Commit d4e5a1f1 authored by Francois Beaufort's avatar Francois Beaufort Committed by Chromium LUCI CQ

[WebNFC] Update NFC device README

This CL has no functional changes. It simply updates documentation based
on recent changes.

Bug: 520391
Change-Id: Ic0793147d859854d0bf9f346660e95e0952788f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2586356
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837016}
parent 626c2bde
...@@ -3,67 +3,73 @@ ...@@ -3,67 +3,73 @@
### High level Overview ### High level Overview
The implementation of Web NFC in Chromium consists of two main parts: 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 and the browser side platform
level adaptation that is 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 the Web NFC APIs. - The NFC module in Blink located at `third_party/blink/renderer/modules/nfc/`
The NDEFReader interface has both, write and scan methods. which contains Blink JavaScript bindings for Web NFC.
- The browser side platform level adaptation located at `services/device/nfc`.
The write method is for writing data to the NFC tag. The Blink NFC module communicates with the browser adaptation through NFC Mojo
This method will return a promise, which will be resolved when the interface defined in the `services/device/public/mojom/nfc.mojom` file and
message is successfully written to a NFC tag or be rejected when errors implemented by the `services/device/nfc` module.
happened or the process is aborted by setting the AbortSignal in the
NDEFWriteOptions.
The scan method tries to read data from any NFC tag NDEFReader is the primary interface of Web NFC. The NDEFReader interface has
that comes within proximity. Once there is some data found an both, write and scan methods:
NDEFReadingEvent carrying the data will be dispatched to the NDEFReader.
The most important classes for Android adaptation are - 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 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.
[NfcImpl](../../../services/device/nfc/android/java/src/org/chromium/device/nfc/NfcImpl.java), The most important classes for Android adaptation are [NfcImpl], [NfcTagHandler],
[NfcTagHandler](../../../services/device/nfc/android/java/src/org/chromium/device/nfc/NfcTagHandler.java) and [NdefMessageUtils].
and
[NdefMessageUtils](../../../services/device/nfc/android/java/src/org/chromium/device/nfc/NdefMessageUtils.java). [NfcImpl]: ../../../services/device/nfc/android/java/src/org/chromium/device/nfc/NfcImpl.java
[NfcTagHandler]: ../../../services/device/nfc/android/java/src/org/chromium/device/nfc/NfcTagHandler.java
[NdefMessageUtils]: ../../../services/device/nfc/android/java/src/org/chromium/device/nfc/NdefMessageUtils.java
## Web-exposed Interfaces ## Web-exposed Interfaces
### [NFC specification ](https://w3c.github.io/web-nfc/) ### [Web NFC specification](https://w3c.github.io/web-nfc/)
## Testing: ## Testing:
* Web platform tests are located in - Web platform tests are located in
`third_party/blink/web_tests/external/wpt/web-nfc/` and are a mirror of the `third_party/blink/web_tests/external/wpt/web-nfc/` and are a mirror of the
[web-platform-tests GitHub repository](https://github.com/web-platform-tests/wpt). [web-platform-tests GitHub repository].
* NFC platform unit tests files for Android are - NFC platform unit tests files for Android are [NFCTest.java] and
[NFCTest.java](../../../services/device/nfc/android/junit/src/org/chromium/device/nfc/NFCTest.java) and [NfcBlocklistTest.java]
[NfcBlocklistTest.java](../../../services/device/nfc/android/junit/src/org/chromium/device/nfc/NfcBlocklistTest.java)
[web-platform-tests github repository]: https://github.com/web-platform-tests/wpt
[nfctest.java]: ../../../services/device/nfc/android/junit/src/org/chromium/device/nfc/NFCTest.java
[nfcblocklisttest.java]: ../../../services/device/nfc/android/junit/src/org/chromium/device/nfc/NfcBlocklistTest.java
## Security and Privacy ## Security and Privacy
Web NFC API can be only accessed by top-level secure browsing contexts and user Web NFC API can be only accessed by top-level secure browsing contexts that are
permission is required to access NFC functionality. Web NFC API specification visible. User permission is required to access NFC functionality. Web NFC
addresses security and privacy topics in chapter [7. Security and Privacy](https://w3c.github.io/web-nfc/#security). specification addresses security and privacy topics in "[Security and Privacy]"
chapter.
[Security and Privacy]: https://w3c.github.io/web-nfc/#security
## Permissions ## Permissions
The device service provides no support for permission checks. When the render The device service provides no support for permission checks. When the renderer
process requests access to a NFC this request is proxied through the browser process requests access to NFC, this request is proxied through the browser
process by [NfcPermissionContext](../../../chrome/browser/nfc/nfc_permission_context.h) process by [NfcPermissionContext] which is responsible for checking the
which is responsible for checking the permissions granted to the requesting origin. permissions granted to the requesting origin.
[NfcPermissionContext]: ../../../chrome/browser/nfc/nfc_permission_context.h
## Platform Support ## Platform Support
At the time of writing, only Android platform is supported. At the time of writing, only Android platform is supported.
## Design Documents ## Design Documents
Please refer to the [design documentation](https://sites.google.com/a/chromium.org/dev/developers/design-documents/web-nfc) Please refer to the [design documentation] for more details.
for more details.
[design documentation]: https://sites.google.com/a/chromium.org/dev/developers/design-documents/web-nfc
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment