| OLD | NEW |
| 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; |
| 12 import org.chromium.chrome.R; | 13 import org.chromium.chrome.R; |
| 13 import org.chromium.chrome.browser.ContentSettingsType; | 14 import org.chromium.chrome.browser.ContentSettingsType; |
| 14 import org.chromium.chrome.browser.preferences.LocationSettings; | 15 import org.chromium.chrome.browser.preferences.LocationSettings; |
| 15 import org.chromium.chrome.browser.preferences.PrefServiceBridge; | 16 import org.chromium.chrome.browser.preferences.PrefServiceBridge; |
| 17 import org.chromium.components.location.LocationUtils; |
| 16 | 18 |
| 17 /** | 19 /** |
| 18 * A class for dealing with the Geolocation category. | 20 * A class for dealing with the Geolocation category. |
| 19 */ | 21 */ |
| 20 public class LocationCategory extends SiteSettingsCategory { | 22 public class LocationCategory extends SiteSettingsCategory { |
| 21 public LocationCategory() { | 23 public LocationCategory() { |
| 22 super(SiteSettingsCategory.CATEGORY_DEVICE_LOCATION, | 24 super(SiteSettingsCategory.CATEGORY_DEVICE_LOCATION, |
| 23 android.Manifest.permission.ACCESS_COARSE_LOCATION, | 25 android.Manifest.permission.ACCESS_COARSE_LOCATION, |
| 24 ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION); | 26 ContentSettingsType.CONTENT_SETTINGS_TYPE_GEOLOCATION); |
| 25 } | 27 } |
| 26 | 28 |
| 27 @Override | 29 @Override |
| 28 protected boolean enabledGlobally() { | 30 protected boolean enabledGlobally() { |
| 29 return LocationSettings.getInstance().isSystemLocationSettingEnabled(); | 31 return LocationUtils.getInstance().isSystemLocationSettingEnabled( |
| 32 ContextUtils.getApplicationContext()); |
| 30 } | 33 } |
| 31 | 34 |
| 32 @Override | 35 @Override |
| 33 public boolean showPermissionBlockedMessage(Context context) { | 36 public boolean showPermissionBlockedMessage(Context context) { |
| 34 if (enabledForChrome(context) && enabledGlobally()) { | 37 if (enabledForChrome(context) && enabledGlobally()) { |
| 35 return false; | 38 return false; |
| 36 } | 39 } |
| 37 | 40 |
| 38 // The only time we don't want to show location as blocked in system is
when Chrome also | 41 // The only time we don't want to show location as blocked in system is
when Chrome also |
| 39 // blocks Location by policy (because then turning it on in the system i
sn't going to | 42 // blocks Location by policy (because then turning it on in the system i
sn't going to |
| 40 // turn on location in Chrome). | 43 // turn on location in Chrome). |
| 41 PrefServiceBridge prefs = PrefServiceBridge.getInstance(); | 44 PrefServiceBridge prefs = PrefServiceBridge.getInstance(); |
| 42 if (!LocationSettings.getInstance().isChromeLocationSettingEnabled() | 45 if (!LocationSettings.getInstance().isChromeLocationSettingEnabled() |
| 43 && !prefs.isAllowLocationUserModifiable()) { | 46 && !prefs.isAllowLocationUserModifiable()) { |
| 44 return false; | 47 return false; |
| 45 } | 48 } |
| 46 | 49 |
| 47 return true; | 50 return true; |
| 48 } | 51 } |
| 49 | 52 |
| 50 @Override | 53 @Override |
| 51 protected Intent getIntentToEnableOsGlobalPermission(Context context) { | 54 protected Intent getIntentToEnableOsGlobalPermission(Context context) { |
| 52 if (enabledGlobally()) return null; | 55 if (enabledGlobally()) return null; |
| 53 return LocationSettings.getInstance().getSystemLocationSettingsIntent(); | 56 return LocationUtils.getInstance().getSystemLocationSettingsIntent(); |
| 54 } | 57 } |
| 55 | 58 |
| 56 @Override | 59 @Override |
| 57 protected String getMessageForEnablingOsGlobalPermission(Activity activity)
{ | 60 protected String getMessageForEnablingOsGlobalPermission(Activity activity)
{ |
| 58 Resources resources = activity.getResources(); | 61 Resources resources = activity.getResources(); |
| 59 if (enabledForChrome(activity)) { | 62 if (enabledForChrome(activity)) { |
| 60 return resources.getString(R.string.android_location_off_globally); | 63 return resources.getString(R.string.android_location_off_globally); |
| 61 } | 64 } |
| 62 return resources.getString(R.string.android_location_also_off_globally); | 65 return resources.getString(R.string.android_location_also_off_globally); |
| 63 } | 66 } |
| 64 } | 67 } |
| OLD | NEW |