| 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 #ifndef NFC_h | 5 #ifndef NFC_h |
| 6 #define NFC_h | 6 #define NFC_h |
| 7 | 7 |
| 8 #include "bindings/core/v8/ScriptPromise.h" | 8 #include "bindings/core/v8/ScriptPromise.h" |
| 9 #include "bindings/modules/v8/StringOrArrayBufferOrNFCMessage.h" | 9 #include "bindings/modules/v8/StringOrArrayBufferOrNFCMessage.h" |
| 10 #include "core/dom/ContextLifecycleObserver.h" | 10 #include "core/dom/ContextLifecycleObserver.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // Cancels all watch operations. | 58 // Cancels all watch operations. |
| 59 ScriptPromise cancelWatch(ScriptState*); | 59 ScriptPromise cancelWatch(ScriptState*); |
| 60 | 60 |
| 61 // Implementation of PageVisibilityObserver. | 61 // Implementation of PageVisibilityObserver. |
| 62 void PageVisibilityChanged() override; | 62 void PageVisibilityChanged() override; |
| 63 | 63 |
| 64 // Interface required by garbage collection. | 64 // Interface required by garbage collection. |
| 65 DECLARE_VIRTUAL_TRACE(); | 65 DECLARE_VIRTUAL_TRACE(); |
| 66 | 66 |
| 67 private: | 67 private: |
| 68 // Returns boolean indicating whether NFC is supported in this context. If |
| 69 // not, |error_message| gives a message indicating why not. |
| 70 bool IsSupportedInContext(ExecutionContext*, String& error_message); |
| 71 |
| 68 // Returns promise with DOMException if feature is not supported | 72 // Returns promise with DOMException if feature is not supported |
| 69 // or when context is not secure. Otherwise, returns empty promise. | 73 // or when context is not secure. Otherwise, returns empty promise. |
| 70 ScriptPromise RejectIfNotSupported(ScriptState*); | 74 ScriptPromise RejectIfNotSupported(ScriptState*); |
| 71 | 75 |
| 72 void OnRequestCompleted(ScriptPromiseResolver*, | 76 void OnRequestCompleted(ScriptPromiseResolver*, |
| 73 device::nfc::mojom::blink::NFCErrorPtr); | 77 device::nfc::mojom::blink::NFCErrorPtr); |
| 74 void OnConnectionError(); | 78 void OnConnectionError(); |
| 75 void OnWatchRegistered(MessageCallback*, | 79 void OnWatchRegistered(MessageCallback*, |
| 76 ScriptPromiseResolver*, | 80 ScriptPromiseResolver*, |
| 77 uint32_t id, | 81 uint32_t id, |
| 78 device::nfc::mojom::blink::NFCErrorPtr); | 82 device::nfc::mojom::blink::NFCErrorPtr); |
| 79 | 83 |
| 80 // device::nfc::mojom::blink::NFCClient implementation. | 84 // device::nfc::mojom::blink::NFCClient implementation. |
| 81 void OnWatch(const WTF::Vector<uint32_t>& ids, | 85 void OnWatch(const WTF::Vector<uint32_t>& ids, |
| 82 device::nfc::mojom::blink::NFCMessagePtr) override; | 86 device::nfc::mojom::blink::NFCMessagePtr) override; |
| 83 | 87 |
| 84 private: | 88 private: |
| 85 explicit NFC(LocalFrame*); | 89 explicit NFC(LocalFrame*); |
| 86 device::nfc::mojom::blink::NFCPtr nfc_; | 90 device::nfc::mojom::blink::NFCPtr nfc_; |
| 87 mojo::Binding<device::nfc::mojom::blink::NFCClient> client_; | 91 mojo::Binding<device::nfc::mojom::blink::NFCClient> client_; |
| 88 HeapHashSet<Member<ScriptPromiseResolver>> requests_; | 92 HeapHashSet<Member<ScriptPromiseResolver>> requests_; |
| 89 using WatchCallbacksMap = HeapHashMap<uint32_t, Member<MessageCallback>>; | 93 using WatchCallbacksMap = HeapHashMap<uint32_t, Member<MessageCallback>>; |
| 90 WatchCallbacksMap callbacks_; | 94 WatchCallbacksMap callbacks_; |
| 91 }; | 95 }; |
| 92 | 96 |
| 93 } // namespace blink | 97 } // namespace blink |
| 94 | 98 |
| 95 #endif // NFC_h | 99 #endif // NFC_h |
| OLD | NEW |