diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-26 07:32:14 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-26 07:32:14 +0000 |
commit | decdd511099c41390b0cfc8859bf93bc1a628e0a (patch) | |
tree | cd5ba0ec818289b57b76bdebf51bd78c0f87a49c /chrome/browser | |
parent | a7a7735b1c0b8a4b1c9d40ede057e9081ef3c6a1 (diff) | |
download | chromium_src-decdd511099c41390b0cfc8859bf93bc1a628e0a.zip chromium_src-decdd511099c41390b0cfc8859bf93bc1a628e0a.tar.gz chromium_src-decdd511099c41390b0cfc8859bf93bc1a628e0a.tar.bz2 |
Clear non-wildcard content settings before setting from bubble or prompt.
BUG=42359
TEST=manual
Review URL: http://codereview.chromium.org/1707011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45571 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/content_setting_bubble_model.cc | 7 | ||||
-rw-r--r-- | chrome/browser/cookie_modal_dialog.cc | 10 | ||||
-rw-r--r-- | chrome/browser/host_content_settings_map.cc | 6 | ||||
-rw-r--r-- | chrome/browser/host_content_settings_map.h | 3 |
4 files changed, 26 insertions, 0 deletions
diff --git a/chrome/browser/content_setting_bubble_model.cc b/chrome/browser/content_setting_bubble_model.cc index 6c01be3..afbf712 100644 --- a/chrome/browser/content_setting_bubble_model.cc +++ b/chrome/browser/content_setting_bubble_model.cc @@ -121,6 +121,13 @@ class ContentSettingSingleRadioGroup : public ContentSettingTitleAndLinkModel { } virtual void OnRadioClicked(int radio_index) { + // Make sure there is no entry that would override the pattern we are about + // to insert for exactly this URL. + profile()->GetHostContentSettingsMap()->SetContentSetting( + HostContentSettingsMap::Pattern::FromURLNoWildcard( + bubble_content().radio_group.url), + content_type(), + CONTENT_SETTING_DEFAULT); profile()->GetHostContentSettingsMap()->SetContentSetting( HostContentSettingsMap::Pattern::FromURL( bubble_content().radio_group.url), diff --git a/chrome/browser/cookie_modal_dialog.cc b/chrome/browser/cookie_modal_dialog.cc index 0135fad..ed86178 100644 --- a/chrome/browser/cookie_modal_dialog.cc +++ b/chrome/browser/cookie_modal_dialog.cc @@ -101,6 +101,11 @@ void CookiePromptModalDialog::AllowSiteData(bool remember, bool session_expire) { DCHECK(!remember || DecisionPersistable()); if (remember && DecisionPersistable()) { + // Make sure there is no entry that would override the pattern we are about + // to insert for exactly this URL. + host_content_settings_map_->SetContentSetting( + HostContentSettingsMap::Pattern::FromURLNoWildcard(origin_), + CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_DEFAULT); host_content_settings_map_->SetContentSetting( HostContentSettingsMap::Pattern::FromURL(origin_), CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_ALLOW); @@ -115,6 +120,11 @@ void CookiePromptModalDialog::AllowSiteData(bool remember, void CookiePromptModalDialog::BlockSiteData(bool remember) { DCHECK(!remember || DecisionPersistable()); if (remember && DecisionPersistable()) { + // Make sure there is no entry that would override the pattern we are about + // to insert for exactly this URL. + host_content_settings_map_->SetContentSetting( + HostContentSettingsMap::Pattern::FromURLNoWildcard(origin_), + CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_DEFAULT); host_content_settings_map_->SetContentSetting( HostContentSettingsMap::Pattern::FromURL(origin_), CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK); diff --git a/chrome/browser/host_content_settings_map.cc b/chrome/browser/host_content_settings_map.cc index 11a080e..40c117e 100644 --- a/chrome/browser/host_content_settings_map.cc +++ b/chrome/browser/host_content_settings_map.cc @@ -47,6 +47,12 @@ HostContentSettingsMap::Pattern HostContentSettingsMap::Pattern::FromURL( std::string(kDomainWildcard) + url.host()); } +// static +HostContentSettingsMap::Pattern + HostContentSettingsMap::Pattern::FromURLNoWildcard(const GURL& url) { + return Pattern(net::GetHostOrSpecFromURL(url)); +} + bool HostContentSettingsMap::Pattern::IsValid() const { if (pattern_.empty()) return false; diff --git a/chrome/browser/host_content_settings_map.h b/chrome/browser/host_content_settings_map.h index 1317eb3..06f1270 100644 --- a/chrome/browser/host_content_settings_map.h +++ b/chrome/browser/host_content_settings_map.h @@ -37,6 +37,9 @@ class HostContentSettingsMap // Returns a pattern that matches the host of this URL and all subdomains. static Pattern FromURL(const GURL& url); + // Returns a pattern that matches exactly this URL. + static Pattern FromURLNoWildcard(const GURL& url); + Pattern() {} explicit Pattern(const std::string& pattern) : pattern_(pattern) {} |