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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/preferences/SearchEngineAdapter.java

Issue 1104473002: Make the Location is Allowed link take the Geo Header into account. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/preferences/SearchEngineAdapter.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/SearchEngineAdapter.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/SearchEngineAdapter.java
index a842cc2d072ae051c1cd48829be72d926ebda0aa..2150d8ee3d1fc82ec468ee7e8c80d862c9cafa51 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/SearchEngineAdapter.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/SearchEngineAdapter.java
@@ -186,7 +186,7 @@ public class SearchEngineAdapter extends BaseAdapter implements LoadListener, On
resources.getColor(R.color.pref_accent_color));
if (LocationSettings.getInstance().isSystemLocationSettingEnabled()) {
String message = mContext.getString(
- locationEnabled(position)
+ locationEnabled(position, true)
? R.string.search_engine_location_allowed
: R.string.search_engine_location_blocked);
SpannableString messageWithLink = new SpannableString(message);
@@ -229,7 +229,7 @@ public class SearchEngineAdapter extends BaseAdapter implements LoadListener, On
SharedPreferences sharedPreferences =
PreferenceManager.getDefaultSharedPreferences(mContext);
if (sharedPreferences.getBoolean(PrefServiceBridge.LOCATION_AUTO_ALLOWED, false)) {
- if (locationEnabled(mSelectedSearchEnginePosition)) {
+ if (locationEnabled(mSelectedSearchEnginePosition, false)) {
TemplateUrl templateUrl = mSearchEngines.get(mSelectedSearchEnginePosition);
String url = TemplateUrlService.getInstance().getSearchEngineUrlFromTemplateUrl(
@@ -253,12 +253,6 @@ public class SearchEngineAdapter extends BaseAdapter implements LoadListener, On
}
private void onLocationLinkClicked() {
- // This catches the case where the user has reset permissions for a site that's set as the
- // default search engine. If the user notices that Location is blocked for the current
- // search engine and clicks the link to enable then the Location record must exist
- // (otherwise it is seemingly impossible to enable after resetting a site).
- PrefServiceBridge.maybeCreatePermissionForDefaultSearchEngine(false, mContext);
-
if (!LocationSettings.getInstance().isSystemLocationSettingEnabled()) {
mContext.startActivity(
LocationSettings.getInstance().getSystemLocationSettingsIntent());
@@ -268,19 +262,25 @@ public class SearchEngineAdapter extends BaseAdapter implements LoadListener, On
String url = TemplateUrlService.getInstance().getSearchEngineUrlFromTemplateUrl(
toIndex(mSelectedSearchEnginePosition));
settingsIntent.putExtra(Preferences.EXTRA_SHOW_FRAGMENT_ARGUMENTS,
- SingleWebsitePreferences.createFragmentArgsForSite(url));
+ SingleWebsitePreferences.createFragmentArgsForSite(url,
+ locationEnabled(mSelectedSearchEnginePosition, true)
+ ? "allow" : "block"));
mContext.startActivity(settingsIntent);
}
mCallback.onDismissDialog();
}
- private boolean locationEnabled(int position) {
+ private boolean locationEnabled(int position, boolean checkGeoHeader) {
if (position == -1) return false;
String url = TemplateUrlService.getInstance().getSearchEngineUrlFromTemplateUrl(
toIndex(position));
GeolocationInfo locationSettings = new GeolocationInfo(url, null);
ContentSetting locationPermission = locationSettings.getContentSetting();
+ // Catch a corner case with the geoHeader being sent when no permission has been specified.
+ if (locationPermission == ContentSetting.ASK && checkGeoHeader) {
+ return PrefServiceBridge.sendGeoHeader(mContext, url, false);
+ }
return locationPermission == ContentSetting.ALLOW;
}
}

Powered by Google App Engine
This is Rietveld 408576698