| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 | 8 |
| 9 import org.chromium.base.annotations.CalledByNative; | 9 import org.chromium.base.annotations.CalledByNative; |
| 10 import org.chromium.base.annotations.JNINamespace; | 10 import org.chromium.base.annotations.JNINamespace; |
| 11 import org.chromium.content.browser.androidoverlay.AndroidOverlayProviderImpl; | 11 import org.chromium.content.browser.androidoverlay.AndroidOverlayProviderImpl; |
| 12 import org.chromium.content.browser.installedapp.InstalledAppProviderFactory; |
| 12 import org.chromium.content.browser.shapedetection.FaceDetectionProviderImpl; | 13 import org.chromium.content.browser.shapedetection.FaceDetectionProviderImpl; |
| 13 import org.chromium.content_public.browser.InterfaceRegistrar; | 14 import org.chromium.content_public.browser.InterfaceRegistrar; |
| 14 import org.chromium.content_public.browser.RenderFrameHost; | 15 import org.chromium.content_public.browser.RenderFrameHost; |
| 15 import org.chromium.content_public.browser.WebContents; | 16 import org.chromium.content_public.browser.WebContents; |
| 16 import org.chromium.device.BatteryMonitor; | 17 import org.chromium.device.BatteryMonitor; |
| 17 import org.chromium.device.battery.BatteryMonitorFactory; | 18 import org.chromium.device.battery.BatteryMonitorFactory; |
| 18 import org.chromium.device.mojom.VibrationManager; | 19 import org.chromium.device.mojom.VibrationManager; |
| 19 import org.chromium.device.nfc.mojom.Nfc; | 20 import org.chromium.device.nfc.mojom.Nfc; |
| 20 import org.chromium.device.vibration.VibrationManagerImpl; | 21 import org.chromium.device.vibration.VibrationManagerImpl; |
| 22 import org.chromium.installedapp.mojom.InstalledAppProvider; |
| 21 import org.chromium.media.mojom.AndroidOverlayProvider; | 23 import org.chromium.media.mojom.AndroidOverlayProvider; |
| 22 import org.chromium.mojo.system.impl.CoreImpl; | 24 import org.chromium.mojo.system.impl.CoreImpl; |
| 23 import org.chromium.services.service_manager.InterfaceRegistry; | 25 import org.chromium.services.service_manager.InterfaceRegistry; |
| 24 import org.chromium.shape_detection.mojom.FaceDetectionProvider; | 26 import org.chromium.shape_detection.mojom.FaceDetectionProvider; |
| 25 | 27 |
| 26 @JNINamespace("content") | 28 @JNINamespace("content") |
| 27 class InterfaceRegistrarImpl { | 29 class InterfaceRegistrarImpl { |
| 28 | 30 |
| 29 private static boolean sHasRegisteredRegistrars; | 31 private static boolean sHasRegisteredRegistrars; |
| 30 | 32 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 55 CoreImpl.getInstance().acquireNativeHandle(nativeHandle).toMessa
gePipeHandle()); | 57 CoreImpl.getInstance().acquireNativeHandle(nativeHandle).toMessa
gePipeHandle()); |
| 56 InterfaceRegistrar.Registry.applyRenderFrameHostRegistrars(registry, ren
derFrameHost); | 58 InterfaceRegistrar.Registry.applyRenderFrameHostRegistrars(registry, ren
derFrameHost); |
| 57 } | 59 } |
| 58 | 60 |
| 59 private static void ensureContentRegistrarsAreRegistered() { | 61 private static void ensureContentRegistrarsAreRegistered() { |
| 60 if (sHasRegisteredRegistrars) return; | 62 if (sHasRegisteredRegistrars) return; |
| 61 sHasRegisteredRegistrars = true; | 63 sHasRegisteredRegistrars = true; |
| 62 InterfaceRegistrar.Registry.addContextRegistrar(new ContentContextInterf
aceRegistrar()); | 64 InterfaceRegistrar.Registry.addContextRegistrar(new ContentContextInterf
aceRegistrar()); |
| 63 InterfaceRegistrar.Registry.addWebContentsRegistrar( | 65 InterfaceRegistrar.Registry.addWebContentsRegistrar( |
| 64 new ContentWebContentsInterfaceRegistrar()); | 66 new ContentWebContentsInterfaceRegistrar()); |
| 67 InterfaceRegistrar.Registry.addRenderFrameHostRegistrar( |
| 68 new ContentRenderFrameHostInterfaceRegistrar()); |
| 65 } | 69 } |
| 66 | 70 |
| 67 private static class ContentContextInterfaceRegistrar implements InterfaceRe
gistrar<Context> { | 71 private static class ContentContextInterfaceRegistrar implements InterfaceRe
gistrar<Context> { |
| 68 @Override | 72 @Override |
| 69 public void registerInterfaces( | 73 public void registerInterfaces( |
| 70 InterfaceRegistry registry, final Context applicationContext) { | 74 InterfaceRegistry registry, final Context applicationContext) { |
| 71 registry.addInterface( | 75 registry.addInterface( |
| 72 VibrationManager.MANAGER, new VibrationManagerImpl.Factory(a
pplicationContext)); | 76 VibrationManager.MANAGER, new VibrationManagerImpl.Factory(a
pplicationContext)); |
| 73 registry.addInterface( | 77 registry.addInterface( |
| 74 BatteryMonitor.MANAGER, new BatteryMonitorFactory(applicatio
nContext)); | 78 BatteryMonitor.MANAGER, new BatteryMonitorFactory(applicatio
nContext)); |
| 75 registry.addInterface(FaceDetectionProvider.MANAGER, | 79 registry.addInterface(FaceDetectionProvider.MANAGER, |
| 76 new FaceDetectionProviderImpl.Factory(applicationContext)); | 80 new FaceDetectionProviderImpl.Factory(applicationContext)); |
| 77 registry.addInterface(AndroidOverlayProvider.MANAGER, | 81 registry.addInterface(AndroidOverlayProvider.MANAGER, |
| 78 new AndroidOverlayProviderImpl.Factory(applicationContext)); | 82 new AndroidOverlayProviderImpl.Factory(applicationContext)); |
| 79 // TODO(avayvod): Register the PresentationService implementation he
re. | 83 // TODO(avayvod): Register the PresentationService implementation he
re. |
| 80 } | 84 } |
| 81 } | 85 } |
| 82 | 86 |
| 83 private static class ContentWebContentsInterfaceRegistrar | 87 private static class ContentWebContentsInterfaceRegistrar |
| 84 implements InterfaceRegistrar<WebContents> { | 88 implements InterfaceRegistrar<WebContents> { |
| 85 @Override | 89 @Override |
| 86 public void registerInterfaces(InterfaceRegistry registry, final WebCont
ents webContents) { | 90 public void registerInterfaces(InterfaceRegistry registry, final WebCont
ents webContents) { |
| 87 registry.addInterface(Nfc.MANAGER, new NfcFactory(webContents)); | 91 registry.addInterface(Nfc.MANAGER, new NfcFactory(webContents)); |
| 88 } | 92 } |
| 89 } | 93 } |
| 94 |
| 95 private static class ContentRenderFrameHostInterfaceRegistrar |
| 96 implements InterfaceRegistrar<RenderFrameHost> { |
| 97 @Override |
| 98 public void registerInterfaces( |
| 99 InterfaceRegistry registry, final RenderFrameHost renderFrameHos
t) { |
| 100 registry.addInterface( |
| 101 InstalledAppProvider.MANAGER, new InstalledAppProviderFactor
y(renderFrameHost)); |
| 102 } |
| 103 } |
| 90 } | 104 } |
| OLD | NEW |