Index: chrome/browser/content_settings/host_content_settings_map.cc |
diff --git a/chrome/browser/content_settings/host_content_settings_map.cc b/chrome/browser/content_settings/host_content_settings_map.cc |
index d58aff9190bb7a9dfb1162b20e36f12998431f8f..f253ae7642e18b579ec344d49844fcf3b9053573 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, |