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

Unified Diff: content/browser/nfc/nfc_host.h

Issue 2865653002: [Device Service] Decouple NFC implementation from //content (Closed)
Patch Set: Response to review + fix for tests that don't actually run on bots 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/nfc/nfc_host.h
diff --git a/content/browser/nfc/nfc_host.h b/content/browser/nfc/nfc_host.h
new file mode 100644
index 0000000000000000000000000000000000000000..4daff0cae993915a7f16a8e1b51603fe95ee10ca
--- /dev/null
+++ b/content/browser/nfc/nfc_host.h
@@ -0,0 +1,45 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_NFC_NFC_HOST_H_
+#define CONTENT_BROWSER_NFC_NFC_HOST_H_
+
+#include "content/public/browser/web_contents.h"
+#include "device/nfc/nfc_provider.mojom.h"
+
+#if defined(OS_ANDROID)
+#include "base/android/jni_android.h"
+#endif
+namespace content {
+
+// On Android, NFC requires the Activity associated with the context in order to
+// access the NFC system APIs. NFCHost provides this functionality by mapping
+// NFC context IDs to the WebContents associated with those IDs.
+class NFCHost {
+ public:
+ explicit NFCHost(WebContents* web_contents);
+ ~NFCHost();
+
+ void GetNFC(device::nfc::mojom::NFCRequest request);
+
+ private:
+ // This instance's ID (passed to the NFC implementation via |nfc_provider_|
+ // and used from the implementation to map back to this object).
+ int id_;
+
+ // The WebContents that owns this instance.
+ WebContents* web_contents_;
+
+ device::nfc::mojom::NFCProviderPtr nfc_provider_;
+
+#if defined(OS_ANDROID)
+ base::android::ScopedJavaGlobalRef<jobject> java_nfc_host_;
+#endif
+
+ DISALLOW_COPY_AND_ASSIGN(NFCHost);
+};
+
+} // namespace content
+
+#endif // CONTENT_BROWSER_NFC_NFC_HOST_H_

Powered by Google App Engine
This is Rietveld 408576698