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

Unified Diff: chrome/browser/notifications/desktop_notification_service.cc

Issue 3304015: Use PrefChangeRegistrar everywhere (Closed)
Patch Set: final version for commit Created 10 years, 3 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/notifications/desktop_notification_service.cc
diff --git a/chrome/browser/notifications/desktop_notification_service.cc b/chrome/browser/notifications/desktop_notification_service.cc
index b55c573771abc259efbf23efe582336e4029b024..1b3df09c899061a43c64599c5432270a59f819e4 100644
--- a/chrome/browser/notifications/desktop_notification_service.cc
+++ b/chrome/browser/notifications/desktop_notification_service.cc
@@ -210,6 +210,7 @@ DesktopNotificationService::DesktopNotificationService(Profile* profile,
NotificationUIManager* ui_manager)
: profile_(profile),
ui_manager_(ui_manager) {
+ registrar_.Init(profile_->GetPrefs());
InitPrefs();
StartObserving();
}
@@ -254,21 +255,15 @@ void DesktopNotificationService::InitPrefs() {
void DesktopNotificationService::StartObserving() {
if (!profile_->IsOffTheRecord()) {
- PrefService* prefs = profile_->GetPrefs();
- prefs->AddPrefObserver(prefs::kDesktopNotificationDefaultContentSetting,
- this);
- prefs->AddPrefObserver(prefs::kDesktopNotificationAllowedOrigins, this);
- prefs->AddPrefObserver(prefs::kDesktopNotificationDeniedOrigins, this);
+ registrar_.Add(prefs::kDesktopNotificationDefaultContentSetting, this);
+ registrar_.Add(prefs::kDesktopNotificationAllowedOrigins, this);
+ registrar_.Add(prefs::kDesktopNotificationDeniedOrigins, this);
}
}
void DesktopNotificationService::StopObserving() {
if (!profile_->IsOffTheRecord()) {
- PrefService* prefs = profile_->GetPrefs();
- prefs->RemovePrefObserver(prefs::kDesktopNotificationDefaultContentSetting,
- this);
- prefs->RemovePrefObserver(prefs::kDesktopNotificationAllowedOrigins, this);
- prefs->RemovePrefObserver(prefs::kDesktopNotificationDeniedOrigins, this);
+ registrar_.RemoveAll();
}
}
« no previous file with comments | « chrome/browser/notifications/desktop_notification_service.h ('k') | chrome/browser/prefs/pref_change_registrar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698