OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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.shape_detection; | 5 package org.chromium.shape_detection; |
6 | 6 |
7 import android.content.Context; | 7 import org.chromium.base.ContextUtils; |
8 | |
9 import org.chromium.base.annotations.CalledByNative; | 8 import org.chromium.base.annotations.CalledByNative; |
10 import org.chromium.base.annotations.JNINamespace; | 9 import org.chromium.base.annotations.JNINamespace; |
11 import org.chromium.mojo.system.impl.CoreImpl; | 10 import org.chromium.mojo.system.impl.CoreImpl; |
12 import org.chromium.services.service_manager.InterfaceRegistry; | 11 import org.chromium.services.service_manager.InterfaceRegistry; |
13 import org.chromium.shape_detection.mojom.BarcodeDetection; | 12 import org.chromium.shape_detection.mojom.BarcodeDetection; |
14 import org.chromium.shape_detection.mojom.FaceDetectionProvider; | 13 import org.chromium.shape_detection.mojom.FaceDetectionProvider; |
15 import org.chromium.shape_detection.mojom.TextDetection; | 14 import org.chromium.shape_detection.mojom.TextDetection; |
16 | 15 |
17 @JNINamespace("shape_detection") | 16 @JNINamespace("shape_detection") |
18 class InterfaceRegistrar { | 17 class InterfaceRegistrar { |
19 @CalledByNative | 18 @CalledByNative |
20 static void createInterfaceRegistryForContext(int nativeHandle, Context appl
icationContext) { | 19 static void createInterfaceRegistryForContext(int nativeHandle) { |
21 // Note: The bindings code manages the lifetime of this object, so it | 20 // Note: The bindings code manages the lifetime of this object, so it |
22 // is not necessary to hold on to a reference to it explicitly. | 21 // is not necessary to hold on to a reference to it explicitly. |
| 22 // TODO(wnwen): Move references to getApplicationContext lower. |
23 InterfaceRegistry registry = InterfaceRegistry.create( | 23 InterfaceRegistry registry = InterfaceRegistry.create( |
24 CoreImpl.getInstance().acquireNativeHandle(nativeHandle).toMessa
gePipeHandle()); | 24 CoreImpl.getInstance().acquireNativeHandle(nativeHandle).toMessa
gePipeHandle()); |
25 registry.addInterface( | 25 registry.addInterface(BarcodeDetection.MANAGER, |
26 BarcodeDetection.MANAGER, new BarcodeDetectionImpl.Factory(appli
cationContext)); | 26 new BarcodeDetectionImpl.Factory(ContextUtils.getApplicationCont
ext())); |
27 registry.addInterface(FaceDetectionProvider.MANAGER, | 27 registry.addInterface(FaceDetectionProvider.MANAGER, |
28 new FaceDetectionProviderImpl.Factory(applicationContext)); | 28 new FaceDetectionProviderImpl.Factory(ContextUtils.getApplicatio
nContext())); |
29 registry.addInterface( | 29 registry.addInterface(TextDetection.MANAGER, |
30 TextDetection.MANAGER, new TextDetectionImpl.Factory(application
Context)); | 30 new TextDetectionImpl.Factory(ContextUtils.getApplicationContext
())); |
31 } | 31 } |
32 } | 32 } |
OLD | NEW |