Skip to content

Commit

Permalink
web-nfc: Merge NDEFWriter in NDEFReader
Browse files Browse the repository at this point in the history
NDEFWriter and NDEFReader share a lot of similar
features and a writing device, will also read.

Therefore it was decided to simplify NDEF functionality,
and to have only one class called NDEFReader,
which can read and write.

refers to w3c/web-nfc#601

Because kWebNfcNdefReaderScan and kWebNfcNdefWriterWrite are now
used in idl extended attributes, their usages
may be higher now as they were fired after user granted permission.

Bug: 1131141
Change-Id: I8cc2ce053e5bb43c0fa5b299bdaf5cb5317bf859
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2424208
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Reilly Grant <reillyg@chromium.org>
Reviewed-by: François Beaufort <beaufort.francois@gmail.com>
Commit-Queue: François Beaufort <beaufort.francois@gmail.com>
Cr-Commit-Position: refs/heads/master@{#832236}
  • Loading branch information
beaufortfrancois authored and Chromium LUCI CQ committed Dec 1, 2020
1 parent f77b5e8 commit c86f47d
Show file tree
Hide file tree
Showing 28 changed files with 474 additions and 661 deletions.
4 changes: 2 additions & 2 deletions chrome/browser/chrome_back_forward_cache_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,10 @@ IN_PROC_BROWSER_TEST_F(ChromeBackForwardCacheBrowserTest,

// Use the WebNfc feature on the empty page.
EXPECT_EQ("success", content::EvalJs(current_frame_host(), R"(
const writer = new NDEFWriter();
const ndef = new NDEFReader();
new Promise(async resolve => {
try {
await writer.write("Hello");
await ndef.write("Hello");
resolve('success');
} catch (error) {
resolve(error.message);
Expand Down
7 changes: 4 additions & 3 deletions services/device/nfc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ 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.
NDEFReader is the primary interface of the Web NFC APIs.
The NDEFReader interface has both, write and scan methods.

The NDEFWriter interface has the write method for writing data to NFC tags.
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 NDEFReader interface has the scan method to try to read data from any NFC tag
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.

Expand Down
2 changes: 0 additions & 2 deletions third_party/blink/renderer/bindings/generated_in_modules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -1741,8 +1741,6 @@ generated_interface_sources_in_modules = [
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ndef_reading_event.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ndef_record.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ndef_record.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ndef_writer.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_ndef_writer.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_network_information.cc",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_network_information.h",
"$root_gen_dir/third_party/blink/renderer/bindings/modules/v8/v8_notification.cc",
Expand Down
1 change: 0 additions & 1 deletion third_party/blink/renderer/bindings/idl_in_modules.gni
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ static_idl_files_in_modules = get_path_info(
"//third_party/blink/renderer/modules/nfc/ndef_record_init.idl",
"//third_party/blink/renderer/modules/nfc/ndef_scan_options.idl",
"//third_party/blink/renderer/modules/nfc/ndef_write_options.idl",
"//third_party/blink/renderer/modules/nfc/ndef_writer.idl",
"//third_party/blink/renderer/modules/notifications/get_notification_options.idl",
"//third_party/blink/renderer/modules/notifications/notification.idl",
"//third_party/blink/renderer/modules/notifications/notification_action.idl",
Expand Down
2 changes: 0 additions & 2 deletions third_party/blink/renderer/modules/nfc/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ blink_modules_sources("nfc") {
"ndef_reading_event.h",
"ndef_record.cc",
"ndef_record.h",
"ndef_writer.cc",
"ndef_writer.h",
"nfc_proxy.cc",
"nfc_proxy.h",
"nfc_type_converters.cc",
Expand Down
1 change: 0 additions & 1 deletion third_party/blink/renderer/modules/nfc/idls.gni
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ modules_idl_files = [
"ndef_record.idl",
"ndef_reader.idl",
"ndef_reading_event.idl",
"ndef_writer.idl",
]

modules_dictionary_idl_files = [
Expand Down
Loading

0 comments on commit c86f47d

Please sign in to comment.