Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: chrome/browser/content_settings/cookie_settings.cc

Issue 11307020: Cleanup: Simplify some extensions / content_settings Observer code by simply DCHECKING instead of u… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::Observe(int type,
159 const content::NotificationSource& source, 159 const content::NotificationSource& source,
160 const content::NotificationDetails& details) { 160 const content::NotificationDetails& details) {
161 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 161 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
162 DCHECK_EQ(type, chrome::NOTIFICATION_PREF_CHANGED);
163 DCHECK_EQ(*content::Details<std::string>(details).ptr(),
164 std::string(prefs::kBlockThirdPartyCookies));
162 165
163 if (type == chrome::NOTIFICATION_PREF_CHANGED) { 166 PrefService* prefs = content::Source<PrefService>(source).ptr();
164 PrefService* prefs = content::Source<PrefService>(source).ptr(); 167 {
165 std::string* name = content::Details<std::string>(details).ptr(); 168 base::AutoLock auto_lock(lock_);
166 if (*name == prefs::kBlockThirdPartyCookies) { 169 block_third_party_cookies_ = prefs->GetBoolean(
167 base::AutoLock auto_lock(lock_); 170 prefs::kBlockThirdPartyCookies);
168 block_third_party_cookies_ = prefs->GetBoolean(
169 prefs::kBlockThirdPartyCookies);
170 } else {
171 NOTREACHED() << "Unexpected preference observed";
172 return;
173 }
174 } else {
175 NOTREACHED() << "Unexpected notification";
176 } 171 }
177 } 172 }
178 173
179 void CookieSettings::ShutdownOnUIThread() { 174 void CookieSettings::ShutdownOnUIThread() {
180 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 175 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
181 pref_change_registrar_.RemoveAll(); 176 pref_change_registrar_.RemoveAll();
182 } 177 }
183 178
184 ContentSetting CookieSettings::GetCookieSetting( 179 ContentSetting CookieSettings::GetCookieSetting(
185 const GURL& url, 180 const GURL& url,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 DCHECK(value.get()); 218 DCHECK(value.get());
224 return content_settings::ValueToContentSetting(value.get()); 219 return content_settings::ValueToContentSetting(value.get());
225 } 220 }
226 221
227 CookieSettings::~CookieSettings() {} 222 CookieSettings::~CookieSettings() {}
228 223
229 bool CookieSettings::ShouldBlockThirdPartyCookies() const { 224 bool CookieSettings::ShouldBlockThirdPartyCookies() const {
230 base::AutoLock auto_lock(lock_); 225 base::AutoLock auto_lock(lock_);
231 return block_third_party_cookies_; 226 return block_third_party_cookies_;
232 } 227 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698