Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1237)

Unified Diff: chrome/browser/content_settings/host_content_settings_map.cc

Issue 7008025: Apply third party cookie blocking to all kinds of cookies (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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,

Powered by Google App Engine
This is Rietveld 408576698