Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/omnibox/geo/GeolocationTracker.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/geo/GeolocationTracker.java b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/geo/GeolocationTracker.java |
| index 076fb175b6aec14e391a2c45f888e0f9f8e875f1..19396e00746aab5a9cbacdc539001c62c898789e 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/geo/GeolocationTracker.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/geo/GeolocationTracker.java |
| @@ -31,6 +31,8 @@ class GeolocationTracker { |
| private static Location sNetworkLocationForTesting; |
| private static Location sGpsLocationForTesting; |
| private static boolean sUseLocationForTesting; |
| + private static long sLocationAgeForTesting; |
| + private static boolean sUseLocationAgeForTesting; |
| private static class SelfCancelingListener implements LocationListener { |
| @@ -78,6 +80,7 @@ class GeolocationTracker { |
| * created. If the apparent age is negative, Long.MAX_VALUE will be returned. |
| */ |
| static long getLocationAge(Location location) { |
| + if (sUseLocationAgeForTesting) return sLocationAgeForTesting; |
|
Ted C
2017/05/18 14:43:03
same comment as the other cl where I think we can
lbargu
2017/05/18 15:14:09
Not sure it would work since age is using "current
|
| long age = System.currentTimeMillis() - location.getTime(); |
| return age >= 0 ? age : Long.MAX_VALUE; |
| } |
| @@ -152,6 +155,16 @@ class GeolocationTracker { |
| sUseLocationForTesting = true; |
| } |
| + @VisibleForTesting |
| + static void setLocationAgeForTesting(Long locationAgeForTesting) { |
| + if (locationAgeForTesting == null) { |
| + sUseLocationAgeForTesting = false; |
| + return; |
| + } |
| + sLocationAgeForTesting = locationAgeForTesting; |
| + sUseLocationAgeForTesting = true; |
| + } |
| + |
| private static boolean hasPermission(Context context, String permission) { |
| return ApiCompatibilityUtils.checkPermission( |
| context, permission, Process.myPid(), Process.myUid()) |