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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/website/LocationCategory.java

Issue 2105573002: Revert of Add a LocationUtils class to give all Chromium Android code access to location helpers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkcr
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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.chrome.browser.preferences.website; 5 package org.chromium.chrome.browser.preferences.website;
6 6
7 import android.app.Activity; 7 import android.app.Activity;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.Intent; 9 import android.content.Intent;
10 import android.content.res.Resources; 10 import android.content.res.Resources;
11 11
12 import org.chromium.base.ContextUtils;
13 import org.chromium.chrome.R; 12 import org.chromium.chrome.R;
14 import org.chromium.chrome.browser.ContentSettingsType; 13 import org.chromium.chrome.browser.ContentSettingsType;
15 import org.chromium.chrome.browser.preferences.LocationSettings; 14 import org.chromium.chrome.browser.preferences.LocationSettings;
16 import org.chromium.chrome.browser.preferences.PrefServiceBridge; 15 import org.chromium.chrome.browser.preferences.PrefServiceBridge;
17 import org.chromium.components.location.LocationUtils;
18 16
19 /** 17 /**
20 * A class for dealing with the Geolocation category. 18 * A class for dealing with the Geolocation category.
21 */ 19 */
22 public class LocationCategory extends SiteSettingsCategory { 20 public class LocationCategory extends SiteSettingsCategory {
23 public LocationCategory() { 21 public LocationCategory() {
24 super(SiteSettingsCategory.CATEGORY_DEVICE_LOCATION, 22 super(SiteSettingsCategory.CATEGORY_DEVICE_LOCATION,
25 android.Manifest.permission.ACCESS_COARSE_LOCATION, 23 android.Manifest.permission.ACCESS_COARSE_LOCATION,
26 ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION); 24 ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION);
27 } 25 }
28 26
29 @Override 27 @Override
30 protected boolean enabledGlobally() { 28 protected boolean enabledGlobally() {
31 return LocationUtils.getInstance().isSystemLocationSettingEnabled( 29 return LocationSettings.getInstance().isSystemLocationSettingEnabled();
32 ContextUtils.getApplicationContext());
33 } 30 }
34 31
35 @Override 32 @Override
36 public boolean showPermissionBlockedMessage(Context context) { 33 public boolean showPermissionBlockedMessage(Context context) {
37 if (enabledForChrome(context) && enabledGlobally()) { 34 if (enabledForChrome(context) && enabledGlobally()) {
38 return false; 35 return false;
39 } 36 }
40 37
41 // The only time we don't want to show location as blocked in system is when Chrome also 38 // The only time we don't want to show location as blocked in system is when Chrome also
42 // blocks Location by policy (because then turning it on in the system i sn't going to 39 // blocks Location by policy (because then turning it on in the system i sn't going to
43 // turn on location in Chrome). 40 // turn on location in Chrome).
44 PrefServiceBridge prefs = PrefServiceBridge.getInstance(); 41 PrefServiceBridge prefs = PrefServiceBridge.getInstance();
45 if (!LocationSettings.getInstance().isChromeLocationSettingEnabled() 42 if (!LocationSettings.getInstance().isChromeLocationSettingEnabled()
46 && !prefs.isAllowLocationUserModifiable()) { 43 && !prefs.isAllowLocationUserModifiable()) {
47 return false; 44 return false;
48 } 45 }
49 46
50 return true; 47 return true;
51 } 48 }
52 49
53 @Override 50 @Override
54 protected Intent getIntentToEnableOsGlobalPermission(Context context) { 51 protected Intent getIntentToEnableOsGlobalPermission(Context context) {
55 if (enabledGlobally()) return null; 52 if (enabledGlobally()) return null;
56 return LocationUtils.getInstance().getSystemLocationSettingsIntent(); 53 return LocationSettings.getInstance().getSystemLocationSettingsIntent();
57 } 54 }
58 55
59 @Override 56 @Override
60 protected String getMessageForEnablingOsGlobalPermission(Activity activity) { 57 protected String getMessageForEnablingOsGlobalPermission(Activity activity) {
61 Resources resources = activity.getResources(); 58 Resources resources = activity.getResources();
62 if (enabledForChrome(activity)) { 59 if (enabledForChrome(activity)) {
63 return resources.getString(R.string.android_location_off_globally); 60 return resources.getString(R.string.android_location_off_globally);
64 } 61 }
65 return resources.getString(R.string.android_location_also_off_globally); 62 return resources.getString(R.string.android_location_also_off_globally);
66 } 63 }
67 } 64 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698