| 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 "chrome/browser/content_settings/cookie_settings.h" | 5 #include "chrome/browser/content_settings/cookie_settings.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/content_settings/content_settings_utils.h" | 8 #include "chrome/browser/content_settings/content_settings_utils.h" |
| 9 #include "chrome/browser/content_settings/host_content_settings_map.h" | 9 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 } | 148 } |
| 149 | 149 |
| 150 void CookieSettings::ResetCookieSetting( | 150 void CookieSettings::ResetCookieSetting( |
| 151 const ContentSettingsPattern& primary_pattern, | 151 const ContentSettingsPattern& primary_pattern, |
| 152 const ContentSettingsPattern& secondary_pattern) { | 152 const ContentSettingsPattern& secondary_pattern) { |
| 153 host_content_settings_map_->SetContentSetting( | 153 host_content_settings_map_->SetContentSetting( |
| 154 primary_pattern, secondary_pattern, CONTENT_SETTINGS_TYPE_COOKIES, "", | 154 primary_pattern, secondary_pattern, CONTENT_SETTINGS_TYPE_COOKIES, "", |
| 155 CONTENT_SETTING_DEFAULT); | 155 CONTENT_SETTING_DEFAULT); |
| 156 } | 156 } |
| 157 | 157 |
| 158 void CookieSettings::Observe(int type, | 158 void CookieSettings::OnPreferenceChanged(PrefServiceBase* prefs, |
| 159 const content::NotificationSource& source, | 159 const std::string& name) { |
| 160 const content::NotificationDetails& details) { | |
| 161 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 160 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 162 DCHECK_EQ(chrome::NOTIFICATION_PREF_CHANGED, type); | 161 DCHECK_EQ(std::string(prefs::kBlockThirdPartyCookies), name); |
| 163 DCHECK_EQ(std::string(prefs::kBlockThirdPartyCookies), | |
| 164 *content::Details<std::string>(details).ptr()); | |
| 165 | 162 |
| 166 PrefService* prefs = content::Source<PrefService>(source).ptr(); | 163 base::AutoLock auto_lock(lock_); |
| 167 { | 164 block_third_party_cookies_ = prefs->GetBoolean( |
| 168 base::AutoLock auto_lock(lock_); | 165 prefs::kBlockThirdPartyCookies); |
| 169 block_third_party_cookies_ = prefs->GetBoolean( | |
| 170 prefs::kBlockThirdPartyCookies); | |
| 171 } | |
| 172 } | 166 } |
| 173 | 167 |
| 174 void CookieSettings::ShutdownOnUIThread() { | 168 void CookieSettings::ShutdownOnUIThread() { |
| 175 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 169 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 176 pref_change_registrar_.RemoveAll(); | 170 pref_change_registrar_.RemoveAll(); |
| 177 } | 171 } |
| 178 | 172 |
| 179 ContentSetting CookieSettings::GetCookieSetting( | 173 ContentSetting CookieSettings::GetCookieSetting( |
| 180 const GURL& url, | 174 const GURL& url, |
| 181 const GURL& first_party_url, | 175 const GURL& first_party_url, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 DCHECK(value.get()); | 212 DCHECK(value.get()); |
| 219 return content_settings::ValueToContentSetting(value.get()); | 213 return content_settings::ValueToContentSetting(value.get()); |
| 220 } | 214 } |
| 221 | 215 |
| 222 CookieSettings::~CookieSettings() {} | 216 CookieSettings::~CookieSettings() {} |
| 223 | 217 |
| 224 bool CookieSettings::ShouldBlockThirdPartyCookies() const { | 218 bool CookieSettings::ShouldBlockThirdPartyCookies() const { |
| 225 base::AutoLock auto_lock(lock_); | 219 base::AutoLock auto_lock(lock_); |
| 226 return block_third_party_cookies_; | 220 return block_third_party_cookies_; |
| 227 } | 221 } |
| OLD | NEW |