Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Side by Side Diff: services/device/android/java/src/org/chromium/services/device/InterfaceRegistrar.java

Issue 2847523002: Android: Remove GetApplicationContext part 4 (Closed)
Patch Set: Rebase and fix build Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.services.device; 5 package org.chromium.services.device;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 8
9 import org.chromium.base.ContextUtils;
9 import org.chromium.base.annotations.CalledByNative; 10 import org.chromium.base.annotations.CalledByNative;
10 import org.chromium.base.annotations.JNINamespace; 11 import org.chromium.base.annotations.JNINamespace;
11 import org.chromium.device.battery.BatteryMonitorFactory; 12 import org.chromium.device.battery.BatteryMonitorFactory;
12 import org.chromium.device.mojom.BatteryMonitor; 13 import org.chromium.device.mojom.BatteryMonitor;
13 import org.chromium.device.mojom.VibrationManager; 14 import org.chromium.device.mojom.VibrationManager;
14 import org.chromium.device.nfc.NfcDelegate; 15 import org.chromium.device.nfc.NfcDelegate;
15 import org.chromium.device.nfc.NfcProviderImpl; 16 import org.chromium.device.nfc.NfcProviderImpl;
16 import org.chromium.device.nfc.mojom.NfcProvider; 17 import org.chromium.device.nfc.mojom.NfcProvider;
17 import org.chromium.device.vibration.VibrationManagerImpl; 18 import org.chromium.device.vibration.VibrationManagerImpl;
18 import org.chromium.mojo.system.impl.CoreImpl; 19 import org.chromium.mojo.system.impl.CoreImpl;
19 import org.chromium.services.service_manager.InterfaceRegistry; 20 import org.chromium.services.service_manager.InterfaceRegistry;
20 21
21 @JNINamespace("device") 22 @JNINamespace("device")
22 class InterfaceRegistrar { 23 class InterfaceRegistrar {
23 @CalledByNative 24 @CalledByNative
24 static void createInterfaceRegistryForContext( 25 static void createInterfaceRegistryForContext(
25 int nativeHandle, Context applicationContext, NfcDelegate nfcDelegat e) { 26 int nativeHandle, NfcDelegate nfcDelegate) {
26 // Note: The bindings code manages the lifetime of this object, so it 27 // Note: The bindings code manages the lifetime of this object, so it
27 // is not necessary to hold on to a reference to it explicitly. 28 // is not necessary to hold on to a reference to it explicitly.
29 // TODO(wnwen): Move calls to ContextUtils down to the individual factor ies.
30 Context applicationContext = ContextUtils.getApplicationContext();
28 InterfaceRegistry registry = InterfaceRegistry.create( 31 InterfaceRegistry registry = InterfaceRegistry.create(
29 CoreImpl.getInstance().acquireNativeHandle(nativeHandle).toMessa gePipeHandle()); 32 CoreImpl.getInstance().acquireNativeHandle(nativeHandle).toMessa gePipeHandle());
30 registry.addInterface( 33 registry.addInterface(
31 BatteryMonitor.MANAGER, new BatteryMonitorFactory(applicationCon text)); 34 BatteryMonitor.MANAGER, new BatteryMonitorFactory(applicationCon text));
32 registry.addInterface( 35 registry.addInterface(
33 NfcProvider.MANAGER, new NfcProviderImpl.Factory(applicationCont ext, nfcDelegate)); 36 NfcProvider.MANAGER, new NfcProviderImpl.Factory(applicationCont ext, nfcDelegate));
34 registry.addInterface( 37 registry.addInterface(
35 VibrationManager.MANAGER, new VibrationManagerImpl.Factory(appli cationContext)); 38 VibrationManager.MANAGER, new VibrationManagerImpl.Factory(appli cationContext));
36 } 39 }
37 } 40 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698