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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentNfcDelegate.java

Issue 2865653002: [Device Service] Decouple NFC implementation from //content (Closed)
Patch Set: Rebase 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/public/android/java/src/org/chromium/content/browser/ContentNfcDelegate.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentNfcDelegate.java b/content/public/android/java/src/org/chromium/content/browser/ContentNfcDelegate.java
new file mode 100644
index 0000000000000000000000000000000000000000..2fea57f0c511cfe9d837cbdffd196184808038ca
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentNfcDelegate.java
@@ -0,0 +1,38 @@
+// 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.
+
+package org.chromium.content.browser;
+
+import android.app.Activity;
+
+import org.chromium.base.Callback;
+import org.chromium.base.annotations.CalledByNative;
+import org.chromium.device.nfc.NfcDelegate;
+
+/** A //content-specific implementation of the NfcDelegate interface. Maps NFC host ideas to their
+ * corresponding NfcHost objects, allowing the NFC implementation to access the Activity of the
+ * WebContents with which its requesting frame is associated.
+ */
+public class ContentNfcDelegate implements NfcDelegate {
+ @CalledByNative
+ private static ContentNfcDelegate create() {
+ return new ContentNfcDelegate();
+ }
+
+ @Override
+ public void trackActivityForHost(int hostId, Callback<Activity> callback) {
+ NfcHost host = NfcHost.fromContextId(hostId);
+ if (host == null) return;
+ host.trackActivityChanges(callback);
+ }
+
+ @Override
+ public void stopTrackingActivityForHost(int hostId) {
+ NfcHost host = NfcHost.fromContextId(hostId);
+ if (host == null) {
+ return;
+ }
+ host.stopTrackingActivityChanges();
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698