tree: ca374378b80863d45d6b05fba95bf0300f7b83dc [path history] [tgz]
  1. android/
  2. DIR_METADATA
  3. OWNERS
  4. README.md
services/device/nfc/README.md

NFC

High level Overview

The implementation of Web NFC in Chromium consists of two main parts:

  • The NFC module in Blink located at third_party/blink/renderer/modules/nfc/ which contains Blink JavaScript bindings for Web NFC.
  • The browser side platform level adaptation located at services/device/nfc.

The Blink NFC module communicates with the browser adaptation through NFC Mojo interface defined in the services/device/public/mojom/nfc.mojom file and implemented by the services/device/nfc module.

NDEFReader is the primary interface of Web NFC. The NDEFReader interface has write, makeReadOnly, and scan methods:

  • The write method is for writing data to an NFC tag. This method returns a promise, which will be resolved when the message is successfully written to an NFC tag, or rejected either when errors happened or process is aborted by setting the AbortSignal in the NDEFWriteOptions.
  • The makeReadOnly method is for making an NFC tag permanently read-only. This method returns a promise, which will be resolved when an NFC tag has been made read-only, or rejected either when errors happened or process is aborted by setting the AbortSignal in the NDEFMakeReadOnlyOptions.
  • The scan method tries to read data from any NFC tag that comes within proximity. Once there is some data found, an NDEFReadingEvent carrying the data is dispatched to the NDEFReader.

The most important classes for Android adaptation are NfcImpl, NfcTagHandler, and NdefMessageUtils.

Web-exposed Interfaces

Web NFC specification

Testing:

Security and Privacy

Web NFC API can be only accessed by top-level secure browsing contexts that are visible. User permission is required to access NFC functionality. Web NFC specification addresses security and privacy topics in “Security and Privacy” chapter.

Permissions

The device service provides no support for permission checks. When the renderer process requests access to NFC, this request is proxied through the browser process by NfcPermissionContext which is responsible for checking the permissions granted to the requesting origin.

Platform Support

At the time of writing, only Android platform is supported.

Design Documents

Please refer to the design documentation for more details.