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

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

Issue 11345008: Remove content::NotificationObserver dependency from most Prefs code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head for commit 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_policy_provider.h" 5 #include "chrome/browser/content_settings/content_settings_policy_provider.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 415
416 void PolicyProvider::ShutdownOnUIThread() { 416 void PolicyProvider::ShutdownOnUIThread() {
417 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 417 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
418 RemoveAllObservers(); 418 RemoveAllObservers();
419 if (!prefs_) 419 if (!prefs_)
420 return; 420 return;
421 pref_change_registrar_.RemoveAll(); 421 pref_change_registrar_.RemoveAll();
422 prefs_ = NULL; 422 prefs_ = NULL;
423 } 423 }
424 424
425 void PolicyProvider::Observe(int type, 425 void PolicyProvider::OnPreferenceChanged(PrefServiceBase* service,
426 const content::NotificationSource& source, 426 const std::string& name) {
427 const content::NotificationDetails& details) {
428 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 427 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
429 DCHECK_EQ(chrome::NOTIFICATION_PREF_CHANGED, type); 428 DCHECK_EQ(prefs_, service);
430 DCHECK_EQ(content::Source<PrefService>(source).ptr(), prefs_);
431 429
432 const std::string& name = *content::Details<std::string>(details).ptr();
433 if (name == prefs::kManagedDefaultCookiesSetting) { 430 if (name == prefs::kManagedDefaultCookiesSetting) {
434 UpdateManagedDefaultSetting(CONTENT_SETTINGS_TYPE_COOKIES); 431 UpdateManagedDefaultSetting(CONTENT_SETTINGS_TYPE_COOKIES);
435 } else if (name == prefs::kManagedDefaultImagesSetting) { 432 } else if (name == prefs::kManagedDefaultImagesSetting) {
436 UpdateManagedDefaultSetting(CONTENT_SETTINGS_TYPE_IMAGES); 433 UpdateManagedDefaultSetting(CONTENT_SETTINGS_TYPE_IMAGES);
437 } else if (name == prefs::kManagedDefaultJavaScriptSetting) { 434 } else if (name == prefs::kManagedDefaultJavaScriptSetting) {
438 UpdateManagedDefaultSetting(CONTENT_SETTINGS_TYPE_JAVASCRIPT); 435 UpdateManagedDefaultSetting(CONTENT_SETTINGS_TYPE_JAVASCRIPT);
439 } else if (name == prefs::kManagedDefaultPluginsSetting) { 436 } else if (name == prefs::kManagedDefaultPluginsSetting) {
440 UpdateManagedDefaultSetting(CONTENT_SETTINGS_TYPE_PLUGINS); 437 UpdateManagedDefaultSetting(CONTENT_SETTINGS_TYPE_PLUGINS);
441 } else if (name == prefs::kManagedDefaultPopupsSetting) { 438 } else if (name == prefs::kManagedDefaultPopupsSetting) {
442 UpdateManagedDefaultSetting(CONTENT_SETTINGS_TYPE_POPUPS); 439 UpdateManagedDefaultSetting(CONTENT_SETTINGS_TYPE_POPUPS);
(...skipping 12 matching lines...) Expand all
455 name == prefs::kManagedJavaScriptAllowedForUrls || 452 name == prefs::kManagedJavaScriptAllowedForUrls ||
456 name == prefs::kManagedJavaScriptBlockedForUrls || 453 name == prefs::kManagedJavaScriptBlockedForUrls ||
457 name == prefs::kManagedPluginsAllowedForUrls || 454 name == prefs::kManagedPluginsAllowedForUrls ||
458 name == prefs::kManagedPluginsBlockedForUrls || 455 name == prefs::kManagedPluginsBlockedForUrls ||
459 name == prefs::kManagedPopupsAllowedForUrls || 456 name == prefs::kManagedPopupsAllowedForUrls ||
460 name == prefs::kManagedPopupsBlockedForUrls || 457 name == prefs::kManagedPopupsBlockedForUrls ||
461 name == prefs::kManagedNotificationsAllowedForUrls || 458 name == prefs::kManagedNotificationsAllowedForUrls ||
462 name == prefs::kManagedNotificationsBlockedForUrls) { 459 name == prefs::kManagedNotificationsBlockedForUrls) {
463 ReadManagedContentSettings(true); 460 ReadManagedContentSettings(true);
464 ReadManagedDefaultSettings(); 461 ReadManagedDefaultSettings();
465 } else {
466 NOTREACHED();
467 return;
468 } 462 }
463
469 NotifyObservers(ContentSettingsPattern(), 464 NotifyObservers(ContentSettingsPattern(),
470 ContentSettingsPattern(), 465 ContentSettingsPattern(),
471 CONTENT_SETTINGS_TYPE_DEFAULT, 466 CONTENT_SETTINGS_TYPE_DEFAULT,
472 std::string()); 467 std::string());
473 } 468 }
474 469
475 } // namespace content_settings 470 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698