summaryrefslogtreecommitdiffstats
path: root/chrome/browser/profiles
diff options
context:
space:
mode:
authortreib <treib@chromium.org>2014-09-26 09:06:25 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-26 16:06:38 +0000
commit3fce4e99a7b91b6ff5ea1036c4984f97e373ab76 (patch)
tree0a5580443c6424909ecdfddbf3a9d7f597e11a8e /chrome/browser/profiles
parentbb13612c089559c29f8509856901225409f2a44b (diff)
downloadchromium_src-3fce4e99a7b91b6ff5ea1036c4984f97e373ab76.zip
chromium_src-3fce4e99a7b91b6ff5ea1036c4984f97e373ab76.tar.gz
chromium_src-3fce4e99a7b91b6ff5ea1036c4984f97e373ab76.tar.bz2
Update the AvatarMenu (and the ProfileChooserView, which listens for changes to the AvatarMenu) when a supervised user's custodian info changes.
BUG=372381 Review URL: https://codereview.chromium.org/597783003 Cr-Commit-Position: refs/heads/master@{#296954}
Diffstat (limited to 'chrome/browser/profiles')
-rw-r--r--chrome/browser/profiles/avatar_menu.cc20
-rw-r--r--chrome/browser/profiles/avatar_menu.h25
-rw-r--r--chrome/browser/profiles/profile_list_desktop_browsertest.cc13
3 files changed, 47 insertions, 11 deletions
diff --git a/chrome/browser/profiles/avatar_menu.cc b/chrome/browser/profiles/avatar_menu.cc
index da41957..992a2aa 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,15 @@ 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_) {
+ supervised_user_observer_.Add(
+ SupervisedUserServiceFactory::GetForProfile(browser_->profile()));
+ }
+#endif
}
AvatarMenu::~AvatarMenu() {
@@ -234,3 +246,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
diff --git a/chrome/browser/profiles/avatar_menu.h b/chrome/browser/profiles/avatar_menu.h
index f319a32..781bdf4 100644
--- a/chrome/browser/profiles/avatar_menu.h
+++ b/chrome/browser/profiles/avatar_menu.h
@@ -10,6 +10,7 @@
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "base/scoped_observer.h"
#include "base/strings/string16.h"
#include "chrome/browser/profiles/profile_metrics.h"
#include "chrome/browser/ui/host_desktop.h"
@@ -19,19 +20,28 @@
#include "content/public/browser/web_contents_observer.h"
#include "ui/gfx/image/image.h"
+#if defined(ENABLE_MANAGED_USERS)
+#include "chrome/browser/supervised_user/supervised_user_service_observer.h"
+#endif
+
+class AvatarMenuActions;
class AvatarMenuObserver;
class Browser;
class Profile;
class ProfileInfoInterface;
class ProfileList;
-class AvatarMenuActions;
+class SupervisedUserService;
// This class represents the menu-like interface used to select profiles,
// such as the bubble that appears when the avatar icon is clicked in the
// browser window frame. This class will notify its observer when the backend
// data changes, and the view for this model should forward actions
// back to it in response to user events.
-class AvatarMenu : public content::NotificationObserver {
+class AvatarMenu :
+#if defined(ENABLE_MANAGED_USERS)
+ public SupervisedUserServiceObserver,
+#endif
+ public content::NotificationObserver {
public:
// Represents an item in the menu.
struct Item {
@@ -142,12 +152,23 @@ class AvatarMenu : public content::NotificationObserver {
const content::NotificationDetails& details) OVERRIDE;
private:
+#if defined(ENABLE_MANAGED_USERS)
+ // SupervisedUserServiceObserver:
+ virtual void OnCustodianInfoChanged() OVERRIDE;
+#endif
+
// The model that provides the list of menu items.
scoped_ptr<ProfileList> profile_list_;
// The controller for avatar menu actions.
scoped_ptr<AvatarMenuActions> menu_actions_;
+#if defined(ENABLE_MANAGED_USERS)
+ // Observes changes to a supervised user's custodian info.
+ ScopedObserver<SupervisedUserService, SupervisedUserServiceObserver>
+ supervised_user_observer_;
+#endif
+
// The cache that provides the profile information. Weak.
ProfileInfoInterface* profile_info_;
diff --git a/chrome/browser/profiles/profile_list_desktop_browsertest.cc b/chrome/browser/profiles/profile_list_desktop_browsertest.cc
index 65a0b2f..e87bdf1 100644
--- a/chrome/browser/profiles/profile_list_desktop_browsertest.cc
+++ b/chrome/browser/profiles/profile_list_desktop_browsertest.cc
@@ -34,13 +34,8 @@ class ProfileListDesktopBrowserTest : public InProcessBrowserTest {
public:
ProfileListDesktopBrowserTest() {}
- AvatarMenu* GetAvatarMenu(ProfileInfoCache* cache) {
- // Reset the menu.
- avatar_menu_.reset(new AvatarMenu(
- cache,
- NULL,
- browser()));
- return avatar_menu_.get();
+ scoped_ptr<AvatarMenu> CreateAvatarMenu(ProfileInfoCache* cache) {
+ return scoped_ptr<AvatarMenu>(new AvatarMenu(cache, NULL, browser()));
}
private:
@@ -68,7 +63,7 @@ IN_PROC_BROWSER_TEST_F(ProfileListDesktopBrowserTest, MAYBE_SignOut) {
ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
size_t index = cache.GetIndexOfProfileWithPath(current_profile->GetPath());
- AvatarMenu* menu = GetAvatarMenu(&cache);
+ scoped_ptr<AvatarMenu> menu = CreateAvatarMenu(&cache);
menu->RebuildMenu();
BrowserList* browser_list =
@@ -125,7 +120,7 @@ IN_PROC_BROWSER_TEST_F(ProfileListDesktopBrowserTest, MAYBE_SwitchToProfile) {
content::RunMessageLoop();
ASSERT_EQ(cache.GetNumberOfProfiles(), 2U);
- AvatarMenu* menu = GetAvatarMenu(&cache);
+ scoped_ptr<AvatarMenu> menu = CreateAvatarMenu(&cache);
menu->RebuildMenu();
BrowserList* browser_list =
BrowserList::GetInstance(chrome::GetActiveDesktop());