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

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

Issue 11345008: Remove content::NotificationObserver dependency from most Prefs code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix PrefNotifierImpl 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/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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 } 269 }
270 270
271 void DefaultProvider::ShutdownOnUIThread() { 271 void DefaultProvider::ShutdownOnUIThread() {
272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
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::OnPreferenceChanged(PrefServiceBase* service,
280 const content::NotificationSource& source, 280 const std::string& name) {
281 const content::NotificationDetails& details) {
282 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 281 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
283 282
284 if (type == chrome::NOTIFICATION_PREF_CHANGED) { 283 DCHECK_EQ(prefs_, service);
285 DCHECK_EQ(prefs_, content::Source<PrefService>(source).ptr()); 284 if (updating_preferences_)
286 if (updating_preferences_) 285 return;
287 return;
288 286
289 std::string* name = content::Details<std::string>(details).ptr(); 287 if (name == prefs::kDefaultContentSettings) {
290 if (*name == prefs::kDefaultContentSettings) { 288 ReadDefaultSettings(true);
291 ReadDefaultSettings(true); 289 } else if (name == prefs::kGeolocationDefaultContentSetting) {
292 } else if (*name == prefs::kGeolocationDefaultContentSetting) { 290 MigrateObsoleteGeolocationPref();
293 MigrateObsoleteGeolocationPref(); 291 // Return and don't send a notifications. Migrating the obsolete
294 // Return and don't send a notifications. Migrating the obsolete 292 // geolocation pref will change the prefs::kDefaultContentSettings and
295 // geolocation pref will change the prefs::kDefaultContentSettings and 293 // cause the notification to be fired.
296 // cause the notification to be fired. 294 return;
297 return; 295 } else {
298 } else { 296 NOTREACHED() << "Unexpected preference observed";
299 NOTREACHED() << "Unexpected preference observed"; 297 return;
300 return; 298 }
301 }
302 299
303 NotifyObservers(ContentSettingsPattern(), 300 NotifyObservers(ContentSettingsPattern(),
304 ContentSettingsPattern(), 301 ContentSettingsPattern(),
305 CONTENT_SETTINGS_TYPE_DEFAULT, 302 CONTENT_SETTINGS_TYPE_DEFAULT,
306 std::string()); 303 std::string());
307 } else {
308 NOTREACHED() << "Unexpected notification";
309 }
310 } 304 }
311 305
312 void DefaultProvider::ReadDefaultSettings(bool overwrite) { 306 void DefaultProvider::ReadDefaultSettings(bool overwrite) {
313 base::AutoLock lock(lock_); 307 base::AutoLock lock(lock_);
314 const DictionaryValue* default_settings_dictionary = 308 const DictionaryValue* default_settings_dictionary =
315 prefs_->GetDictionary(prefs::kDefaultContentSettings); 309 prefs_->GetDictionary(prefs::kDefaultContentSettings);
316 310
317 if (overwrite) 311 if (overwrite)
318 default_settings_.clear(); 312 default_settings_.clear();
319 313
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 SetWebsiteSetting( 380 SetWebsiteSetting(
387 ContentSettingsPattern::Wildcard(), 381 ContentSettingsPattern::Wildcard(),
388 ContentSettingsPattern::Wildcard(), 382 ContentSettingsPattern::Wildcard(),
389 CONTENT_SETTINGS_TYPE_GEOLOCATION, 383 CONTENT_SETTINGS_TYPE_GEOLOCATION,
390 std::string(), 384 std::string(),
391 value->DeepCopy()); 385 value->DeepCopy());
392 } 386 }
393 } 387 }
394 388
395 } // namespace content_settings 389 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698