Skip to content

Commit

Permalink
Add README.md for Web NFC.
Browse files Browse the repository at this point in the history
This CL adds some documentation for the NFC module in Chrome.
The detailed design documentation is located at
https://sites.google.com/a/chromium.org/dev/developers/design-documents/web-nfc
and the READMEs do reference that document for more details.

Bug: 520391
Change-Id: Ib8b7632d0bf9bba2b3de9fb1b9bf4f528fa11162
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1985961
Commit-Queue: Rijubrata Bhaumik <rijubrata.bhaumik@intel.com>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Reviewed-by: Leon Han <leon.han@intel.com>
Reviewed-by: François Beaufort <beaufort.francois@gmail.com>
Cr-Commit-Position: refs/heads/master@{#729664}
  • Loading branch information
riju authored and Commit Bot committed Jan 9, 2020
1 parent efba8d2 commit 7d08b29
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
69 changes: 69 additions & 0 deletions services/device/nfc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# 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 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.

NDEFWriter and NDEFReader are the two primary interfaces of the Web NFC APIs.

The NDEFWriter interface has the push method for writing data to NFC devices such as
tags. This method will return a promise, which will be resolved when the
message is successfully written to some target or be rejected when errors
happened or the process is aborted by setting the AbortSignal in the
NDEFPushOptions.

The NDEFReader interface has the scan method to try to read data from any NFC device
that comes within proximity. Once there is some data found to be matching the
filtering criteria provided by web developers in NDEFScanOptions, an
NDEFReadingEvent carrying the data will be dispatched to the NDEFReader.

The most important classes for Android adaptation are

[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).

## Web-exposed Interfaces

### [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 file for Android is
[NFCTest.java](../../../services/device/nfc/android/junit/src/org/chromium/device/nfc/NFCTest.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).


## 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.


## 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.
20 changes: 20 additions & 0 deletions third_party/blink/renderer/modules/nfc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Web NFC Blink Module

`renderer/modules/nfc` implements the renderer process details and bindings for
the [Web NFC specification]. It communicates with the browser process through the
[Web NFC Mojo interface]. The platform-specific parts of the
implementation are located in `services/device/nfc`.

[Web NFC specification]: https://w3c.github.io/web-nfc/
[Web NFC Mojo interface]: ../../../../../services/device/public/mojom/nfc.mojom


## Testing

Web NFC is primarily tested in [Web Platform Tests](https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/web_tests/external/wpt/web-nfc/).


## Design Documents

Please refer to the [design documentation](https://sites.google.com/a/chromium.org/dev/developers/design-documents/web-nfc)
for more details.

0 comments on commit 7d08b29

Please sign in to comment.