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

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

Issue 1938393003: [webnfc] WIP: Implement push method for Android nfc mojo service. Base URL: https://chromium.googlesource.com/chromium/src.git@implement_nfc_push_in_blink
Patch Set: Created 4 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
« no previous file with comments | « content/public/android/BUILD.gn ('k') | device/nfc/android/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/java/src/org/chromium/content/browser/ServiceRegistrar.java
diff --git a/content/public/android/java/src/org/chromium/content/browser/ServiceRegistrar.java b/content/public/android/java/src/org/chromium/content/browser/ServiceRegistrar.java
index e8c279eba71fe6d02ad850868bec051be71ac3e7..831726c4fb009c11a6bb75a440c5f326d3bed372 100644
--- a/content/public/android/java/src/org/chromium/content/browser/ServiceRegistrar.java
+++ b/content/public/android/java/src/org/chromium/content/browser/ServiceRegistrar.java
@@ -4,14 +4,18 @@
package org.chromium.content.browser;
+import android.app.Activity;
import android.content.Context;
import org.chromium.base.annotations.CalledByNative;
import org.chromium.base.annotations.JNINamespace;
import org.chromium.content.browser.ServiceRegistry.ImplementationFactory;
+import org.chromium.content_public.browser.WebContents;
import org.chromium.device.battery.BatteryMonitorFactory;
+import org.chromium.device.nfc.NfcImpl;
import org.chromium.device.vibration.VibrationManagerImpl;
import org.chromium.mojom.device.BatteryMonitor;
+import org.chromium.mojom.device.Nfc;
import org.chromium.mojom.device.VibrationManager;
/**
@@ -35,6 +39,29 @@ class ServiceRegistrar {
}
}
+ private static class NfcImplementationFactory implements ImplementationFactory<Nfc> {
+ private final WebContents mContents;
+
+ NfcImplementationFactory(WebContents contents) {
+ mContents = contents;
+ }
+
+ @Override
+ public Nfc createImpl() {
+ Activity activity = null;
+ ContentViewCore viewCore = null;
+ if (mContents != null) {
+ viewCore = ContentViewCore.fromWebContents(mContents);
+ }
+
+ if (viewCore != null && viewCore.getWindowAndroid() != null) {
+ activity = viewCore.getWindowAndroid().getActivity().get();
+ }
+
+ return new NfcImpl(activity);
+ }
+ }
+
private static class VibrationManagerImplementationFactory
implements ImplementationFactory<VibrationManager> {
private final Context mApplicationContext;
@@ -59,8 +86,10 @@ class ServiceRegistrar {
}
@CalledByNative
- static void registerFrameHostServices(ServiceRegistry registry, Context applicationContext) {
+ static void registerFrameHostServices(ServiceRegistry registry,
+ Context applicationContext, WebContents contents) {
assert applicationContext != null;
// TODO(avayvod): Register the PresentationService implementation here.
+ registry.addService(Nfc.MANAGER, new NfcImplementationFactory(contents));
}
}
« no previous file with comments | « content/public/android/BUILD.gn ('k') | device/nfc/android/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698