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.shapedetection.FaceDetectionProviderImpl; | 11 import org.chromium.content.browser.shapedetection.FaceDetectionProviderImpl; |
12 import org.chromium.content_public.browser.InterfaceRegistrar; | 12 import org.chromium.content_public.browser.InterfaceRegistrar; |
| 13 import org.chromium.content_public.browser.RenderFrameHost; |
13 import org.chromium.content_public.browser.WebContents; | 14 import org.chromium.content_public.browser.WebContents; |
14 import org.chromium.device.BatteryMonitor; | 15 import org.chromium.device.BatteryMonitor; |
15 import org.chromium.device.battery.BatteryMonitorFactory; | 16 import org.chromium.device.battery.BatteryMonitorFactory; |
16 import org.chromium.device.mojom.VibrationManager; | 17 import org.chromium.device.mojom.VibrationManager; |
17 import org.chromium.device.nfc.mojom.Nfc; | 18 import org.chromium.device.nfc.mojom.Nfc; |
18 import org.chromium.device.vibration.VibrationManagerImpl; | 19 import org.chromium.device.vibration.VibrationManagerImpl; |
19 import org.chromium.mojo.system.impl.CoreImpl; | 20 import org.chromium.mojo.system.impl.CoreImpl; |
20 import org.chromium.services.service_manager.InterfaceRegistry; | 21 import org.chromium.services.service_manager.InterfaceRegistry; |
21 import org.chromium.shape_detection.mojom.FaceDetectionProvider; | 22 import org.chromium.shape_detection.mojom.FaceDetectionProvider; |
22 | 23 |
(...skipping 13 matching lines...) Expand all Loading... |
36 | 37 |
37 @CalledByNative | 38 @CalledByNative |
38 static void createInterfaceRegistryForWebContents(int nativeHandle, WebConte
nts webContents) { | 39 static void createInterfaceRegistryForWebContents(int nativeHandle, WebConte
nts webContents) { |
39 ensureContentRegistrarsAreRegistered(); | 40 ensureContentRegistrarsAreRegistered(); |
40 | 41 |
41 InterfaceRegistry registry = InterfaceRegistry.create( | 42 InterfaceRegistry registry = InterfaceRegistry.create( |
42 CoreImpl.getInstance().acquireNativeHandle(nativeHandle).toMessa
gePipeHandle()); | 43 CoreImpl.getInstance().acquireNativeHandle(nativeHandle).toMessa
gePipeHandle()); |
43 InterfaceRegistrar.Registry.applyWebContentsRegistrars(registry, webCont
ents); | 44 InterfaceRegistrar.Registry.applyWebContentsRegistrars(registry, webCont
ents); |
44 } | 45 } |
45 | 46 |
| 47 @CalledByNative |
| 48 static void createInterfaceRegistryForRenderFrameHost( |
| 49 int nativeHandle, RenderFrameHost renderFrameHost) { |
| 50 ensureContentRegistrarsAreRegistered(); |
| 51 |
| 52 InterfaceRegistry registry = InterfaceRegistry.create( |
| 53 CoreImpl.getInstance().acquireNativeHandle(nativeHandle).toMessa
gePipeHandle()); |
| 54 InterfaceRegistrar.Registry.applyRenderFrameHostRegistrars(registry, ren
derFrameHost); |
| 55 } |
| 56 |
46 private static void ensureContentRegistrarsAreRegistered() { | 57 private static void ensureContentRegistrarsAreRegistered() { |
47 if (sHasRegisteredRegistrars) return; | 58 if (sHasRegisteredRegistrars) return; |
48 sHasRegisteredRegistrars = true; | 59 sHasRegisteredRegistrars = true; |
49 InterfaceRegistrar.Registry.addContextRegistrar(new ContentContextInterf
aceRegistrar()); | 60 InterfaceRegistrar.Registry.addContextRegistrar(new ContentContextInterf
aceRegistrar()); |
50 InterfaceRegistrar.Registry.addWebContentsRegistrar( | 61 InterfaceRegistrar.Registry.addWebContentsRegistrar( |
51 new ContentWebContentsInterfaceRegistrar()); | 62 new ContentWebContentsInterfaceRegistrar()); |
52 } | 63 } |
53 | 64 |
54 private static class ContentContextInterfaceRegistrar implements InterfaceRe
gistrar<Context> { | 65 private static class ContentContextInterfaceRegistrar implements InterfaceRe
gistrar<Context> { |
55 @Override | 66 @Override |
(...skipping 10 matching lines...) Expand all Loading... |
66 } | 77 } |
67 | 78 |
68 private static class ContentWebContentsInterfaceRegistrar | 79 private static class ContentWebContentsInterfaceRegistrar |
69 implements InterfaceRegistrar<WebContents> { | 80 implements InterfaceRegistrar<WebContents> { |
70 @Override | 81 @Override |
71 public void registerInterfaces(InterfaceRegistry registry, final WebCont
ents webContents) { | 82 public void registerInterfaces(InterfaceRegistry registry, final WebCont
ents webContents) { |
72 registry.addInterface(Nfc.MANAGER, new NfcFactory(webContents)); | 83 registry.addInterface(Nfc.MANAGER, new NfcFactory(webContents)); |
73 } | 84 } |
74 } | 85 } |
75 } | 86 } |
OLD | NEW |