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 const ContentSettingsPattern& primary_pattern, | 96 ContentSetting setting) { |
97 const ContentSettingsPattern& secondary_pattern, | |
98 ContentSetting setting) { | |
99 DCHECK(IsValidSetting(setting)); | 97 DCHECK(IsValidSetting(setting)); |
100 if (setting == CONTENT_SETTING_SESSION_ONLY) { | 98 host_content_settings_map_->SetContentSettingDefaultScope( |
101 DCHECK(secondary_pattern == ContentSettingsPattern::Wildcard()); | 99 primary_url, GURL(), CONTENT_SETTINGS_TYPE_COOKIES, std::string(), |
102 } | 100 setting); |
103 host_content_settings_map_->SetContentSetting( | |
104 primary_pattern, secondary_pattern, CONTENT_SETTINGS_TYPE_COOKIES, | |
105 std::string(), setting); | |
106 } | 101 } |
107 | 102 |
108 void CookieSettings::ResetCookieSetting(const GURL& primary_url) { | 103 void CookieSettings::ResetCookieSetting(const GURL& primary_url) { |
109 host_content_settings_map_->SetNarrowestContentSetting( | 104 host_content_settings_map_->SetNarrowestContentSetting( |
110 primary_url, GURL(), CONTENT_SETTINGS_TYPE_COOKIES, | 105 primary_url, GURL(), CONTENT_SETTINGS_TYPE_COOKIES, |
111 CONTENT_SETTING_DEFAULT); | 106 CONTENT_SETTING_DEFAULT); |
112 } | 107 } |
113 | 108 |
114 bool CookieSettings::IsStorageDurable(const GURL& origin) const { | 109 bool CookieSettings::IsStorageDurable(const GURL& origin) const { |
115 // TODO(dgrogan): Don't use host_content_settings_map_ directly. | 110 // TODO(dgrogan): Don't use host_content_settings_map_ directly. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 block_third_party_cookies_ = pref_change_registrar_.prefs()->GetBoolean( | 177 block_third_party_cookies_ = pref_change_registrar_.prefs()->GetBoolean( |
183 prefs::kBlockThirdPartyCookies); | 178 prefs::kBlockThirdPartyCookies); |
184 } | 179 } |
185 | 180 |
186 bool CookieSettings::ShouldBlockThirdPartyCookies() const { | 181 bool CookieSettings::ShouldBlockThirdPartyCookies() const { |
187 base::AutoLock auto_lock(lock_); | 182 base::AutoLock auto_lock(lock_); |
188 return block_third_party_cookies_; | 183 return block_third_party_cookies_; |
189 } | 184 } |
190 | 185 |
191 } // namespace content_settings | 186 } // namespace content_settings |
OLD | NEW |