| 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; | |
| 13 import org.chromium.content.browser.shapedetection.FaceDetectionProviderImpl; | 12 import org.chromium.content.browser.shapedetection.FaceDetectionProviderImpl; |
| 14 import org.chromium.content_public.browser.InterfaceRegistrar; | 13 import org.chromium.content_public.browser.InterfaceRegistrar; |
| 15 import org.chromium.content_public.browser.RenderFrameHost; | 14 import org.chromium.content_public.browser.RenderFrameHost; |
| 16 import org.chromium.content_public.browser.WebContents; | 15 import org.chromium.content_public.browser.WebContents; |
| 17 import org.chromium.device.BatteryMonitor; | 16 import org.chromium.device.BatteryMonitor; |
| 18 import org.chromium.device.battery.BatteryMonitorFactory; | 17 import org.chromium.device.battery.BatteryMonitorFactory; |
| 19 import org.chromium.device.mojom.VibrationManager; | 18 import org.chromium.device.mojom.VibrationManager; |
| 20 import org.chromium.device.nfc.mojom.Nfc; | 19 import org.chromium.device.nfc.mojom.Nfc; |
| 21 import org.chromium.device.vibration.VibrationManagerImpl; | 20 import org.chromium.device.vibration.VibrationManagerImpl; |
| 22 import org.chromium.installedapp.mojom.InstalledAppProvider; | |
| 23 import org.chromium.media.mojom.AndroidOverlayProvider; | 21 import org.chromium.media.mojom.AndroidOverlayProvider; |
| 24 import org.chromium.mojo.system.impl.CoreImpl; | 22 import org.chromium.mojo.system.impl.CoreImpl; |
| 25 import org.chromium.services.service_manager.InterfaceRegistry; | 23 import org.chromium.services.service_manager.InterfaceRegistry; |
| 26 import org.chromium.shape_detection.mojom.FaceDetectionProvider; | 24 import org.chromium.shape_detection.mojom.FaceDetectionProvider; |
| 27 | 25 |
| 28 @JNINamespace("content") | 26 @JNINamespace("content") |
| 29 class InterfaceRegistrarImpl { | 27 class InterfaceRegistrarImpl { |
| 30 | 28 |
| 31 private static boolean sHasRegisteredRegistrars; | 29 private static boolean sHasRegisteredRegistrars; |
| 32 | 30 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 57 CoreImpl.getInstance().acquireNativeHandle(nativeHandle).toMessa
gePipeHandle()); | 55 CoreImpl.getInstance().acquireNativeHandle(nativeHandle).toMessa
gePipeHandle()); |
| 58 InterfaceRegistrar.Registry.applyRenderFrameHostRegistrars(registry, ren
derFrameHost); | 56 InterfaceRegistrar.Registry.applyRenderFrameHostRegistrars(registry, ren
derFrameHost); |
| 59 } | 57 } |
| 60 | 58 |
| 61 private static void ensureContentRegistrarsAreRegistered() { | 59 private static void ensureContentRegistrarsAreRegistered() { |
| 62 if (sHasRegisteredRegistrars) return; | 60 if (sHasRegisteredRegistrars) return; |
| 63 sHasRegisteredRegistrars = true; | 61 sHasRegisteredRegistrars = true; |
| 64 InterfaceRegistrar.Registry.addContextRegistrar(new ContentContextInterf
aceRegistrar()); | 62 InterfaceRegistrar.Registry.addContextRegistrar(new ContentContextInterf
aceRegistrar()); |
| 65 InterfaceRegistrar.Registry.addWebContentsRegistrar( | 63 InterfaceRegistrar.Registry.addWebContentsRegistrar( |
| 66 new ContentWebContentsInterfaceRegistrar()); | 64 new ContentWebContentsInterfaceRegistrar()); |
| 67 InterfaceRegistrar.Registry.addRenderFrameHostRegistrar( | |
| 68 new ContentRenderFrameHostInterfaceRegistrar()); | |
| 69 } | 65 } |
| 70 | 66 |
| 71 private static class ContentContextInterfaceRegistrar implements InterfaceRe
gistrar<Context> { | 67 private static class ContentContextInterfaceRegistrar implements InterfaceRe
gistrar<Context> { |
| 72 @Override | 68 @Override |
| 73 public void registerInterfaces( | 69 public void registerInterfaces( |
| 74 InterfaceRegistry registry, final Context applicationContext) { | 70 InterfaceRegistry registry, final Context applicationContext) { |
| 75 registry.addInterface( | 71 registry.addInterface( |
| 76 VibrationManager.MANAGER, new VibrationManagerImpl.Factory(a
pplicationContext)); | 72 VibrationManager.MANAGER, new VibrationManagerImpl.Factory(a
pplicationContext)); |
| 77 registry.addInterface( | 73 registry.addInterface( |
| 78 BatteryMonitor.MANAGER, new BatteryMonitorFactory(applicatio
nContext)); | 74 BatteryMonitor.MANAGER, new BatteryMonitorFactory(applicatio
nContext)); |
| 79 registry.addInterface(FaceDetectionProvider.MANAGER, | 75 registry.addInterface(FaceDetectionProvider.MANAGER, |
| 80 new FaceDetectionProviderImpl.Factory(applicationContext)); | 76 new FaceDetectionProviderImpl.Factory(applicationContext)); |
| 81 registry.addInterface(AndroidOverlayProvider.MANAGER, | 77 registry.addInterface(AndroidOverlayProvider.MANAGER, |
| 82 new AndroidOverlayProviderImpl.Factory(applicationContext)); | 78 new AndroidOverlayProviderImpl.Factory(applicationContext)); |
| 83 // TODO(avayvod): Register the PresentationService implementation he
re. | 79 // TODO(avayvod): Register the PresentationService implementation he
re. |
| 84 } | 80 } |
| 85 } | 81 } |
| 86 | 82 |
| 87 private static class ContentWebContentsInterfaceRegistrar | 83 private static class ContentWebContentsInterfaceRegistrar |
| 88 implements InterfaceRegistrar<WebContents> { | 84 implements InterfaceRegistrar<WebContents> { |
| 89 @Override | 85 @Override |
| 90 public void registerInterfaces(InterfaceRegistry registry, final WebCont
ents webContents) { | 86 public void registerInterfaces(InterfaceRegistry registry, final WebCont
ents webContents) { |
| 91 registry.addInterface(Nfc.MANAGER, new NfcFactory(webContents)); | 87 registry.addInterface(Nfc.MANAGER, new NfcFactory(webContents)); |
| 92 } | 88 } |
| 93 } | 89 } |
| 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 } | |
| 104 } | 90 } |
| OLD | NEW |