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

Unified Diff: chrome/browser/profiles/avatar_menu.cc

Issue 597783003: Update the AvatarMenu when a supervised user's custodian info changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ScopedObserver Created 6 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/profiles/avatar_menu.cc
diff --git a/chrome/browser/profiles/avatar_menu.cc b/chrome/browser/profiles/avatar_menu.cc
index da41957edccb2bd1bd9f0c4525afd2e25e2fc852..e9f8860a86877792968348731b90dd6028611155 100644
--- a/chrome/browser/profiles/avatar_menu.cc
+++ b/chrome/browser/profiles/avatar_menu.cc
@@ -53,6 +53,9 @@ AvatarMenu::AvatarMenu(ProfileInfoInterface* profile_cache,
Browser* browser)
: profile_list_(ProfileList::Create(profile_cache)),
menu_actions_(AvatarMenuActions::Create()),
+#if defined(ENABLE_MANAGED_USERS)
+ supervised_user_observer_(this),
+#endif
profile_info_(profile_cache),
observer_(observer),
browser_(browser) {
@@ -64,6 +67,16 @@ AvatarMenu::AvatarMenu(ProfileInfoInterface* profile_cache,
// Register this as an observer of the info cache.
registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
content::NotificationService::AllSources());
+
+#if defined(ENABLE_MANAGED_USERS)
+ // Register this as an observer of the SupervisedUserService to be notified
+ // of changes to the custodian info.
+ if (browser_) {
+ SupervisedUserService* service =
+ SupervisedUserServiceFactory::GetForProfile(browser_->profile());
+ supervised_user_observer_.Add(service);
Bernhard Bauer 2014/09/25 16:11:19 You could even inline |service| now?
Marc Treib 2014/09/25 16:17:16 Done.
+ }
+#endif
}
AvatarMenu::~AvatarMenu() {
@@ -234,3 +247,11 @@ void AvatarMenu::Observe(int type,
if (observer_)
observer_->OnAvatarMenuChanged(this);
}
+
+#if defined(ENABLE_MANAGED_USERS)
+void AvatarMenu::OnCustodianInfoChanged() {
+ RebuildMenu();
+ if (observer_)
+ observer_->OnAvatarMenuChanged(this);
+}
+#endif

Powered by Google App Engine
This is Rietveld 408576698