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

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

Issue 895803003: [Profiles] Remove the NotificationService from the ProfileInfoCache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: maybe fix NTPLoginHandler tests Created 5 years, 10 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/message_center_settings_controller.cc
diff --git a/chrome/browser/notifications/message_center_settings_controller.cc b/chrome/browser/notifications/message_center_settings_controller.cc
index 6a70af4a0aa87548754621c7d6f26374975dbfee..89f5e5e6ad102604f9ee2233c3af55bdd157b66d 100644
--- a/chrome/browser/notifications/message_center_settings_controller.cc
+++ b/chrome/browser/notifications/message_center_settings_controller.cc
@@ -134,10 +134,8 @@ MessageCenterSettingsController::MessageCenterSettingsController(
registrar_.Add(this,
chrome::NOTIFICATION_PROFILE_DESTROYED,
content::NotificationService::AllBrowserContextsAndSources());
- registrar_.Add(this,
- chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
- content::NotificationService::AllBrowserContextsAndSources());
- RebuildNotifierGroups();
+ g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(this);
+ RebuildNotifierGroups(false);
#if defined(OS_CHROMEOS)
// UserManager may not exist in some tests.
@@ -147,6 +145,8 @@ MessageCenterSettingsController::MessageCenterSettingsController(
}
MessageCenterSettingsController::~MessageCenterSettingsController() {
+ g_browser_process->profile_manager()->
+ GetProfileInfoCache().RemoveObserver(this);
#if defined(OS_CHROMEOS)
// UserManager may not exist in some tests.
if (user_manager::UserManager::IsInitialized())
@@ -403,7 +403,7 @@ void MessageCenterSettingsController::OnFaviconLoaded(
#if defined(OS_CHROMEOS)
void MessageCenterSettingsController::ActiveUserChanged(
const user_manager::User* active_user) {
- RebuildNotifierGroups();
+ RebuildNotifierGroups(false);
}
#endif
@@ -426,10 +426,26 @@ void MessageCenterSettingsController::Observe(
return;
}
- RebuildNotifierGroups();
- FOR_EACH_OBSERVER(message_center::NotifierSettingsObserver,
- observers_,
- NotifierGroupChanged());
+ RebuildNotifierGroups(true);
+}
+
+void MessageCenterSettingsController::OnProfileAdded(
+ const base::FilePath& profile_path) {
+ RebuildNotifierGroups(true);
+}
+void MessageCenterSettingsController::OnProfileWasRemoved(
+ const base::FilePath& profile_path,
+ const base::string16& profile_name) {
+ RebuildNotifierGroups(true);
+}
+void MessageCenterSettingsController::OnProfileNameChanged(
+ const base::FilePath& profile_path,
+ const base::string16& old_profile_name) {
+ RebuildNotifierGroups(true);
+}
+void MessageCenterSettingsController::OnProfileUserNameChanged(
+ const base::FilePath& profile_path) {
+ RebuildNotifierGroups(true);
}
#if defined(OS_CHROMEOS)
@@ -460,12 +476,11 @@ void MessageCenterSettingsController::CreateNotifierGroupForGuestLogin() {
}
#endif
-void MessageCenterSettingsController::RebuildNotifierGroups() {
+void MessageCenterSettingsController::RebuildNotifierGroups(bool notify) {
notifier_groups_.clear();
current_notifier_group_ = 0;
const size_t count = profile_info_cache_->GetNumberOfProfiles();
-
for (size_t i = 0; i < count; ++i) {
scoped_ptr<message_center::ProfileNotifierGroup> group(
new message_center::ProfileNotifierGroup(
@@ -517,4 +532,10 @@ void MessageCenterSettingsController::RebuildNotifierGroups() {
weak_factory_.GetWeakPtr()));
}
#endif
+
+ if (notify) {
+ FOR_EACH_OBSERVER(message_center::NotifierSettingsObserver,
+ observers_,
+ NotifierGroupChanged());
+ }
}

Powered by Google App Engine
This is Rietveld 408576698