diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-26 14:26:09 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-26 14:26:09 +0000 |
commit | 5b52ad495b1afcfb6c71259cfa8e18dec60378aa (patch) | |
tree | 64a43712584282e504f188711dbc5ab5b61cd1df /chrome | |
parent | 4d7715c250719cf357e156425d9226740329d9ec (diff) | |
download | chromium_src-5b52ad495b1afcfb6c71259cfa8e18dec60378aa.zip chromium_src-5b52ad495b1afcfb6c71259cfa8e18dec60378aa.tar.gz chromium_src-5b52ad495b1afcfb6c71259cfa8e18dec60378aa.tar.bz2 |
Apply third party cookie blocking to all kinds of cookies
BUG=72586
TEST=HostContentSettingsMapTest.Cookies*
Review URL: http://codereview.chromium.org/7008025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86820 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
8 files changed, 263 insertions, 75 deletions
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc index 47ba711..d66a1be 100644 --- a/chrome/browser/chrome_content_browser_client.cc +++ b/chrome/browser/chrome_content_browser_client.cc @@ -44,7 +44,6 @@ #include "content/common/bindings_policy.h" #include "net/base/cookie_monster.h" #include "net/base/cookie_options.h" -#include "net/base/static_cookie_policy.h" #if defined(OS_LINUX) #include "base/linux_util.h" @@ -238,12 +237,14 @@ std::string ChromeContentBrowserClient::GetAcceptLangs(const TabContents* tab) { } bool ChromeContentBrowserClient::AllowAppCache( - const GURL& manifest_url, const content::ResourceContext& context) { + const GURL& manifest_url, + const content::ResourceContext& context) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); ProfileIOData* io_data = reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); + // FIXME(jochen): get the correct top-level origin. ContentSetting setting = io_data->GetHostContentSettingsMap()-> - GetContentSetting(manifest_url, CONTENT_SETTINGS_TYPE_COOKIES, ""); + GetCookieContentSetting(manifest_url, manifest_url, true); DCHECK(setting != CONTENT_SETTING_DEFAULT); return setting != CONTENT_SETTING_BLOCK; } @@ -256,27 +257,12 @@ bool ChromeContentBrowserClient::AllowGetCookie( int render_process_id, int render_view_id) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - bool allow = true; ProfileIOData* io_data = reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); - if (io_data->GetHostContentSettingsMap()->BlockThirdPartyCookies()) { - bool strict = CommandLine::ForCurrentProcess()->HasSwitch( - switches::kBlockReadingThirdPartyCookies); - net::StaticCookiePolicy policy(strict ? - net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES : - net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES); - int rv = policy.CanGetCookies(url, first_party); - DCHECK_NE(net::ERR_IO_PENDING, rv); - if (rv != net::OK) - allow = false; - } - - if (allow) { - ContentSetting setting = io_data->GetHostContentSettingsMap()-> - GetContentSetting(url, CONTENT_SETTINGS_TYPE_COOKIES, ""); - allow = setting == CONTENT_SETTING_ALLOW || - setting == CONTENT_SETTING_SESSION_ONLY; - } + ContentSetting setting = io_data->GetHostContentSettingsMap()-> + GetCookieContentSetting(url, first_party, false); + bool allow = setting == CONTENT_SETTING_ALLOW || + setting == CONTENT_SETTING_SESSION_ONLY; BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, @@ -295,30 +281,16 @@ bool ChromeContentBrowserClient::AllowSetCookie( int render_view_id, net::CookieOptions* options) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); - bool allow = true; ProfileIOData* io_data = reinterpret_cast<ProfileIOData*>(context.GetUserData(NULL)); - if (io_data->GetHostContentSettingsMap()->BlockThirdPartyCookies()) { - bool strict = CommandLine::ForCurrentProcess()->HasSwitch( - switches::kBlockReadingThirdPartyCookies); - net::StaticCookiePolicy policy(strict ? - net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES : - net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES); - int rv = policy.CanSetCookie(url, first_party, cookie_line); - if (rv != net::OK) - allow = false; - } - - if (allow) { - ContentSetting setting = io_data->GetHostContentSettingsMap()-> - GetContentSetting(url, CONTENT_SETTINGS_TYPE_COOKIES, ""); + ContentSetting setting = io_data->GetHostContentSettingsMap()-> + GetCookieContentSetting(url, first_party, true); - if (setting == CONTENT_SETTING_SESSION_ONLY) - options->set_force_session(); + if (setting == CONTENT_SETTING_SESSION_ONLY) + options->set_force_session(); - allow = setting == CONTENT_SETTING_ALLOW || - setting == CONTENT_SETTING_SESSION_ONLY; - } + bool allow = setting == CONTENT_SETTING_ALLOW || + setting == CONTENT_SETTING_SESSION_ONLY; BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, diff --git a/chrome/browser/chrome_worker_message_filter.cc b/chrome/browser/chrome_worker_message_filter.cc index 0e2b569..453ac5d 100644 --- a/chrome/browser/chrome_worker_message_filter.cc +++ b/chrome/browser/chrome_worker_message_filter.cc @@ -43,8 +43,7 @@ void ChromeWorkerMessageFilter::OnAllowDatabase(int worker_route_id, unsigned long estimated_size, bool* result) { ContentSetting content_setting = - host_content_settings_map_->GetContentSetting( - url, CONTENT_SETTINGS_TYPE_COOKIES, ""); + host_content_settings_map_->GetCookieContentSetting(url, url, true); *result = content_setting != CONTENT_SETTING_BLOCK; @@ -75,7 +74,6 @@ void ChromeWorkerMessageFilter::OnAllowFileSystem(int worker_route_id, // TODO(kinuko): Need to notify the UI thread to indicate that // there's a blocked content. See the above for inspiration. ContentSetting content_setting = - host_content_settings_map_->GetContentSetting( - url, CONTENT_SETTINGS_TYPE_COOKIES, ""); + host_content_settings_map_->GetCookieContentSetting(url, url, true); *result = content_setting != CONTENT_SETTING_BLOCK; } diff --git a/chrome/browser/content_settings/host_content_settings_map.cc b/chrome/browser/content_settings/host_content_settings_map.cc index d58aff9..f253ae7 100644 --- a/chrome/browser/content_settings/host_content_settings_map.cc +++ b/chrome/browser/content_settings/host_content_settings_map.cc @@ -24,6 +24,7 @@ #include "content/common/notification_source.h" #include "content/common/notification_type.h" #include "googleurl/src/gurl.h" +#include "net/base/net_errors.h" #include "net/base/net_util.h" #include "net/base/static_cookie_policy.h" @@ -161,6 +162,14 @@ ContentSetting HostContentSettingsMap::GetContentSetting( const GURL& url, ContentSettingsType content_type, const std::string& resource_identifier) const { + DCHECK_NE(CONTENT_SETTINGS_TYPE_COOKIES, content_type); + return GetContentSettingInternal(url, content_type, resource_identifier); +} + +ContentSetting HostContentSettingsMap::GetContentSettingInternal( + const GURL& url, + ContentSettingsType content_type, + const std::string& resource_identifier) const { ContentSetting setting = GetNonDefaultContentSetting(url, content_type, resource_identifier); @@ -169,6 +178,33 @@ ContentSetting HostContentSettingsMap::GetContentSetting( return setting; } +ContentSetting HostContentSettingsMap::GetCookieContentSetting( + const GURL& url, + const GURL& first_party_url, + bool setting_cookie) const { + ContentSetting setting = CONTENT_SETTING_ALLOW; + if (BlockThirdPartyCookies()) { + bool strict = CommandLine::ForCurrentProcess()->HasSwitch( + switches::kBlockReadingThirdPartyCookies); + net::StaticCookiePolicy policy(strict ? + net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES : + net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES); + int rv; + if (setting_cookie) + rv = policy.CanSetCookie(url, first_party_url); + else + rv = policy.CanGetCookies(url, first_party_url); + DCHECK_NE(net::ERR_IO_PENDING, rv); + if (rv != net::OK) + setting = CONTENT_SETTING_BLOCK; + } + + if (setting == CONTENT_SETTING_ALLOW) + setting = GetContentSettingInternal(url, CONTENT_SETTINGS_TYPE_COOKIES, ""); + + return setting; +} + ContentSetting HostContentSettingsMap::GetNonDefaultContentSetting( const GURL& url, ContentSettingsType content_type, diff --git a/chrome/browser/content_settings/host_content_settings_map.h b/chrome/browser/content_settings/host_content_settings_map.h index 09b3500..68f4cad 100644 --- a/chrome/browser/content_settings/host_content_settings_map.h +++ b/chrome/browser/content_settings/host_content_settings_map.h @@ -65,6 +65,16 @@ class HostContentSettingsMap ContentSettingsType content_type, const std::string& resource_identifier) const; + // Gets the content setting for cookies. This takes the third party cookie + // flag into account, and therefore needs to know whether we read or write a + // cookie. + // + // This may be called on any thread. + ContentSetting GetCookieContentSetting( + const GURL& url, + const GURL& first_party_url, + bool setting_cookie) const; + // Returns a single ContentSetting which applies to a given URL or // CONTENT_SETTING_DEFAULT, if no exception applies. Note that certain // internal schemes are whitelisted. For ContentSettingsTypes that require an @@ -169,6 +179,11 @@ class HostContentSettingsMap virtual ~HostContentSettingsMap(); + ContentSetting GetContentSettingInternal( + const GURL& url, + ContentSettingsType content_type, + const std::string& resource_identifier) const; + void UnregisterObservers(); // Various migration methods (old cookie, popup and per-host data gets diff --git a/chrome/browser/content_settings/host_content_settings_map_unittest.cc b/chrome/browser/content_settings/host_content_settings_map_unittest.cc index 8a3b0e7..60075e5 100644 --- a/chrome/browser/content_settings/host_content_settings_map_unittest.cc +++ b/chrome/browser/content_settings/host_content_settings_map_unittest.cc @@ -256,8 +256,8 @@ TEST_F(HostContentSettingsMapTest, ObserveDefaultPref) { host_content_settings_map->SetDefaultContentSetting( CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK); EXPECT_EQ(CONTENT_SETTING_BLOCK, - host_content_settings_map->GetContentSetting( - host, CONTENT_SETTINGS_TYPE_COOKIES, "")); + host_content_settings_map->GetCookieContentSetting( + host, host, true)); // Make a copy of the pref's new value so we can reset it later. scoped_ptr<Value> new_value(prefs->FindPreference( @@ -266,14 +266,14 @@ TEST_F(HostContentSettingsMapTest, ObserveDefaultPref) { // Clearing the backing pref should also clear the internal cache. prefs->Set(prefs::kDefaultContentSettings, *default_value); EXPECT_EQ(CONTENT_SETTING_ALLOW, - host_content_settings_map->GetContentSetting( - host, CONTENT_SETTINGS_TYPE_COOKIES, "")); + host_content_settings_map->GetCookieContentSetting( + host, host, true)); // Reseting the pref to its previous value should update the cache. prefs->Set(prefs::kDefaultContentSettings, *new_value); EXPECT_EQ(CONTENT_SETTING_BLOCK, - host_content_settings_map->GetContentSetting( - host, CONTENT_SETTINGS_TYPE_COOKIES, "")); + host_content_settings_map->GetCookieContentSetting( + host, host, true)); } TEST_F(HostContentSettingsMapTest, ObserveExceptionPref) { @@ -294,8 +294,8 @@ TEST_F(HostContentSettingsMapTest, ObserveExceptionPref) { host_content_settings_map->SetContentSetting(pattern, CONTENT_SETTINGS_TYPE_COOKIES, "", CONTENT_SETTING_BLOCK); EXPECT_EQ(CONTENT_SETTING_BLOCK, - host_content_settings_map->GetContentSetting( - host, CONTENT_SETTINGS_TYPE_COOKIES, "")); + host_content_settings_map->GetCookieContentSetting( + host, host, true)); // Make a copy of the pref's new value so we can reset it later. scoped_ptr<Value> new_value(prefs->FindPreference( @@ -304,14 +304,14 @@ TEST_F(HostContentSettingsMapTest, ObserveExceptionPref) { // Clearing the backing pref should also clear the internal cache. prefs->Set(prefs::kContentSettingsPatterns, *default_value); EXPECT_EQ(CONTENT_SETTING_ALLOW, - host_content_settings_map->GetContentSetting( - host, CONTENT_SETTINGS_TYPE_COOKIES, "")); + host_content_settings_map->GetCookieContentSetting( + host, host, true)); // Reseting the pref to its previous value should update the cache. prefs->Set(prefs::kContentSettingsPatterns, *new_value); EXPECT_EQ(CONTENT_SETTING_BLOCK, - host_content_settings_map->GetContentSetting( - host, CONTENT_SETTINGS_TYPE_COOKIES, "")); + host_content_settings_map->GetCookieContentSetting( + host, host, true)); } TEST_F(HostContentSettingsMapTest, HostTrimEndingDotCheck) { @@ -338,18 +338,18 @@ TEST_F(HostContentSettingsMapTest, HostTrimEndingDotCheck) { host_ending_with_dot, CONTENT_SETTINGS_TYPE_IMAGES, "")); EXPECT_EQ(CONTENT_SETTING_ALLOW, - host_content_settings_map->GetContentSetting( - host_ending_with_dot, CONTENT_SETTINGS_TYPE_COOKIES, "")); + host_content_settings_map->GetCookieContentSetting( + host_ending_with_dot, host_ending_with_dot, true)); host_content_settings_map->SetContentSetting(pattern, CONTENT_SETTINGS_TYPE_COOKIES, "", CONTENT_SETTING_DEFAULT); EXPECT_EQ(CONTENT_SETTING_ALLOW, - host_content_settings_map->GetContentSetting( - host_ending_with_dot, CONTENT_SETTINGS_TYPE_COOKIES, "")); + host_content_settings_map->GetCookieContentSetting( + host_ending_with_dot, host_ending_with_dot, true)); host_content_settings_map->SetContentSetting(pattern, CONTENT_SETTINGS_TYPE_COOKIES, "", CONTENT_SETTING_BLOCK); EXPECT_EQ(CONTENT_SETTING_BLOCK, - host_content_settings_map->GetContentSetting( - host_ending_with_dot, CONTENT_SETTINGS_TYPE_COOKIES, "")); + host_content_settings_map->GetCookieContentSetting( + host_ending_with_dot, host_ending_with_dot, true)); EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting( @@ -901,4 +901,170 @@ TEST_F(HostContentSettingsMapTest, ResetToDefaultsWhenManaged) { EXPECT_FALSE(host_content_settings_map->BlockThirdPartyCookies()); } +// Tests for cookie content settings. +const GURL kBlockedSite = GURL("http://ads.thirdparty.com"); +const GURL kAllowedSite = GURL("http://good.allays.com"); +const GURL kFirstPartySite = GURL("http://cool.things.com"); + +TEST_F(HostContentSettingsMapTest, CookiesBlockSingle) { + TestingProfile profile; + HostContentSettingsMap* host_content_settings_map = + profile.GetHostContentSettingsMap(); + host_content_settings_map->AddExceptionForURL( + kBlockedSite, CONTENT_SETTINGS_TYPE_COOKIES, "", + CONTENT_SETTING_BLOCK); + EXPECT_EQ(CONTENT_SETTING_BLOCK, + host_content_settings_map->GetCookieContentSetting( + kBlockedSite, kBlockedSite, false)); +} + +TEST_F(HostContentSettingsMapTest, CookiesBlockThirdParty) { + TestingProfile profile; + HostContentSettingsMap* host_content_settings_map = + profile.GetHostContentSettingsMap(); + host_content_settings_map->SetBlockThirdPartyCookies(true); + EXPECT_EQ(CONTENT_SETTING_ALLOW, + host_content_settings_map->GetCookieContentSetting( + kBlockedSite, kFirstPartySite, false)); + EXPECT_EQ(CONTENT_SETTING_BLOCK, + host_content_settings_map->GetCookieContentSetting( + kBlockedSite, kFirstPartySite, true)); + + CommandLine* cmd = CommandLine::ForCurrentProcess(); + AutoReset<CommandLine> auto_reset(cmd, *cmd); + cmd->AppendSwitch(switches::kBlockReadingThirdPartyCookies); + + EXPECT_EQ(CONTENT_SETTING_BLOCK, + host_content_settings_map->GetCookieContentSetting( + kBlockedSite, kFirstPartySite, false)); + EXPECT_EQ(CONTENT_SETTING_BLOCK, + host_content_settings_map->GetCookieContentSetting( + kBlockedSite, kFirstPartySite, true)); +} + +TEST_F(HostContentSettingsMapTest, CookiesAllowThirdParty) { + TestingProfile profile; + HostContentSettingsMap* host_content_settings_map = + profile.GetHostContentSettingsMap(); + EXPECT_EQ(CONTENT_SETTING_ALLOW, + host_content_settings_map->GetCookieContentSetting( + kBlockedSite, kFirstPartySite, false)); + EXPECT_EQ(CONTENT_SETTING_ALLOW, + host_content_settings_map->GetCookieContentSetting( + kBlockedSite, kFirstPartySite, true)); +} + +TEST_F(HostContentSettingsMapTest, CookiesExplicitBlockSingleThirdParty) { + TestingProfile profile; + HostContentSettingsMap* host_content_settings_map = + profile.GetHostContentSettingsMap(); + host_content_settings_map->AddExceptionForURL( + kBlockedSite, CONTENT_SETTINGS_TYPE_COOKIES, "", + CONTENT_SETTING_BLOCK); + EXPECT_EQ(CONTENT_SETTING_BLOCK, + host_content_settings_map->GetCookieContentSetting( + kBlockedSite, kFirstPartySite, false)); + EXPECT_EQ(CONTENT_SETTING_BLOCK, + host_content_settings_map->GetCookieContentSetting( + kBlockedSite, kFirstPartySite, true)); + EXPECT_EQ(CONTENT_SETTING_ALLOW, + host_content_settings_map->GetCookieContentSetting( + kAllowedSite, kFirstPartySite, true)); +} + +TEST_F(HostContentSettingsMapTest, CookiesExplicitSessionOnly) { + TestingProfile profile; + HostContentSettingsMap* host_content_settings_map = + profile.GetHostContentSettingsMap(); + host_content_settings_map->AddExceptionForURL( + kBlockedSite, CONTENT_SETTINGS_TYPE_COOKIES, "", + CONTENT_SETTING_SESSION_ONLY); + EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY, + host_content_settings_map->GetCookieContentSetting( + kBlockedSite, kFirstPartySite, false)); + EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY, + host_content_settings_map->GetCookieContentSetting( + kBlockedSite, kFirstPartySite, true)); + + host_content_settings_map->SetBlockThirdPartyCookies(true); + EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY, + host_content_settings_map->GetCookieContentSetting( + kBlockedSite, kFirstPartySite, false)); + EXPECT_EQ(CONTENT_SETTING_BLOCK, + host_content_settings_map->GetCookieContentSetting( + kBlockedSite, kFirstPartySite, true)); +} + +TEST_F(HostContentSettingsMapTest, CookiesThirdPartyAlwaysBlocked) { + TestingProfile profile; + HostContentSettingsMap* host_content_settings_map = + profile.GetHostContentSettingsMap(); + host_content_settings_map->AddExceptionForURL( + kAllowedSite, CONTENT_SETTINGS_TYPE_COOKIES, "", + CONTENT_SETTING_ALLOW); + host_content_settings_map->SetBlockThirdPartyCookies(true); + EXPECT_EQ(CONTENT_SETTING_ALLOW, + host_content_settings_map->GetCookieContentSetting( + kAllowedSite, kFirstPartySite, false)); + EXPECT_EQ(CONTENT_SETTING_BLOCK, + host_content_settings_map->GetCookieContentSetting( + kAllowedSite, kFirstPartySite, true)); + + CommandLine* cmd = CommandLine::ForCurrentProcess(); + AutoReset<CommandLine> auto_reset(cmd, *cmd); + cmd->AppendSwitch(switches::kBlockReadingThirdPartyCookies); + + EXPECT_EQ(CONTENT_SETTING_BLOCK, + host_content_settings_map->GetCookieContentSetting( + kAllowedSite, kFirstPartySite, false)); +} + +TEST_F(HostContentSettingsMapTest, CookiesBlockEverything) { + TestingProfile profile; + HostContentSettingsMap* host_content_settings_map = + profile.GetHostContentSettingsMap(); + host_content_settings_map->SetDefaultContentSetting( + CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK); + + EXPECT_EQ(CONTENT_SETTING_BLOCK, + host_content_settings_map->GetCookieContentSetting( + kFirstPartySite, kFirstPartySite, false)); + EXPECT_EQ(CONTENT_SETTING_BLOCK, + host_content_settings_map->GetCookieContentSetting( + kFirstPartySite, kFirstPartySite, true)); + EXPECT_EQ(CONTENT_SETTING_BLOCK, + host_content_settings_map->GetCookieContentSetting( + kAllowedSite, kFirstPartySite, true)); +} + +TEST_F(HostContentSettingsMapTest, CookiesBlockEverythingExceptAllowed) { + TestingProfile profile; + HostContentSettingsMap* host_content_settings_map = + profile.GetHostContentSettingsMap(); + host_content_settings_map->SetDefaultContentSetting( + CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK); + host_content_settings_map->AddExceptionForURL( + kAllowedSite, CONTENT_SETTINGS_TYPE_COOKIES, "", + CONTENT_SETTING_ALLOW); + + EXPECT_EQ(CONTENT_SETTING_BLOCK, + host_content_settings_map->GetCookieContentSetting( + kFirstPartySite, kFirstPartySite, false)); + EXPECT_EQ(CONTENT_SETTING_BLOCK, + host_content_settings_map->GetCookieContentSetting( + kFirstPartySite, kFirstPartySite, true)); + EXPECT_EQ(CONTENT_SETTING_ALLOW, + host_content_settings_map->GetCookieContentSetting( + kAllowedSite, kFirstPartySite, false)); + EXPECT_EQ(CONTENT_SETTING_ALLOW, + host_content_settings_map->GetCookieContentSetting( + kAllowedSite, kFirstPartySite, true)); + EXPECT_EQ(CONTENT_SETTING_ALLOW, + host_content_settings_map->GetCookieContentSetting( + kAllowedSite, kAllowedSite, false)); + EXPECT_EQ(CONTENT_SETTING_ALLOW, + host_content_settings_map->GetCookieContentSetting( + kAllowedSite, kAllowedSite, true)); +} + } // namespace diff --git a/chrome/browser/cookies_tree_model_unittest.cc b/chrome/browser/cookies_tree_model_unittest.cc index 94051ac..9ff0a5c 100644 --- a/chrome/browser/cookies_tree_model_unittest.cc +++ b/chrome/browser/cookies_tree_model_unittest.cc @@ -681,8 +681,7 @@ TEST_F(CookiesTreeModelTest, ContentSettings) { EXPECT_EQ(2, observer.counter); EXPECT_EQ(pattern, observer.last_pattern); EXPECT_EQ(CONTENT_SETTING_SESSION_ONLY, - content_settings->GetContentSetting( - host, CONTENT_SETTINGS_TYPE_COOKIES, "")); + content_settings->GetCookieContentSetting(host, host, true)); } } // namespace diff --git a/chrome/browser/renderer_host/chrome_render_message_filter.cc b/chrome/browser/renderer_host/chrome_render_message_filter.cc index 6f71701..2ef39eb 100644 --- a/chrome/browser/renderer_host/chrome_render_message_filter.cc +++ b/chrome/browser/renderer_host/chrome_render_message_filter.cc @@ -334,8 +334,8 @@ void ChromeRenderMessageFilter::OnAllowDatabase(int render_view_id, const string16& name, const string16& display_name, bool* allowed) { - ContentSetting setting = host_content_settings_map_->GetContentSetting( - origin_url, CONTENT_SETTINGS_TYPE_COOKIES, ""); + ContentSetting setting = host_content_settings_map_->GetCookieContentSetting( + origin_url, top_origin_url, true); DCHECK((setting == CONTENT_SETTING_ALLOW) || (setting == CONTENT_SETTING_BLOCK) || (setting == CONTENT_SETTING_SESSION_ONLY)); @@ -354,8 +354,8 @@ void ChromeRenderMessageFilter::OnAllowDOMStorage(int render_view_id, const GURL& top_origin_url, DOMStorageType type, bool* allowed) { - ContentSetting setting = host_content_settings_map_->GetContentSetting( - origin_url, CONTENT_SETTINGS_TYPE_COOKIES, ""); + ContentSetting setting = host_content_settings_map_->GetCookieContentSetting( + origin_url, top_origin_url, true); *allowed = setting != CONTENT_SETTING_BLOCK; // If content was blocked, tell the UI to display the blocked content icon. BrowserThread::PostTask( @@ -371,8 +371,8 @@ void ChromeRenderMessageFilter::OnAllowFileSystem(int render_view_id, bool* allowed) { // TODO(kinuko): Need to notify the UI thread to indicate that // there's a blocked content. See the above for inspiration. - ContentSetting setting = host_content_settings_map_->GetContentSetting( - origin_url, CONTENT_SETTINGS_TYPE_COOKIES, ""); + ContentSetting setting = host_content_settings_map_->GetCookieContentSetting( + origin_url, top_origin_url, true); DCHECK((setting == CONTENT_SETTING_ALLOW) || (setting == CONTENT_SETTING_BLOCK) || (setting == CONTENT_SETTING_SESSION_ONLY)); @@ -384,8 +384,8 @@ void ChromeRenderMessageFilter::OnAllowIndexedDB(int render_view_id, const GURL& top_origin_url, const string16& name, bool* allowed) { - ContentSetting setting = host_content_settings_map_->GetContentSetting( - origin_url, CONTENT_SETTINGS_TYPE_COOKIES, ""); + ContentSetting setting = host_content_settings_map_->GetCookieContentSetting( + origin_url, top_origin_url, true); *allowed = setting != CONTENT_SETTING_BLOCK; BrowserThread::PostTask( diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc index 865f1c2..1d96238 100644 --- a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc @@ -280,7 +280,9 @@ class ContentSettingSingleRadioGroup ContentSetting mostRestrictiveSetting; if (resources.empty()) { mostRestrictiveSetting = - map->GetContentSetting(url, content_type(), std::string()); + content_type() == CONTENT_SETTINGS_TYPE_COOKIES ? + map->GetCookieContentSetting(url, url, true) : + map->GetContentSetting(url, content_type(), std::string()); } else { mostRestrictiveSetting = CONTENT_SETTING_ALLOW; for (std::set<std::string>::const_iterator it = resources.begin(); |