| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "modules/nfc/NFC.h" | 5 #include "modules/nfc/NFC.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ScriptPromiseResolver.h" | 7 #include "bindings/core/v8/ScriptPromiseResolver.h" |
| 8 #include "bindings/core/v8/V8ArrayBuffer.h" | 8 #include "bindings/core/v8/V8ArrayBuffer.h" |
| 9 #include "bindings/core/v8/V8StringResource.h" | 9 #include "bindings/core/v8/V8StringResource.h" |
| 10 #include "core/dom/DOMArrayBuffer.h" | 10 #include "core/dom/DOMArrayBuffer.h" |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 const NFCPushMessage& push_message, | 611 const NFCPushMessage& push_message, |
| 612 const NFCPushOptions& options) { | 612 const NFCPushOptions& options) { |
| 613 ScriptPromise promise = RejectIfNotSupported(script_state); | 613 ScriptPromise promise = RejectIfNotSupported(script_state); |
| 614 if (!promise.IsEmpty()) | 614 if (!promise.IsEmpty()) |
| 615 return promise; | 615 return promise; |
| 616 | 616 |
| 617 DOMException* exception = IsValidNFCPushMessage(push_message); | 617 DOMException* exception = IsValidNFCPushMessage(push_message); |
| 618 if (exception) | 618 if (exception) |
| 619 return ScriptPromise::RejectWithDOMException(script_state, exception); | 619 return ScriptPromise::RejectWithDOMException(script_state, exception); |
| 620 | 620 |
| 621 // https://w3c.github.io/web-nfc/#dom-nfc-push |
| 622 // 9. If timeout value is NaN or negative, reject promise with "TypeError" |
| 623 // and abort these steps. |
| 624 if (options.hasTimeout() && |
| 625 (std::isnan(options.timeout()) || options.timeout() < 0)) { |
| 626 return ScriptPromise::Reject( |
| 627 script_state, |
| 628 V8ThrowException::CreateTypeError( |
| 629 script_state->GetIsolate(), |
| 630 "Invalid NFCPushOptions.timeout value was provided.")); |
| 631 } |
| 632 |
| 621 device::nfc::mojom::blink::NFCMessagePtr message = | 633 device::nfc::mojom::blink::NFCMessagePtr message = |
| 622 device::nfc::mojom::blink::NFCMessage::From(push_message); | 634 device::nfc::mojom::blink::NFCMessage::From(push_message); |
| 623 if (!message) | 635 if (!message) |
| 624 return ScriptPromise::RejectWithDOMException( | 636 return ScriptPromise::RejectWithDOMException( |
| 625 script_state, DOMException::Create(kSyntaxError)); | 637 script_state, DOMException::Create(kSyntaxError)); |
| 626 | 638 |
| 627 if (!SetURL( | 639 if (!SetURL( |
| 628 ExecutionContext::From(script_state)->GetSecurityOrigin()->ToString(), | 640 ExecutionContext::From(script_state)->GetSecurityOrigin()->ToString(), |
| 629 message)) | 641 message)) |
| 630 return ScriptPromise::RejectWithDOMException( | 642 return ScriptPromise::RejectWithDOMException( |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 } | 837 } |
| 826 | 838 |
| 827 DEFINE_TRACE(NFC) { | 839 DEFINE_TRACE(NFC) { |
| 828 PageVisibilityObserver::Trace(visitor); | 840 PageVisibilityObserver::Trace(visitor); |
| 829 ContextLifecycleObserver::Trace(visitor); | 841 ContextLifecycleObserver::Trace(visitor); |
| 830 visitor->Trace(requests_); | 842 visitor->Trace(requests_); |
| 831 visitor->Trace(callbacks_); | 843 visitor->Trace(callbacks_); |
| 832 } | 844 } |
| 833 | 845 |
| 834 } // namespace blink | 846 } // namespace blink |
| OLD | NEW |