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 {
continue;
}
}
if (!options.mediaType.isEmpty()
&& !options.mediaType.equals(message.data[i].mediaType)) {
if (options.mediaType != null && !options.mediaType.equals(message.data[i].mediaType)) {
continue;
}
......
......@@ -1234,7 +1234,6 @@ public class NFCTest {
private NdefScanOptions createNdefScanOptions() {
NdefScanOptions options = new NdefScanOptions();
options.mediaType = "";
return options;
}
......
......@@ -106,11 +106,13 @@ struct NDEFScanOptions {
// string means must match on empty.
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;
// Defines media type filtering constraint. Empty string means don't filter.
string media_type;
// Defines media type filtering constraint. Null means don't filter, empty
// string means must match on empty.
string? media_type;
};
interface NFC {
......
......@@ -6,6 +6,6 @@
dictionary NDEFScanOptions {
USVString id;
USVString recordType;
USVString mediaType = "";
USVString mediaType;
AbortSignal? signal;
};
......@@ -70,9 +70,8 @@ TypeConverter<NDEFScanOptionsPtr, const blink::NDEFScanOptions*>::Convert(
const blink::NDEFScanOptions* scanOptions) {
// https://w3c.github.io/web-nfc/#dom-ndefscanoptions
// Default values for NDEFScanOptions dictionary are:
// id = undefined, recordType = undefined, mediaType = ""
// id = undefined, recordType = undefined, mediaType = undefined
NDEFScanOptionsPtr scanOptionsPtr = NDEFScanOptions::New();
scanOptionsPtr->media_type = scanOptions->mediaType();
if (scanOptions->hasId()) {
scanOptionsPtr->id = scanOptions->id();
......@@ -82,6 +81,10 @@ TypeConverter<NDEFScanOptionsPtr, const blink::NDEFScanOptions*>::Convert(
scanOptionsPtr->record_type = scanOptions->recordType();
}
if (scanOptions->hasMediaType()) {
scanOptionsPtr->media_type = scanOptions->mediaType();
}
return scanOptionsPtr;
}
......
......@@ -133,7 +133,7 @@ function matchesWatchOptions(message, options) {
options.recordType !== record.recordType) {
continue;
}
if (options.mediaType !== '' && options.mediaType !== record.mediaType) {
if (options.mediaType != null && options.mediaType !== record.mediaType) {
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