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

Unified Diff: third_party/WebKit/Source/modules/nfc/NFC.h

Issue 1759373003: [webnfc] Implement nfc.watch in blink nfc module. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@implement_nfc_push_in_android
Patch Set: Rebased. Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/nfc/NFC.h
diff --git a/third_party/WebKit/Source/modules/nfc/NFC.h b/third_party/WebKit/Source/modules/nfc/NFC.h
index 60c799562a2a4e22a0777a8cd55065ebbe7174ee..63211947124eb1f5e5520f37aaa6b78e40f7579f 100644
--- a/third_party/WebKit/Source/modules/nfc/NFC.h
+++ b/third_party/WebKit/Source/modules/nfc/NFC.h
@@ -11,7 +11,9 @@
#include "bindings/modules/v8/UnionTypesModules.h"
#include "core/page/PageLifecycleObserver.h"
#include "device/nfc/nfc.mojom-wtf.h"
+#include "modules/nfc/MessageCallback.h"
#include "mojo/public/cpp/bindings/binding.h"
+#include "wtf/HashMap.h"
namespace blink {
@@ -19,6 +21,7 @@ class MessageCallback;
class NFCError;
class NFCPushOptions;
using NFCPushMessage = StringOrArrayBufferOrNFCMessage;
+class NFCWatchCallback;
class NFCWatchOptions;
class ServiceRegistry;
@@ -58,15 +61,23 @@ public:
DECLARE_VIRTUAL_TRACE();
private:
+ friend class NFCWatchCallback;
bool Initialize(ServiceRegistry*);
+
+ // Returns promise with DOMException if feature is not supported
+ // or when context is not secure. Otherwise, returns empty promise.
+ ScriptPromise RejectIfNotSupported(ScriptState*);
void OnError();
// device::wtf::NFCClient implementation
void OnWatch(uint32_t id, device::wtf::NFCMessagePtr) override;
+ void OnWatchRegistered(uint32_t id, MessageCallback*);
private:
explicit NFC(LocalFrame*);
device::wtf::NFCPtr m_nfc;
mojo::Binding<device::wtf::NFCClient> m_client;
+ using WatchCallbacksMap = HeapHashMap<uint32_t, Member<MessageCallback>>;
+ WatchCallbacksMap m_callbacks;
};
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698