Commit 2ad1dc61 authored by Rijubrata Bhaumik's avatar Rijubrata Bhaumik Committed by Commit Bot

[webnfc] Rename NFCPushMessage union to NFCMessageSource.

git grep -l 'NFCPushMessage' | xargs sed -i 's/NFCPushMessage/NDEFMessageSource/g'

Corresponding Spec changes:
https://github.com/w3c/web-nfc/commit/bf85df9e534da7351fc4c870228857dddef37e0e

Bug: 520391
Change-Id: I07980bfa1e68fc8959541442ddf4c83db968a52f
Reviewed-on: https://chromium-review.googlesource.com/c/1483028Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Reviewed-by: default avatarPhilip Jägenstedt <foolip@chromium.org>
Commit-Queue: Rijubrata Bhaumik <rijubrata.bhaumik@intel.com>
Cr-Commit-Position: refs/heads/master@{#636194}
parent efffa248
...@@ -290,8 +290,8 @@ struct TypeConverter<NDEFMessagePtr, blink::DOMArrayBuffer*> { ...@@ -290,8 +290,8 @@ struct TypeConverter<NDEFMessagePtr, blink::DOMArrayBuffer*> {
}; };
template <> template <>
struct TypeConverter<NDEFMessagePtr, blink::NFCPushMessage> { struct TypeConverter<NDEFMessagePtr, blink::NDEFMessageSource> {
static NDEFMessagePtr Convert(const blink::NFCPushMessage& message) { static NDEFMessagePtr Convert(const blink::NDEFMessageSource& message) {
if (message.IsString()) if (message.IsString())
return NDEFMessage::From(message.GetAsString()); return NDEFMessage::From(message.GetAsString());
...@@ -499,14 +499,14 @@ ScriptPromise RejectIfInvalidNDEFRecordArray( ...@@ -499,14 +499,14 @@ ScriptPromise RejectIfInvalidNDEFRecordArray(
return ScriptPromise(); return ScriptPromise();
} }
ScriptPromise RejectIfInvalidNFCPushMessage( ScriptPromise RejectIfInvalidNDEFMessageSource(
ScriptState* script_state, ScriptState* script_state,
const NFCPushMessage& push_message) { const NDEFMessageSource& push_message) {
// If NFCPushMessage of invalid type, reject promise with TypeError // If NDEFMessageSource of invalid type, reject promise with TypeError
if (!push_message.IsNDEFMessage() && !push_message.IsString() && if (!push_message.IsNDEFMessage() && !push_message.IsString() &&
!push_message.IsArrayBuffer()) { !push_message.IsArrayBuffer()) {
return RejectWithTypeError(script_state, return RejectWithTypeError(script_state,
"Invalid NFCPushMessage type was provided."); "Invalid NDEFMessageSource type was provided.");
} }
if (push_message.IsNDEFMessage()) { if (push_message.IsNDEFMessage()) {
...@@ -681,14 +681,14 @@ void NFC::ContextDestroyed(ExecutionContext*) { ...@@ -681,14 +681,14 @@ void NFC::ContextDestroyed(ExecutionContext*) {
// https://w3c.github.io/web-nfc/#writing-or-pushing-content // https://w3c.github.io/web-nfc/#writing-or-pushing-content
// https://w3c.github.io/web-nfc/#dom-nfc-push // https://w3c.github.io/web-nfc/#dom-nfc-push
ScriptPromise NFC::push(ScriptState* script_state, ScriptPromise NFC::push(ScriptState* script_state,
const NFCPushMessage& push_message, const NDEFMessageSource& push_message,
const NFCPushOptions* options) { const NFCPushOptions* options) {
ScriptPromise promise = RejectIfNotSupported(script_state); ScriptPromise promise = RejectIfNotSupported(script_state);
if (!promise.IsEmpty()) if (!promise.IsEmpty())
return promise; return promise;
ScriptPromise isValidMessage = ScriptPromise isValidMessage =
RejectIfInvalidNFCPushMessage(script_state, push_message); RejectIfInvalidNDEFMessageSource(script_state, push_message);
if (!isValidMessage.IsEmpty()) if (!isValidMessage.IsEmpty())
return isValidMessage; return isValidMessage;
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
namespace blink { namespace blink {
class NFCPushOptions; class NFCPushOptions;
using NFCPushMessage = StringOrArrayBufferOrNDEFMessage; using NDEFMessageSource = StringOrArrayBufferOrNDEFMessage;
class NFCWatchOptions; class NFCWatchOptions;
class ScriptPromiseResolver; class ScriptPromiseResolver;
...@@ -41,9 +41,9 @@ class NFC final : public ScriptWrappable, ...@@ -41,9 +41,9 @@ class NFC final : public ScriptWrappable,
// ContextLifecycleObserver overrides. // ContextLifecycleObserver overrides.
void ContextDestroyed(ExecutionContext*) override; void ContextDestroyed(ExecutionContext*) override;
// Pushes NFCPushMessage asynchronously to NFC tag / peer. // Pushes NDEFMessageSource asynchronously to NFC tag / peer.
ScriptPromise push(ScriptState*, ScriptPromise push(ScriptState*,
const NFCPushMessage&, const NDEFMessageSource&,
const NFCPushOptions*); const NFCPushOptions*);
// Cancels ongoing push operation. // Cancels ongoing push operation.
......
...@@ -2,15 +2,17 @@ ...@@ -2,15 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// https://w3c.github.io/web-nfc/#the-nfc-interface // https://w3c.github.io/web-nfc/#dom-ndefmessagesource
typedef (DOMString or ArrayBuffer or NDEFMessage) NDEFMessageSource;
typedef (DOMString or ArrayBuffer or NDEFMessage) NFCPushMessage; // https://w3c.github.io/web-nfc/#the-nfc-interface
[ [
RuntimeEnabled=WebNFC, RuntimeEnabled=WebNFC,
SecureContext SecureContext
] interface NFC { ] interface NFC {
[CallWith=ScriptState, MeasureAs=WebNFCPush] Promise<void> push (NFCPushMessage message, optional NFCPushOptions options); [CallWith=ScriptState, MeasureAs=WebNFCPush] Promise<void> push (NDEFMessageSource message, optional NFCPushOptions options);
[CallWith=ScriptState, MeasureAs=WebNFCCancelPush] Promise<void> cancelPush (optional NFCPushTarget target = "any"); [CallWith=ScriptState, MeasureAs=WebNFCCancelPush] Promise<void> cancelPush (optional NFCPushTarget target = "any");
[CallWith=ScriptState, MeasureAs=WebNFCWatch] Promise<long> watch (MessageCallback callback, optional NFCWatchOptions options); [CallWith=ScriptState, MeasureAs=WebNFCWatch] Promise<long> watch (MessageCallback callback, optional NFCWatchOptions options);
[CallWith=ScriptState, MeasureAs=WebNFCCancelWatch] Promise<void> cancelWatch (optional long id); [CallWith=ScriptState, MeasureAs=WebNFCCancelWatch] Promise<void> cancelWatch (optional long id);
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
const invalid_type_messages = const invalid_type_messages =
[ [
// Invalid NFCPushMessage type // Invalid NDEFMessageSource type
undefined, undefined,
// NDEFMessage.records: should have at least 1 valid record. // NDEFMessage.records: should have at least 1 valid record.
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
const invalid_type_messages = const invalid_type_messages =
[ [
// Invalid NFCPushMessage type // Invalid NDEFMessageSource type
undefined, undefined,
// NDEFMessage.records: should have at least 1 valid record. // NDEFMessage.records: should have at least 1 valid record.
......
...@@ -142,7 +142,7 @@ function toByteArray(data) { ...@@ -142,7 +142,7 @@ function toByteArray(data) {
function assertNDEFMessagesEqual(providedMessage, receivedMessage) { function assertNDEFMessagesEqual(providedMessage, receivedMessage) {
// If simple data type is passed, e.g. String or ArrayBuffer, convert it // If simple data type is passed, e.g. String or ArrayBuffer, convert it
// to NDEFMessage before comparing. // to NDEFMessage before comparing.
// https://w3c.github.io/web-nfc/#idl-def-nfcpushmessage // https://w3c.github.io/web-nfc/#dom-ndefmessagesource
let provided = providedMessage; let provided = providedMessage;
if (providedMessage instanceof ArrayBuffer) if (providedMessage instanceof ArrayBuffer)
provided = createMessage([createOpaqueRecord(providedMessage)]); provided = createMessage([createOpaqueRecord(providedMessage)]);
......
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