OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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.ServiceRegistry.ImplementationFactory; | 11 import org.chromium.content.browser.ServiceRegistry.ImplementationFactory; |
| 12 import org.chromium.content.browser.installedapp.InstalledAppProviderImpl; |
12 import org.chromium.device.battery.BatteryMonitorFactory; | 13 import org.chromium.device.battery.BatteryMonitorFactory; |
13 import org.chromium.device.vibration.VibrationManagerImpl; | 14 import org.chromium.device.vibration.VibrationManagerImpl; |
| 15 import org.chromium.mojom.content.InstalledAppProvider; |
14 import org.chromium.mojom.device.BatteryMonitor; | 16 import org.chromium.mojom.device.BatteryMonitor; |
15 import org.chromium.mojom.device.VibrationManager; | 17 import org.chromium.mojom.device.VibrationManager; |
16 | 18 |
17 /** | 19 /** |
18 * Registers mojo services exposed by the browser in the given registry. | 20 * Registers mojo services exposed by the browser in the given registry. |
19 */ | 21 */ |
20 @JNINamespace("content") | 22 @JNINamespace("content") |
21 class ServiceRegistrar { | 23 class ServiceRegistrar { |
22 // BatteryMonitorFactory can't implement ImplementationFactory itself, as we
don't depend on | 24 // BatteryMonitorFactory can't implement ImplementationFactory itself, as we
don't depend on |
23 // /content in /device. Hence we use BatteryMonitorImplementationFactory as
a wrapper. | 25 // /content in /device. Hence we use BatteryMonitorImplementationFactory as
a wrapper. |
(...skipping 18 matching lines...) Expand all Loading... |
42 VibrationManagerImplementationFactory(Context applicationContext) { | 44 VibrationManagerImplementationFactory(Context applicationContext) { |
43 mApplicationContext = applicationContext; | 45 mApplicationContext = applicationContext; |
44 } | 46 } |
45 | 47 |
46 @Override | 48 @Override |
47 public VibrationManager createImpl() { | 49 public VibrationManager createImpl() { |
48 return new VibrationManagerImpl(mApplicationContext); | 50 return new VibrationManagerImpl(mApplicationContext); |
49 } | 51 } |
50 } | 52 } |
51 | 53 |
| 54 private static class InstalledAppProviderFactory |
| 55 implements ImplementationFactory<InstalledAppProvider> { |
| 56 private final Context mApplicationContext; |
| 57 |
| 58 InstalledAppProviderFactory(Context applicationContext) { |
| 59 mApplicationContext = applicationContext; |
| 60 } |
| 61 |
| 62 @Override |
| 63 public InstalledAppProvider createImpl() { |
| 64 return new InstalledAppProviderImpl(mApplicationContext); |
| 65 } |
| 66 } |
| 67 |
52 @CalledByNative | 68 @CalledByNative |
53 static void registerProcessHostServices(ServiceRegistry registry, Context ap
plicationContext) { | 69 static void registerProcessHostServices(ServiceRegistry registry, Context ap
plicationContext) { |
54 assert applicationContext != null; | 70 assert applicationContext != null; |
55 registry.addService(BatteryMonitor.MANAGER, | 71 registry.addService(BatteryMonitor.MANAGER, |
56 new BatteryMonitorImplementationFactory(applicationContext)); | 72 new BatteryMonitorImplementationFactory(applicationContext)); |
57 registry.addService(VibrationManager.MANAGER, | 73 registry.addService(VibrationManager.MANAGER, |
58 new VibrationManagerImplementationFactory(applicationContext)); | 74 new VibrationManagerImplementationFactory(applicationContext)); |
| 75 registry.addService( |
| 76 InstalledAppProvider.MANAGER, new InstalledAppProviderFactory(ap
plicationContext)); |
59 } | 77 } |
60 | 78 |
61 @CalledByNative | 79 @CalledByNative |
62 static void registerFrameHostServices(ServiceRegistry registry, Context appl
icationContext) { | 80 static void registerFrameHostServices(ServiceRegistry registry, Context appl
icationContext) { |
63 assert applicationContext != null; | 81 assert applicationContext != null; |
64 // TODO(avayvod): Register the PresentationService implementation here. | 82 // TODO(avayvod): Register the PresentationService implementation here. |
65 } | 83 } |
66 } | 84 } |
OLD | NEW |