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

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: Response to reviews 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..15829c0a5d85cfdafea394ef29b9908b3514de3b
--- /dev/null
+++ b/content/public/android/java/src/org/chromium/content/browser/ContentNfcDelegate.java
@@ -0,0 +1,40 @@
+// 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
+ static ContentNfcDelegate create() {
Ted C 2017/05/10 14:37:40 can this be private?
blundell 2017/05/11 15:13:51 Done.
+ return new ContentNfcDelegate();
+ }
+
+ public void trackActivityForHost(int hostId, Callback<Activity> callback) {
Ted C 2017/05/10 14:37:41 should have an @Override here and below
+ NfcHost host = NfcHost.fromContextId(hostId);
+ if (host == null) {
Ted C 2017/05/10 14:37:41 FYI, if the statement and condition all fit on a s
blundell 2017/05/11 15:13:52 It is valid for the host to be null: a request mig
+ return;
+ }
+ host.trackActivityChanges(callback);
+ }
+
+ 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