Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: third_party/WebKit/Source/modules/nfc/NFC.h

Issue 2875283002: [NFC] Only connect to NFC impl if ExecutionContext supports it (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/nfc/NFC.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 |context|. If not,
69 // |error_message| gives a message indicating why not.
70 bool IsSupportedInContext(ExecutionContext*, String&);
jochen (gone - plz use gerrit) 2017/05/15 05:34:55 nit. should be String& error_message, as it's not
blundell 2017/05/15 07:27:55 Done.
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
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/modules/nfc/NFC.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698