The implementation of Web NFC in Chromium consists of two main parts:
third_party/blink/renderer/modules/nfc/
which contains Blink JavaScript bindings for Web NFC.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 most important classes for Android adaptation are NfcImpl, NfcTagHandler, and NdefMessageUtils.
third_party/blink/web_tests/external/wpt/web-nfc/
and are a mirror of the web-platform-tests GitHub repository.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.
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.
At the time of writing, only Android platform is supported.
Please refer to the design documentation for more details.