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 @@
### 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 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 NDEFReader interface has both, write and scan methods.
- 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 write method is for writing data to the NFC tag.
This method will return a promise, which will be resolved when the
message is successfully written to a NFC tag or be rejected when errors
happened or the process is aborted by setting the AbortSignal in the
NDEFWriteOptions.
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.
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 will be dispatched to the NDEFReader.
NDEFReader is the primary interface of Web NFC. The NDEFReader interface has
both, write and scan methods:
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),
[NfcTagHandler](../../../services/device/nfc/android/java/src/org/chromium/device/nfc/NfcTagHandler.java)
and
[NdefMessageUtils](../../../services/device/nfc/android/java/src/org/chromium/device/nfc/NdefMessageUtils.java).
The most important classes for Android adaptation are [NfcImpl], [NfcTagHandler],
and [NdefMessageUtils].
[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
### [NFC specification ](https://w3c.github.io/web-nfc/)
### [Web NFC specification](https://w3c.github.io/web-nfc/)
## Testing:
* Web platform tests are located in
`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).
* NFC platform unit tests files for Android are
[NFCTest.java](../../../services/device/nfc/android/junit/src/org/chromium/device/nfc/NFCTest.java) and
[NfcBlocklistTest.java](../../../services/device/nfc/android/junit/src/org/chromium/device/nfc/NfcBlocklistTest.java)
- Web platform tests are located in
`third_party/blink/web_tests/external/wpt/web-nfc/` and are a mirror of the
[web-platform-tests GitHub repository].
- NFC platform unit tests files for Android are [NFCTest.java] and
[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
Web NFC API can be only accessed by top-level secure browsing contexts and user
permission is required to access NFC functionality. Web NFC API specification
addresses security and privacy topics in chapter [7. Security and Privacy](https://w3c.github.io/web-nfc/#security).
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.
[Security and Privacy]: https://w3c.github.io/web-nfc/#security
## Permissions
The device service provides no support for permission checks. When the render
process requests access to a NFC this request is proxied through the browser
process by [NfcPermissionContext](../../../chrome/browser/nfc/nfc_permission_context.h)
which is responsible for checking the permissions granted to the requesting origin.
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.
[NfcPermissionContext]: ../../../chrome/browser/nfc/nfc_permission_context.h
## Platform Support
At the time of writing, only Android platform is supported.
## Design Documents
Please refer to the [design documentation](https://sites.google.com/a/chromium.org/dev/developers/design-documents/web-nfc)
for more details.
Please refer to the [design documentation] 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