Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/content_settings/host_content_settings_map.h" | 5 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 if (ShouldAllowAllContent(first_party_url, CONTENT_SETTINGS_TYPE_COOKIES)) | 201 if (ShouldAllowAllContent(first_party_url, CONTENT_SETTINGS_TYPE_COOKIES)) |
| 202 return CONTENT_SETTING_ALLOW; | 202 return CONTENT_SETTING_ALLOW; |
| 203 | 203 |
| 204 // First get any host-specific settings. | 204 // First get any host-specific settings. |
| 205 ContentSetting setting = GetNonDefaultContentSetting(url, | 205 ContentSetting setting = GetNonDefaultContentSetting(url, |
| 206 first_party_url, CONTENT_SETTINGS_TYPE_COOKIES, ""); | 206 first_party_url, CONTENT_SETTINGS_TYPE_COOKIES, ""); |
| 207 | 207 |
| 208 // If no explicit exception has been made and third-party cookies are blocked | 208 // If no explicit exception has been made and third-party cookies are blocked |
| 209 // by default, apply that rule. | 209 // by default, apply that rule. |
| 210 if (setting == CONTENT_SETTING_DEFAULT && BlockThirdPartyCookies()) { | 210 if (setting == CONTENT_SETTING_DEFAULT && BlockThirdPartyCookies()) { |
| 211 bool strict = CommandLine::ForCurrentProcess()->HasSwitch( | 211 net::StaticCookiePolicy policy( |
| 212 switches::kBlockReadingThirdPartyCookies); | 212 net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES); |
|
jochen (gone - plz use gerrit)
2011/09/28 07:46:48
I think it would be preferable to keep a pref so y
| |
| 213 net::StaticCookiePolicy policy(strict ? | |
| 214 net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES : | |
| 215 net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES); | |
| 216 int rv; | 213 int rv; |
| 217 if (setting_cookie) | 214 if (setting_cookie) |
| 218 rv = policy.CanSetCookie(url, first_party_url); | 215 rv = policy.CanSetCookie(url, first_party_url); |
| 219 else | 216 else |
| 220 rv = policy.CanGetCookies(url, first_party_url); | 217 rv = policy.CanGetCookies(url, first_party_url); |
| 221 DCHECK_NE(net::ERR_IO_PENDING, rv); | 218 DCHECK_NE(net::ERR_IO_PENDING, rv); |
| 222 if (rv != net::OK) | 219 if (rv != net::OK) |
| 223 setting = CONTENT_SETTING_BLOCK; | 220 setting = CONTENT_SETTING_BLOCK; |
| 224 } | 221 } |
| 225 | 222 |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 586 void HostContentSettingsMap::MigrateObsoleteCookiePref() { | 583 void HostContentSettingsMap::MigrateObsoleteCookiePref() { |
| 587 if (prefs_->HasPrefPath(prefs::kCookieBehavior)) { | 584 if (prefs_->HasPrefPath(prefs::kCookieBehavior)) { |
| 588 int cookie_behavior = prefs_->GetInteger(prefs::kCookieBehavior); | 585 int cookie_behavior = prefs_->GetInteger(prefs::kCookieBehavior); |
| 589 prefs_->ClearPref(prefs::kCookieBehavior); | 586 prefs_->ClearPref(prefs::kCookieBehavior); |
| 590 if (!prefs_->HasPrefPath(prefs::kDefaultContentSettings)) { | 587 if (!prefs_->HasPrefPath(prefs::kDefaultContentSettings)) { |
| 591 SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES, | 588 SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES, |
| 592 (cookie_behavior == net::StaticCookiePolicy::BLOCK_ALL_COOKIES) ? | 589 (cookie_behavior == net::StaticCookiePolicy::BLOCK_ALL_COOKIES) ? |
| 593 CONTENT_SETTING_BLOCK : CONTENT_SETTING_ALLOW); | 590 CONTENT_SETTING_BLOCK : CONTENT_SETTING_ALLOW); |
| 594 } | 591 } |
| 595 if (!prefs_->HasPrefPath(prefs::kBlockThirdPartyCookies)) { | 592 if (!prefs_->HasPrefPath(prefs::kBlockThirdPartyCookies)) { |
| 596 SetBlockThirdPartyCookies(cookie_behavior == | 593 SetBlockThirdPartyCookies( |
| 597 net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES); | 594 cookie_behavior == |
| 595 net::StaticCookiePolicy::BLOCK_SETTING_THIRD_PARTY_COOKIES || | |
| 596 cookie_behavior == | |
| 597 net::StaticCookiePolicy::BLOCK_ALL_THIRD_PARTY_COOKIES); | |
|
jochen (gone - plz use gerrit)
2011/09/28 07:46:48
we don't write this pref key, so it should never b
| |
| 598 } | 598 } |
| 599 } | 599 } |
| 600 } | 600 } |
| OLD | NEW |