Index: chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleWebsitePreferences.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleWebsitePreferences.java b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleWebsitePreferences.java |
index 807fb6e23162617af36407926fc5a448efdfd17d..dadde5b230a44e8b5e0943959ea2f3f33a7c9c0e 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleWebsitePreferences.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/preferences/website/SingleWebsitePreferences.java |
@@ -35,12 +35,15 @@ public class SingleWebsitePreferences extends PreferenceFragment |
implements DialogInterface.OnClickListener, OnPreferenceChangeListener, |
OnPreferenceClickListener { |
// SingleWebsitePreferences expects either EXTRA_SITE (a Website) or |
- // EXTRA_ADDRESS (a WebsiteAddress) to be present (but not both). If |
+ // EXTRA_ORIGIN (a WebsiteAddress) to be present (but not both). If |
// EXTRA_SITE is present, the fragment will display the permissions in that |
- // Website object. If EXTRA_ADDRESS is present, the fragment will find all |
- // permissions for that website address and display those. |
+ // Website object. If EXTRA_ORIGIN is present, the fragment will find all |
+ // permissions for that website address and display those. If EXTRA_LOCATION |
+ // is present, the fragment will add a Location toggle, even if the site |
+ // specifies no Location permission. |
public static final String EXTRA_SITE = "org.chromium.chrome.preferences.site"; |
public static final String EXTRA_ORIGIN = "org.chromium.chrome.preferences.origin"; |
+ public static final String EXTRA_LOCATION = "org.chromium.chrome.preferences.location"; |
// Preference keys, see single_website_preferences.xml |
// Headings: |
@@ -115,14 +118,18 @@ public class SingleWebsitePreferences extends PreferenceFragment |
* |
* @param url The URL to open the fragment with. This is a complete url including scheme, |
* domain, port, path, etc. |
+ * @param locationValueIfMissing The value to show for the Location UI (optional, can be blank). |
* @return The bundle to attach to the preferences intent. |
*/ |
- public static Bundle createFragmentArgsForSite(String url) { |
+ public static Bundle createFragmentArgsForSite(String url, String locationValueIfMissing) { |
newt (away)
2015/04/28 06:44:01
Instead of adding a new argument to this method, I
Finnur
2015/04/29 14:54:09
Oooh, I like that idea! :)
|
Bundle fragmentArgs = new Bundle(); |
// TODO(mvanouwerkerk): Define a pure getOrigin method in UrlUtilities that is the |
// equivalent of the call below, because this is perfectly fine for non-display purposes. |
String origin = UrlUtilities.getOriginForDisplay(URI.create(url), true /* schowScheme */); |
fragmentArgs.putString(SingleWebsitePreferences.EXTRA_ORIGIN, origin); |
+ if (locationValueIfMissing.length() != 0) { |
+ fragmentArgs.putString(SingleWebsitePreferences.EXTRA_LOCATION, locationValueIfMissing); |
+ } |
return fragmentArgs; |
} |
@@ -268,7 +275,15 @@ public class SingleWebsitePreferences extends PreferenceFragment |
} else if (PREF_JAVASCRIPT_PERMISSION.equals(preference.getKey())) { |
setUpListPreference(preference, mSite.getJavaScriptPermission()); |
} else if (PREF_LOCATION_ACCESS.equals(preference.getKey())) { |
- setUpListPreference(preference, mSite.getGeolocationPermission()); |
+ Object extraLocation = getArguments().getSerializable(EXTRA_LOCATION); |
+ if (mSite.getGeolocationPermission() == null && extraLocation != null) { |
+ String origin = mSite.getAddress().getOrigin(); |
+ mSite.setGeolocationInfo(new GeolocationInfo(origin, origin)); |
+ setUpListPreference(preference, extraLocation.toString().equals("allow") |
+ ? ContentSetting.ALLOW : ContentSetting.BLOCK); |
+ } else { |
+ setUpListPreference(preference, mSite.getGeolocationPermission()); |
+ } |
} else if (PREF_MIDI_SYSEX_PERMISSION.equals(preference.getKey())) { |
setUpListPreference(preference, mSite.getMidiPermission()); |
} else if (PREF_POPUP_PERMISSION.equals(preference.getKey())) { |