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

Side by Side Diff: device/geolocation/android/java/src/org/chromium/device/geolocation/LocationProviderFactory.java

Issue 2832983003: Revert of GeoLocation: add support for GmsCore location provider (Closed)
Patch Set: Created 3 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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.device.geolocation; 5 package org.chromium.device.geolocation;
6 6
7 import android.content.Context; 7 import android.content.Context;
8 8
9 import org.chromium.base.VisibleForTesting; 9 import org.chromium.base.VisibleForTesting;
10 10
11 /** 11 /**
12 * Factory to create a LocationProvider to allow us to inject a mock for tests. 12 * Factory to create a LocationProvider to allow us to inject
13 * a mock for tests.
13 */ 14 */
14 public class LocationProviderFactory { 15 public class LocationProviderFactory {
15 private static LocationProviderFactory.LocationProvider sProviderImpl; 16 private static LocationProviderFactory.LocationProvider sProviderImpl;
16 17
17 /** 18 /**
18 * LocationProviderFactory.create() returns an instance of this interface. 19 * LocationProviderFactory.create() returns an instance of this interface.
19 */ 20 */
20 public interface LocationProvider { 21 public interface LocationProvider {
21 /** 22 /**
22 * Start listening for location updates. Calling several times before st op() is interpreted 23 * Start listening for location updates.
23 * as restart. 24 * @param enableHighAccuracy Whether or not to enable high accuracy loca tion providers.
24 * @param enableHighAccuracy Whether or not to enable high accuracy loca tion.
25 */ 25 */
26 public void start(boolean enableHighAccuracy); 26 public void start(boolean enableHighAccuracy);
27 27
28 /** 28 /**
29 * Stop listening for location updates. 29 * Stop listening for location updates.
30 */ 30 */
31 public void stop(); 31 public void stop();
32 32
33 /** 33 /**
34 * Returns true if we are currently listening for location updates, fals e if not. 34 * Returns true if we are currently listening for location updates, fals e if not.
35 */ 35 */
36 public boolean isRunning(); 36 public boolean isRunning();
37 } 37 }
38 38
39 private LocationProviderFactory() {} 39 private LocationProviderFactory() {}
40 40
41 @VisibleForTesting 41 @VisibleForTesting
42 public static void setLocationProviderImpl(LocationProviderFactory.LocationP rovider provider) { 42 public static void setLocationProviderImpl(LocationProviderFactory.LocationP rovider provider) {
43 assert sProviderImpl == null;
43 sProviderImpl = provider; 44 sProviderImpl = provider;
44 } 45 }
45 46
46 public static LocationProvider create(Context context) { 47 public static LocationProvider create(Context context) {
47 if (sProviderImpl != null) return sProviderImpl; 48 if (sProviderImpl == null) {
48
49 if (LocationProviderGmsCore.isGooglePlayServicesAvailable(context)) {
50 sProviderImpl = new LocationProviderGmsCore(context);
51 } else {
52 sProviderImpl = new LocationProviderAndroid(context); 49 sProviderImpl = new LocationProviderAndroid(context);
53 } 50 }
54 return sProviderImpl; 51 return sProviderImpl;
55 } 52 }
56 } 53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698