From cbd426185e5893b46084922ea4c6c766cd94bc26 Mon Sep 17 00:00:00 2001 From: "bauerb@chromium.org" Date: Mon, 19 Jul 2010 09:29:02 +0000 Subject: Preparatory work for adding content exceptions from the tab cookie view. Factor out HostContentSettingsMap::AddExceptionForURL() and add CookieTreeOriginNode::CreateContentException(). Review URL: http://codereview.chromium.org/2868059 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@52888 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/content_setting_bubble_model.cc | 12 ++---------- chrome/browser/cookies_tree_model.cc | 7 +++++++ chrome/browser/host_content_settings_map.cc | 12 ++++++++++++ chrome/browser/host_content_settings_map.h | 7 +++++++ 4 files changed, 28 insertions(+), 10 deletions(-) (limited to 'chrome') diff --git a/chrome/browser/content_setting_bubble_model.cc b/chrome/browser/content_setting_bubble_model.cc index 6fc78e1..6d8b902 100644 --- a/chrome/browser/content_setting_bubble_model.cc +++ b/chrome/browser/content_setting_bubble_model.cc @@ -166,16 +166,8 @@ 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), + profile()->GetHostContentSettingsMap()->AddExceptionForURL( + bubble_content().radio_group.url, content_type(), radio_index == 0 ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); } diff --git a/chrome/browser/cookies_tree_model.cc b/chrome/browser/cookies_tree_model.cc index 239a36d..a51d2cb 100644 --- a/chrome/browser/cookies_tree_model.cc +++ b/chrome/browser/cookies_tree_model.cc @@ -237,6 +237,13 @@ CookieTreeAppCachesNode* CookieTreeOriginNode::GetOrCreateAppCachesNode() { return appcaches_child_; } +void CookieTreeOriginNode::CreateContentException() { +// profile_->GetHostContentSettingsMap()->AddExceptionForURL( +// , +// CONTENT_, +// radio_index == 0 ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); +} + /////////////////////////////////////////////////////////////////////////////// // CookieTreeCookiesNode, public: diff --git a/chrome/browser/host_content_settings_map.cc b/chrome/browser/host_content_settings_map.cc index 611b645..8742238 100644 --- a/chrome/browser/host_content_settings_map.cc +++ b/chrome/browser/host_content_settings_map.cc @@ -406,6 +406,18 @@ void HostContentSettingsMap::SetContentSetting(const Pattern& pattern, NotifyObservers(ContentSettingsDetails(pattern)); } +void HostContentSettingsMap::AddExceptionForURL( + const GURL& url, + ContentSettingsType content_type, + ContentSetting setting) { + // Make sure there is no entry that would override the pattern we are about + // to insert for exactly this URL. + SetContentSetting(Pattern::FromURLNoWildcard(url), + content_type, + CONTENT_SETTING_DEFAULT); + SetContentSetting(Pattern::FromURL(url), content_type, setting); +} + void HostContentSettingsMap::ClearSettingsForOneType( ContentSettingsType content_type) { DCHECK(kTypeNames[content_type] != NULL); // Don't call this for Geolocation. diff --git a/chrome/browser/host_content_settings_map.h b/chrome/browser/host_content_settings_map.h index 876fa713..fc38afc 100644 --- a/chrome/browser/host_content_settings_map.h +++ b/chrome/browser/host_content_settings_map.h @@ -142,6 +142,13 @@ class HostContentSettingsMap ContentSettingsType content_type, ContentSetting setting); + // Convenience method to add a content setting for a given URL, making sure + // that there is no setting overriding it. + // This should only be called on the UI thread. + void AddExceptionForURL(const GURL& url, + ContentSettingsType content_type, + ContentSetting setting); + // Clears all host-specific settings for one content type. // // This should only be called on the UI thread. -- cgit v1.1