Chromium Code Reviews| Index: content/public/android/java/src/org/chromium/content/browser/InterfaceRegistrar.java |
| diff --git a/content/public/android/java/src/org/chromium/content/browser/InterfaceRegistrar.java b/content/public/android/java/src/org/chromium/content/browser/InterfaceRegistrar.java |
| index 0bd9b5457963c99b05a896c79e56bfb823c5ef98..29fa870f401db0b29ae1dd5e1cec96030c52e23f 100644 |
| --- a/content/public/android/java/src/org/chromium/content/browser/InterfaceRegistrar.java |
| +++ b/content/public/android/java/src/org/chromium/content/browser/InterfaceRegistrar.java |
| @@ -4,119 +4,25 @@ |
| 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.InterfaceRegistry.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.VibrationManager; |
| -import org.chromium.mojom.device.nfc.Nfc; |
| -import org.chromium.ui.base.WindowAndroid; |
| /** |
| * Registers interfaces exposed by the browser in the given registry. |
| */ |
| @JNINamespace("content") |
| class InterfaceRegistrar { |
|
boliu
2016/09/22 14:32:18
this looks empty now, can this be removed?
Sam McNally
2016/09/23 01:38:50
Yes. I was going to delete it in a follow up CL: h
|
| - // BatteryMonitorFactory can't implement ImplementationFactory itself, as we don't depend on |
| - // /content in /device. Hence we use BatteryMonitorImplementationFactory as a wrapper. |
| - private static class BatteryMonitorImplementationFactory |
| - implements ImplementationFactory<BatteryMonitor> { |
| - private final BatteryMonitorFactory mFactory; |
| - |
| - BatteryMonitorImplementationFactory(Context applicationContext) { |
| - mFactory = new BatteryMonitorFactory(applicationContext); |
| - } |
| - |
| - @Override |
| - public BatteryMonitor createImpl() { |
| - return mFactory.createMonitor(); |
| - } |
| - } |
| - |
| - private static class VibrationManagerImplementationFactory |
| - implements ImplementationFactory<VibrationManager> { |
| - private final Context mApplicationContext; |
| - |
| - VibrationManagerImplementationFactory(Context applicationContext) { |
| - mApplicationContext = applicationContext; |
| - } |
| - |
| - @Override |
| - public VibrationManager createImpl() { |
| - return new VibrationManagerImpl(mApplicationContext); |
| - } |
| - } |
| - |
| - private static class NfcImplementationFactory implements ImplementationFactory<Nfc> { |
| - private final Context mContext; |
| - private final WebContents mContents; |
| - |
| - NfcImplementationFactory(Context context, WebContents contents) { |
| - mContext = context; |
| - mContents = contents; |
| - } |
| - |
| - private static class ContextAwareNfcImpl extends NfcImpl implements |
| - WindowAndroidChangedObserver { |
| - private final ContentViewCore mContextViewCore; |
| - |
| - ContextAwareNfcImpl(Context context, ContentViewCore contextViewCore) { |
| - super(context); |
| - mContextViewCore = contextViewCore; |
| - if (mContextViewCore != null) { |
| - mContextViewCore.addWindowAndroidChangedObserver(this); |
| - if (mContextViewCore.getWindowAndroid() != null) { |
| - setActivity(mContextViewCore.getWindowAndroid().getActivity().get()); |
| - } |
| - } |
| - } |
| - |
| - @Override |
| - public void close() { |
| - super.close(); |
| - if (mContextViewCore != null) { |
| - mContextViewCore.removeWindowAndroidChangedObserver(this); |
| - } |
| - } |
| - |
| - @Override |
| - public void onWindowAndroidChanged(WindowAndroid newWindowAndroid) { |
| - Activity activity = null; |
| - if (newWindowAndroid != null) { |
| - activity = newWindowAndroid.getActivity().get(); |
| - } |
| - setActivity(activity); |
| - } |
| - } |
| - |
| - @Override |
| - public Nfc createImpl() { |
| - return new ContextAwareNfcImpl(mContext, ContentViewCore.fromWebContents(mContents)); |
| - } |
| - } |
| - |
| @CalledByNative |
| static void exposeInterfacesToRenderer(InterfaceRegistry registry, Context applicationContext) { |
| assert applicationContext != null; |
| - registry.addInterface(BatteryMonitor.MANAGER, |
| - new BatteryMonitorImplementationFactory(applicationContext)); |
| } |
| @CalledByNative |
| static void exposeInterfacesToFrame(InterfaceRegistry registry, |
| Context applicationContext, WebContents contents) { |
| assert applicationContext != null; |
| - registry.addInterface(VibrationManager.MANAGER, |
| - new VibrationManagerImplementationFactory(applicationContext)); |
| - registry.addInterface(Nfc.MANAGER, |
| - new NfcImplementationFactory(applicationContext, contents)); |
| - // TODO(avayvod): Register the PresentationService implementation here. |
| } |
| } |