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..ff34373670bba49be07eb8c358cf83106ad97612 100644 |
--- a/chrome/browser/profiles/avatar_menu.cc |
+++ b/chrome/browser/profiles/avatar_menu.cc |
@@ -64,9 +64,26 @@ 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()); |
noms (inactive)
2014/09/25 14:22:22
Is it possible to be in a state where browser_->pr
Marc Treib
2014/09/25 14:50:56
browser_->profile() can be the guest profile, but
Bernhard Bauer
2014/09/25 15:15:48
Yeah, I don't think we set it to NULL for testing
|
+ service->AddObserver(this); |
+ } |
+#endif |
} |
AvatarMenu::~AvatarMenu() { |
+#if defined(ENABLE_MANAGED_USERS) |
+ if (browser_) { |
+ SupervisedUserService* service = |
+ SupervisedUserServiceFactory::GetForProfile(browser_->profile()); |
+ service->RemoveObserver(this); |
Bernhard Bauer
2014/09/25 15:15:48
A ScopedObserver might be useful here, to do this
Marc Treib
2014/09/25 15:30:28
Done.
|
+ } |
+#endif |
} |
AvatarMenu::Item::Item(size_t menu_index, |
@@ -234,3 +251,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 |