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 | 161 |
163 if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 162 if (name == prefs::kBlockThirdPartyCookies) { |
164 PrefService* prefs = content::Source<PrefService>(source).ptr(); | 163 base::AutoLock auto_lock(lock_); |
165 std::string* name = content::Details<std::string>(details).ptr(); | 164 block_third_party_cookies_ = prefs->GetBoolean( |
166 if (*name == prefs::kBlockThirdPartyCookies) { | 165 prefs::kBlockThirdPartyCookies); |
167 base::AutoLock auto_lock(lock_); | |
168 block_third_party_cookies_ = prefs->GetBoolean( | |
169 prefs::kBlockThirdPartyCookies); | |
170 } else { | |
171 NOTREACHED() << "Unexpected preference observed"; | |
172 return; | |
173 } | |
174 } else { | 166 } else { |
175 NOTREACHED() << "Unexpected notification"; | 167 NOTREACHED() << "Unexpected preference observed"; |
| 168 return; |
176 } | 169 } |
177 } | 170 } |
178 | 171 |
179 void CookieSettings::ShutdownOnUIThread() { | 172 void CookieSettings::ShutdownOnUIThread() { |
180 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 173 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
181 pref_change_registrar_.RemoveAll(); | 174 pref_change_registrar_.RemoveAll(); |
182 } | 175 } |
183 | 176 |
184 ContentSetting CookieSettings::GetCookieSetting( | 177 ContentSetting CookieSettings::GetCookieSetting( |
185 const GURL& url, | 178 const GURL& url, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 DCHECK(value.get()); | 216 DCHECK(value.get()); |
224 return content_settings::ValueToContentSetting(value.get()); | 217 return content_settings::ValueToContentSetting(value.get()); |
225 } | 218 } |
226 | 219 |
227 CookieSettings::~CookieSettings() {} | 220 CookieSettings::~CookieSettings() {} |
228 | 221 |
229 bool CookieSettings::ShouldBlockThirdPartyCookies() const { | 222 bool CookieSettings::ShouldBlockThirdPartyCookies() const { |
230 base::AutoLock auto_lock(lock_); | 223 base::AutoLock auto_lock(lock_); |
231 return block_third_party_cookies_; | 224 return block_third_party_cookies_; |
232 } | 225 } |
OLD | NEW |