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

Side by Side Diff: chrome/browser/content_settings/content_settings_default_provider.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: Flip DCHECK_EQ arguments to (expected, actual) 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
« no previous file with comments | « no previous file | chrome/browser/content_settings/content_settings_policy_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/content_settings_default_provider.h" 5 #include "chrome/browser/content_settings/content_settings_default_provider.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 DCHECK(prefs_); 273 DCHECK(prefs_);
274 RemoveAllObservers(); 274 RemoveAllObservers();
275 pref_change_registrar_.RemoveAll(); 275 pref_change_registrar_.RemoveAll();
276 prefs_ = NULL; 276 prefs_ = NULL;
277 } 277 }
278 278
279 void DefaultProvider::Observe(int type, 279 void DefaultProvider::Observe(int type,
280 const content::NotificationSource& source, 280 const content::NotificationSource& source,
281 const content::NotificationDetails& details) { 281 const content::NotificationDetails& details) {
282 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 282 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
283 DCHECK_EQ(chrome::NOTIFICATION_PREF_CHANGED, type);
284 DCHECK_EQ(content::Source<PrefService>(source).ptr(), prefs_);
283 285
284 if (type == chrome::NOTIFICATION_PREF_CHANGED) { 286 if (updating_preferences_)
285 DCHECK_EQ(prefs_, content::Source<PrefService>(source).ptr()); 287 return;
286 if (updating_preferences_)
287 return;
288 288
289 std::string* name = content::Details<std::string>(details).ptr(); 289 const std::string& name = *content::Details<std::string>(details).ptr();
290 if (*name == prefs::kDefaultContentSettings) { 290 if (name == prefs::kDefaultContentSettings) {
291 ReadDefaultSettings(true); 291 ReadDefaultSettings(true);
292 } else if (*name == prefs::kGeolocationDefaultContentSetting) { 292 } else if (name == prefs::kGeolocationDefaultContentSetting) {
293 MigrateObsoleteGeolocationPref(); 293 MigrateObsoleteGeolocationPref();
294 // Return and don't send a notifications. Migrating the obsolete 294 // Return and don't send a notifications. Migrating the obsolete
295 // geolocation pref will change the prefs::kDefaultContentSettings and 295 // geolocation pref will change the prefs::kDefaultContentSettings and
296 // cause the notification to be fired. 296 // cause the notification to be fired.
297 return; 297 return;
298 } else { 298 } else {
299 NOTREACHED() << "Unexpected preference observed"; 299 NOTREACHED() << "Unexpected preference observed";
300 return; 300 return;
301 } 301 }
302 302
303 NotifyObservers(ContentSettingsPattern(), 303 NotifyObservers(ContentSettingsPattern(),
304 ContentSettingsPattern(), 304 ContentSettingsPattern(),
305 CONTENT_SETTINGS_TYPE_DEFAULT, 305 CONTENT_SETTINGS_TYPE_DEFAULT,
306 std::string()); 306 std::string());
307 } else {
308 NOTREACHED() << "Unexpected notification";
309 }
310 } 307 }
311 308
312 void DefaultProvider::ReadDefaultSettings(bool overwrite) { 309 void DefaultProvider::ReadDefaultSettings(bool overwrite) {
313 base::AutoLock lock(lock_); 310 base::AutoLock lock(lock_);
314 const DictionaryValue* default_settings_dictionary = 311 const DictionaryValue* default_settings_dictionary =
315 prefs_->GetDictionary(prefs::kDefaultContentSettings); 312 prefs_->GetDictionary(prefs::kDefaultContentSettings);
316 313
317 if (overwrite) 314 if (overwrite)
318 default_settings_.clear(); 315 default_settings_.clear();
319 316
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 SetWebsiteSetting( 383 SetWebsiteSetting(
387 ContentSettingsPattern::Wildcard(), 384 ContentSettingsPattern::Wildcard(),
388 ContentSettingsPattern::Wildcard(), 385 ContentSettingsPattern::Wildcard(),
389 CONTENT_SETTINGS_TYPE_GEOLOCATION, 386 CONTENT_SETTINGS_TYPE_GEOLOCATION,
390 std::string(), 387 std::string(),
391 value->DeepCopy()); 388 value->DeepCopy());
392 } 389 }
393 } 390 }
394 391
395 } // namespace content_settings 392 } // namespace content_settings
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/content_settings/content_settings_policy_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698