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.chrome.browser.mojo; | 5 package org.chromium.chrome.browser.mojo; |
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.chrome.browser.payments.PaymentRequestFactory; | 10 import org.chromium.chrome.browser.payments.PaymentRequestFactory; |
11 import org.chromium.chrome.browser.shapedetection.BarcodeDetectionImpl; | 11 import org.chromium.chrome.browser.shapedetection.BarcodeDetectionImpl; |
12 import org.chromium.chrome.browser.shapedetection.TextDetectionImpl; | 12 import org.chromium.chrome.browser.shapedetection.TextDetectionImpl; |
13 import org.chromium.chrome.browser.webshare.ShareServiceImplementationFactory; | 13 import org.chromium.chrome.browser.webshare.ShareServiceImplementationFactory; |
14 import org.chromium.content_public.browser.InterfaceRegistrar; | 14 import org.chromium.content_public.browser.InterfaceRegistrar; |
| 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.payments.mojom.PaymentRequest; | 17 import org.chromium.payments.mojom.PaymentRequest; |
17 import org.chromium.services.service_manager.InterfaceRegistry; | 18 import org.chromium.services.service_manager.InterfaceRegistry; |
18 import org.chromium.shape_detection.mojom.BarcodeDetection; | 19 import org.chromium.shape_detection.mojom.BarcodeDetection; |
19 import org.chromium.shape_detection.mojom.TextDetection; | 20 import org.chromium.shape_detection.mojom.TextDetection; |
20 import org.chromium.webshare.mojom.ShareService; | 21 import org.chromium.webshare.mojom.ShareService; |
21 | 22 |
22 @SuppressWarnings("MultipleTopLevelClassesInFile") | 23 @SuppressWarnings("MultipleTopLevelClassesInFile") |
23 | 24 |
24 /** Registers mojo interface implementations exposed to C++ code at the Chrome l
ayer. */ | 25 /** Registers mojo interface implementations exposed to C++ code at the Chrome l
ayer. */ |
25 class ChromeInterfaceRegistrar { | 26 class ChromeInterfaceRegistrar { |
26 @CalledByNative | 27 @CalledByNative |
27 private static void registerMojoInterfaces() { | 28 private static void registerMojoInterfaces() { |
28 InterfaceRegistrar.Registry.addContextRegistrar(new ChromeContextInterfa
ceRegistrar()); | 29 InterfaceRegistrar.Registry.addContextRegistrar(new ChromeContextInterfa
ceRegistrar()); |
29 InterfaceRegistrar.Registry.addWebContentsRegistrar( | 30 InterfaceRegistrar.Registry.addWebContentsRegistrar( |
30 new ChromeWebContentsInterfaceRegistrar()); | 31 new ChromeWebContentsInterfaceRegistrar()); |
| 32 InterfaceRegistrar.Registry.addRenderFrameHostRegistrar( |
| 33 new ChromeRenderFrameHostInterfaceRegistrar()); |
31 } | 34 } |
32 | 35 |
33 private static class ChromeContextInterfaceRegistrar implements InterfaceReg
istrar<Context> { | 36 private static class ChromeContextInterfaceRegistrar implements InterfaceReg
istrar<Context> { |
34 @Override | 37 @Override |
35 public void registerInterfaces( | 38 public void registerInterfaces( |
36 InterfaceRegistry registry, final Context applicationContext) { | 39 InterfaceRegistry registry, final Context applicationContext) { |
37 registry.addInterface( | 40 registry.addInterface( |
38 BarcodeDetection.MANAGER, new BarcodeDetectionImpl.Factory(a
pplicationContext)); | 41 BarcodeDetection.MANAGER, new BarcodeDetectionImpl.Factory(a
pplicationContext)); |
39 registry.addInterface( | 42 registry.addInterface( |
40 TextDetection.MANAGER, new TextDetectionImpl.Factory(applica
tionContext)); | 43 TextDetection.MANAGER, new TextDetectionImpl.Factory(applica
tionContext)); |
41 } | 44 } |
42 } | 45 } |
43 | 46 |
44 private static class ChromeWebContentsInterfaceRegistrar | 47 private static class ChromeWebContentsInterfaceRegistrar |
45 implements InterfaceRegistrar<WebContents> { | 48 implements InterfaceRegistrar<WebContents> { |
46 @Override | 49 @Override |
47 public void registerInterfaces(InterfaceRegistry registry, final WebCont
ents webContents) { | 50 public void registerInterfaces(InterfaceRegistry registry, final WebCont
ents webContents) { |
48 registry.addInterface(PaymentRequest.MANAGER, new PaymentRequestFact
ory(webContents)); | |
49 registry.addInterface( | 51 registry.addInterface( |
50 ShareService.MANAGER, new ShareServiceImplementationFactory(
webContents)); | 52 ShareService.MANAGER, new ShareServiceImplementationFactory(
webContents)); |
51 } | 53 } |
52 } | 54 } |
| 55 |
| 56 private static class ChromeRenderFrameHostInterfaceRegistrar |
| 57 implements InterfaceRegistrar<RenderFrameHost> { |
| 58 @Override |
| 59 public void registerInterfaces( |
| 60 InterfaceRegistry registry, final RenderFrameHost renderFrameHos
t) { |
| 61 registry.addInterface( |
| 62 PaymentRequest.MANAGER, new PaymentRequestFactory(renderFram
eHost)); |
| 63 } |
| 64 } |
53 } | 65 } |
OLD | NEW |