summaryrefslogtreecommitdiffstats
path: root/chrome/browser/content_setting_bubble_model.cc
diff options
context:
space:
mode:
authorjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-07 16:55:21 +0000
committerjoth@chromium.org <joth@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-07 16:55:21 +0000
commit0d0524fea0ce2adb9aa132f90b63c7deb5410b1f (patch)
treeba4b53e201a3b31faac05c88ba23b78d562655f8 /chrome/browser/content_setting_bubble_model.cc
parent85255d75aa0836f97b088394b2ffbad310755dbf (diff)
downloadchromium_src-0d0524fea0ce2adb9aa132f90b63c7deb5410b1f.zip
chromium_src-0d0524fea0ce2adb9aa132f90b63c7deb5410b1f.tar.gz
chromium_src-0d0524fea0ce2adb9aa132f90b63c7deb5410b1f.tar.bz2
Change the Clear these settings... link to be a reload page hint message when a clear is pending.
Also adds some unit tests for the geolocation bubble, and refactors the tests a bit to make this new test neater. BUG=40263 TEST=a) unit_tests --gtest_filter=ContentSettingBubbleModelTest* b) open a page using geolocation and test different combinations of global permission & exceptions for that page. Review URL: http://codereview.chromium.org/1605016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43844 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/content_setting_bubble_model.cc')
-rw-r--r--chrome/browser/content_setting_bubble_model.cc39
1 files changed, 33 insertions, 6 deletions
diff --git a/chrome/browser/content_setting_bubble_model.cc b/chrome/browser/content_setting_bubble_model.cc
index 01d4d22..573111a 100644
--- a/chrome/browser/content_setting_bubble_model.cc
+++ b/chrome/browser/content_setting_bubble_model.cc
@@ -172,8 +172,7 @@ class ContentSettingDomainListBubbleModel
: ContentSettingTitleAndLinkModel(tab_contents, profile, content_type) {
DCHECK_EQ(CONTENT_SETTINGS_TYPE_GEOLOCATION, content_type) <<
"SetDomains currently only supports geolocation content type";
- SetDomains();
- SetClearLink();
+ SetDomainsAndClearLink();
}
private:
@@ -183,24 +182,52 @@ class ContentSettingDomainListBubbleModel
add_domain_list(*domain_list);
}
}
- void SetDomains() {
+ void SetDomainsAndClearLink() {
const TabContents::GeolocationContentSettings& settings =
tab_contents()->geolocation_content_settings();
+ const GURL& embedder_url = tab_contents()->GetURL();
+ const GeolocationContentSettingsMap* settings_map =
+ profile()->GetGeolocationContentSettingsMap();
+ const ContentSetting default_setting =
+ settings_map->GetDefaultContentSetting();
+ // Will be true if the current page permission state does not
+ // match that in the content map (i.e. if a reload will yield a different
+ // permission state).
+ bool needs_reload = false;
+ // Will be true if there are any exceptions in the content map
+ // (i.e. non-default entries) for the frames using geolocaiton on this page.
+ bool has_exception = false;
// Divide the tab's current geolocation users into sets according to their
// permission state.
DomainList domains[CONTENT_SETTING_NUM_SETTINGS];
for (TabContents::GeolocationContentSettings::const_iterator it =
settings.begin(); it != settings.end(); ++it) {
domains[it->second].hosts.insert(it->first.host());
+ const ContentSetting saved_setting =
+ settings_map->GetContentSetting(it->first, embedder_url);
+ if (saved_setting != default_setting)
+ has_exception = true;
+ if (saved_setting != it->second)
+ needs_reload = true;
}
MaybeAddDomainList(&domains[CONTENT_SETTING_ALLOW],
IDS_GEOLOCATION_BUBBLE_SECTION_ALLOWED);
MaybeAddDomainList(&domains[CONTENT_SETTING_BLOCK],
IDS_GEOLOCATION_BUBBLE_SECTION_DENIED);
- }
- void SetClearLink() {
- set_clear_link(l10n_util::GetStringUTF8(IDS_GEOLOCATION_BUBBLE_CLEAR_LINK));
+ if (has_exception) {
+ set_clear_link(
+ l10n_util::GetStringUTF8(IDS_GEOLOCATION_BUBBLE_CLEAR_LINK));
+ } else if (needs_reload) {
+ // It is a slight abuse of the domain list field to use it for the reload
+ // hint, but works fine for now. TODO(joth): If we need to style it
+ // differently, consider adding an explicit field, or generalize the
+ // domain list to be a flat list of style formatted lines.
+ DomainList reload_section;
+ reload_section.title = l10n_util::GetStringUTF8(
+ IDS_GEOLOCATION_BUBBLE_REQUIRE_RELOAD_TO_CLEAR);
+ add_domain_list(reload_section);
+ }
}
virtual void OnClearLinkClicked() {
if (!tab_contents())