Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "components/content_settings/core/browser/cookie_settings.h" | 5 #include "components/content_settings/core/browser/cookie_settings.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "components/content_settings/core/browser/content_settings_utils.h" | 9 #include "components/content_settings/core/browser/content_settings_utils.h" |
| 10 #include "components/content_settings/core/browser/host_content_settings_map.h" | 10 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 85 prefs::kBlockThirdPartyCookies, false, | 85 prefs::kBlockThirdPartyCookies, false, |
| 86 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 86 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void CookieSettings::SetDefaultCookieSetting(ContentSetting setting) { | 89 void CookieSettings::SetDefaultCookieSetting(ContentSetting setting) { |
| 90 DCHECK(IsValidSetting(setting)); | 90 DCHECK(IsValidSetting(setting)); |
| 91 host_content_settings_map_->SetDefaultContentSetting( | 91 host_content_settings_map_->SetDefaultContentSetting( |
| 92 CONTENT_SETTINGS_TYPE_COOKIES, setting); | 92 CONTENT_SETTINGS_TYPE_COOKIES, setting); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void CookieSettings::SetCookieSetting( | 95 void CookieSettings::SetCookieSetting(const GURL& primary_url, |
| 96 ContentSetting setting) { | |
| 97 DCHECK(IsValidSetting(setting)); | |
| 98 host_content_settings_map_->SetContentSettingDefaultScope( | |
| 99 primary_url, GURL(), CONTENT_SETTINGS_TYPE_COOKIES, std::string(), | |
| 100 setting); | |
| 101 } | |
| 102 | |
| 103 void CookieSettings::SetCookieException( | |
| 96 const ContentSettingsPattern& primary_pattern, | 104 const ContentSettingsPattern& primary_pattern, |
| 97 const ContentSettingsPattern& secondary_pattern, | 105 const ContentSettingsPattern& secondary_pattern, |
| 98 ContentSetting setting) { | 106 ContentSetting setting) { |
| 99 DCHECK(IsValidSetting(setting)); | 107 DCHECK(IsValidSetting(setting)); |
| 100 if (setting == CONTENT_SETTING_SESSION_ONLY) { | 108 if (setting == CONTENT_SETTING_SESSION_ONLY) { |
| 101 DCHECK(secondary_pattern == ContentSettingsPattern::Wildcard()); | 109 DCHECK(secondary_pattern == ContentSettingsPattern::Wildcard()); |
|
raymes
2016/03/17 04:21:29
DCHECK_EQ(..., ...);
lshang
2016/03/17 08:49:53
Didn't address this. DCHECK_EQ can only compare tw
| |
| 102 } | 110 } |
|
raymes
2016/03/17 04:21:29
nit: no {}
lshang
2016/03/17 08:49:53
Done.
| |
| 103 host_content_settings_map_->SetContentSetting( | 111 host_content_settings_map_->SetContentSetting( |
| 104 primary_pattern, secondary_pattern, CONTENT_SETTINGS_TYPE_COOKIES, | 112 primary_pattern, secondary_pattern, CONTENT_SETTINGS_TYPE_COOKIES, |
| 105 std::string(), setting); | 113 std::string(), setting); |
| 106 } | 114 } |
| 107 | 115 |
| 108 void CookieSettings::ResetCookieSetting( | 116 void CookieSettings::ResetCookieSetting( |
| 109 const ContentSettingsPattern& primary_pattern, | 117 const ContentSettingsPattern& primary_pattern, |
| 110 const ContentSettingsPattern& secondary_pattern) { | 118 const ContentSettingsPattern& secondary_pattern) { |
| 111 host_content_settings_map_->SetContentSetting( | 119 host_content_settings_map_->SetContentSetting( |
| 112 primary_pattern, secondary_pattern, CONTENT_SETTINGS_TYPE_COOKIES, | 120 primary_pattern, secondary_pattern, CONTENT_SETTINGS_TYPE_COOKIES, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 block_third_party_cookies_ = pref_change_registrar_.prefs()->GetBoolean( | 192 block_third_party_cookies_ = pref_change_registrar_.prefs()->GetBoolean( |
| 185 prefs::kBlockThirdPartyCookies); | 193 prefs::kBlockThirdPartyCookies); |
| 186 } | 194 } |
| 187 | 195 |
| 188 bool CookieSettings::ShouldBlockThirdPartyCookies() const { | 196 bool CookieSettings::ShouldBlockThirdPartyCookies() const { |
| 189 base::AutoLock auto_lock(lock_); | 197 base::AutoLock auto_lock(lock_); |
| 190 return block_third_party_cookies_; | 198 return block_third_party_cookies_; |
| 191 } | 199 } |
| 192 | 200 |
| 193 } // namespace content_settings | 201 } // namespace content_settings |
| OLD | NEW |