Commit 9d172709 authored by Leon Han's avatar Leon Han Committed by Commit Bot

[webnfc] NDEFScanOptions#mediaType being undefined means do not filter

And the empty string should just match on empty.

The spec change:
https://github.com/w3c/web-nfc/pull/496
https://github.com/w3c/web-nfc/pull/498

BUG=520391

Change-Id: Idae55b976a6fbbdd252f6227cbe13ee50d16269c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1986632Reviewed-by: default avatarRijubrata Bhaumik <rijubrata.bhaumik@intel.com>
Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Leon Han <leon.han@intel.com>
Cr-Commit-Position: refs/heads/master@{#728813}
parent 29af8e17
...@@ -612,8 +612,7 @@ public class NfcImpl implements Nfc { ...@@ -612,8 +612,7 @@ public class NfcImpl implements Nfc {
continue; continue;
} }
} }
if (!options.mediaType.isEmpty() if (options.mediaType != null && !options.mediaType.equals(message.data[i].mediaType)) {
&& !options.mediaType.equals(message.data[i].mediaType)) {
continue; continue;
} }
......
...@@ -1234,7 +1234,6 @@ public class NFCTest { ...@@ -1234,7 +1234,6 @@ public class NFCTest {
private NdefScanOptions createNdefScanOptions() { private NdefScanOptions createNdefScanOptions() {
NdefScanOptions options = new NdefScanOptions(); NdefScanOptions options = new NdefScanOptions();
options.mediaType = "";
return options; return options;
} }
......
...@@ -106,11 +106,13 @@ struct NDEFScanOptions { ...@@ -106,11 +106,13 @@ struct NDEFScanOptions {
// string means must match on empty. // string means must match on empty.
string? id; string? id;
// Defines record type filtering constraint. // Defines record type filtering constraint. Null means don't filter, empty
// string means must match on empty.
string? record_type; string? record_type;
// Defines media type filtering constraint. Empty string means don't filter. // Defines media type filtering constraint. Null means don't filter, empty
string media_type; // string means must match on empty.
string? media_type;
}; };
interface NFC { interface NFC {
......
...@@ -6,6 +6,6 @@ ...@@ -6,6 +6,6 @@
dictionary NDEFScanOptions { dictionary NDEFScanOptions {
USVString id; USVString id;
USVString recordType; USVString recordType;
USVString mediaType = ""; USVString mediaType;
AbortSignal? signal; AbortSignal? signal;
}; };
...@@ -70,9 +70,8 @@ TypeConverter<NDEFScanOptionsPtr, const blink::NDEFScanOptions*>::Convert( ...@@ -70,9 +70,8 @@ TypeConverter<NDEFScanOptionsPtr, const blink::NDEFScanOptions*>::Convert(
const blink::NDEFScanOptions* scanOptions) { const blink::NDEFScanOptions* scanOptions) {
// https://w3c.github.io/web-nfc/#dom-ndefscanoptions // https://w3c.github.io/web-nfc/#dom-ndefscanoptions
// Default values for NDEFScanOptions dictionary are: // Default values for NDEFScanOptions dictionary are:
// id = undefined, recordType = undefined, mediaType = "" // id = undefined, recordType = undefined, mediaType = undefined
NDEFScanOptionsPtr scanOptionsPtr = NDEFScanOptions::New(); NDEFScanOptionsPtr scanOptionsPtr = NDEFScanOptions::New();
scanOptionsPtr->media_type = scanOptions->mediaType();
if (scanOptions->hasId()) { if (scanOptions->hasId()) {
scanOptionsPtr->id = scanOptions->id(); scanOptionsPtr->id = scanOptions->id();
...@@ -82,6 +81,10 @@ TypeConverter<NDEFScanOptionsPtr, const blink::NDEFScanOptions*>::Convert( ...@@ -82,6 +81,10 @@ TypeConverter<NDEFScanOptionsPtr, const blink::NDEFScanOptions*>::Convert(
scanOptionsPtr->record_type = scanOptions->recordType(); scanOptionsPtr->record_type = scanOptions->recordType();
} }
if (scanOptions->hasMediaType()) {
scanOptionsPtr->media_type = scanOptions->mediaType();
}
return scanOptionsPtr; return scanOptionsPtr;
} }
......
...@@ -133,7 +133,7 @@ function matchesWatchOptions(message, options) { ...@@ -133,7 +133,7 @@ function matchesWatchOptions(message, options) {
options.recordType !== record.recordType) { options.recordType !== record.recordType) {
continue; continue;
} }
if (options.mediaType !== '' && options.mediaType !== record.mediaType) { if (options.mediaType != null && options.mediaType !== record.mediaType) {
continue; continue;
} }
......
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