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

Unified Diff: components/location/android/java/src/org/chromium/components/location/LocationUtils.java

Issue 2183563002: Remove Context param from LocationUtils methods (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update BT Device Fakes class Created 4 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: components/location/android/java/src/org/chromium/components/location/LocationUtils.java
diff --git a/components/location/android/java/src/org/chromium/components/location/LocationUtils.java b/components/location/android/java/src/org/chromium/components/location/LocationUtils.java
index f9e0899f53ef3ccbdfe084d70c926c7bd5f5c3b5..fd09e40a2d1cb16b1ff3b46d8305b816162765d3 100644
--- a/components/location/android/java/src/org/chromium/components/location/LocationUtils.java
+++ b/components/location/android/java/src/org/chromium/components/location/LocationUtils.java
@@ -13,6 +13,7 @@ import android.os.Process;
import android.provider.Settings;
import android.text.TextUtils;
+import org.chromium.base.ContextUtils;
import org.chromium.base.ThreadUtils;
import org.chromium.base.VisibleForTesting;
import org.chromium.base.annotations.SuppressFBWarnings;
@@ -46,7 +47,8 @@ public class LocationUtils {
return sInstance;
}
- private boolean hasPermission(Context context, String name) {
+ private boolean hasPermission(String name) {
+ Context context = ContextUtils.getApplicationContext();
return context.checkPermission(name, Process.myPid(), Process.myUid())
== PackageManager.PERMISSION_GRANTED;
}
@@ -57,16 +59,17 @@ public class LocationUtils {
* Check both hasAndroidLocationPermission() and isSystemLocationSettingEnabled() to determine
* if Chromium's location requests will return results.
*/
- public boolean hasAndroidLocationPermission(Context context) {
- return hasPermission(context, Manifest.permission.ACCESS_COARSE_LOCATION)
- || hasPermission(context, Manifest.permission.ACCESS_FINE_LOCATION);
+ public boolean hasAndroidLocationPermission() {
+ return hasPermission(Manifest.permission.ACCESS_COARSE_LOCATION)
+ || hasPermission(Manifest.permission.ACCESS_FINE_LOCATION);
}
/**
* Returns whether location services are enabled system-wide, i.e. whether any application is
* able to access location.
*/
- public boolean isSystemLocationSettingEnabled(Context context) {
+ public boolean isSystemLocationSettingEnabled() {
+ Context context = ContextUtils.getApplicationContext();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
return Settings.Secure.getInt(context.getContentResolver(),
Settings.Secure.LOCATION_MODE, Settings.Secure.LOCATION_MODE_OFF)
@@ -77,6 +80,11 @@ public class LocationUtils {
}
}
+ // TODO(cco3): Remove when no longer needed downstream.
+ public boolean isSystemLocationSettingEnabled(Context context) {
+ return isSystemLocationSettingEnabled();
+ }
+
/**
* Returns an intent to launch Android Location Settings.
*/

Powered by Google App Engine
This is Rietveld 408576698