| Index: chrome/browser/ui/cocoa/profiles/avatar_base_controller.mm
|
| diff --git a/chrome/browser/ui/cocoa/profiles/avatar_base_controller.mm b/chrome/browser/ui/cocoa/profiles/avatar_base_controller.mm
|
| index f8f8dfb31898127295d6306352b280550bff2ce5..33e969aa57a9261b7d972f59ef9d7ad13804afb0 100644
|
| --- a/chrome/browser/ui/cocoa/profiles/avatar_base_controller.mm
|
| +++ b/chrome/browser/ui/cocoa/profiles/avatar_base_controller.mm
|
| @@ -11,6 +11,7 @@
|
| #include "chrome/browser/profiles/profile_manager.h"
|
| #include "chrome/browser/profiles/profile_metrics.h"
|
| #include "chrome/browser/signin/signin_header_helper.h"
|
| +#include "chrome/browser/profiles/profiles_state.h"
|
| #include "chrome/browser/ui/browser.h"
|
| #include "chrome/browser/ui/browser_commands.h"
|
| #include "chrome/browser/ui/browser_window.h"
|
| @@ -18,6 +19,7 @@
|
| #import "chrome/browser/ui/cocoa/browser_window_controller.h"
|
| #import "chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller.h"
|
| #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h"
|
| +#include "components/signin/core/browser/signin_error_controller.h"
|
| #include "components/signin/core/common/profile_management_switches.h"
|
| #include "ui/base/resource/resource_bundle.h"
|
|
|
| @@ -27,50 +29,79 @@ const CGFloat kMenuYOffsetAdjust = 1.0;
|
| @interface AvatarBaseController (Private)
|
| // Shows the avatar bubble.
|
| - (IBAction)buttonClicked:(id)sender;
|
| +
|
| - (void)bubbleWillClose:(NSNotification*)notif;
|
| +
|
| // Updates the profile name displayed by the avatar button. If |layoutParent| is
|
| // yes, then the BrowserWindowController is notified to relayout the subviews,
|
| // as the button needs to be repositioned.
|
| - (void)updateAvatarButtonAndLayoutParent:(BOOL)layoutParent;
|
| +
|
| +// Displays an error icon if any accounts associated with this profile have an
|
| +// auth error.
|
| +- (void)updateErrorStatus:(BOOL)hasError;
|
| @end
|
|
|
| -class ProfileInfoUpdateObserver : public ProfileInfoCacheObserver {
|
| +class ProfileInfoUpdateObserver : public ProfileInfoCacheObserver,
|
| + public SigninErrorController::Observer {
|
| public:
|
| - ProfileInfoUpdateObserver(AvatarBaseController* avatarButton)
|
| - : avatarButton_(avatarButton) {
|
| + ProfileInfoUpdateObserver(Profile* profile,
|
| + AvatarBaseController* avatarController)
|
| + : profile_(profile),
|
| + avatarController_(avatarController) {
|
| g_browser_process->profile_manager()->
|
| GetProfileInfoCache().AddObserver(this);
|
| +
|
| + // Subscribe to authentication error changes so that the avatar button
|
| + // can update itself.
|
| + SigninErrorController* errorController =
|
| + profiles::GetSigninErrorController(profile_);
|
| + if (errorController)
|
| + errorController->AddObserver(this);
|
| }
|
|
|
| virtual ~ProfileInfoUpdateObserver() {
|
| g_browser_process->profile_manager()->
|
| GetProfileInfoCache().RemoveObserver(this);
|
| + SigninErrorController* errorController =
|
| + profiles::GetSigninErrorController(profile_);
|
| + if (errorController)
|
| + errorController->RemoveObserver(this);
|
| }
|
|
|
| // ProfileInfoCacheObserver:
|
| virtual void OnProfileAdded(const base::FilePath& profile_path) OVERRIDE {
|
| - [avatarButton_ updateAvatarButtonAndLayoutParent:YES];
|
| + [avatarController_ updateAvatarButtonAndLayoutParent:YES];
|
| }
|
|
|
| virtual void OnProfileWasRemoved(
|
| const base::FilePath& profile_path,
|
| const base::string16& profile_name) OVERRIDE {
|
| - [avatarButton_ updateAvatarButtonAndLayoutParent:YES];
|
| + [avatarController_ updateAvatarButtonAndLayoutParent:YES];
|
| }
|
|
|
| virtual void OnProfileNameChanged(
|
| const base::FilePath& profile_path,
|
| const base::string16& old_profile_name) OVERRIDE {
|
| - [avatarButton_ updateAvatarButtonAndLayoutParent:YES];
|
| + [avatarController_ updateAvatarButtonAndLayoutParent:YES];
|
| }
|
|
|
| virtual void OnProfileAvatarChanged(
|
| const base::FilePath& profile_path) OVERRIDE {
|
| - [avatarButton_ updateAvatarButtonAndLayoutParent:YES];
|
| + [avatarController_ updateAvatarButtonAndLayoutParent:YES];
|
| + }
|
| +
|
| + // SigninErrorController::Observer:
|
| + virtual void OnErrorChanged() OVERRIDE {
|
| + SigninErrorController* errorController =
|
| + profiles::GetSigninErrorController(profile_);
|
| + if (errorController)
|
| + [avatarController_ updateErrorStatus:errorController->HasError()];
|
| }
|
|
|
| private:
|
| - AvatarBaseController* avatarButton_; // Weak; owns this.
|
| + Profile* profile_;
|
| + AvatarBaseController* avatarController_; // Weak; owns this.
|
|
|
| DISALLOW_COPY_AND_ASSIGN(ProfileInfoUpdateObserver);
|
| };
|
| @@ -80,7 +111,8 @@ class ProfileInfoUpdateObserver : public ProfileInfoCacheObserver {
|
| - (id)initWithBrowser:(Browser*)browser {
|
| if ((self = [super init])) {
|
| browser_ = browser;
|
| - profileInfoObserver_.reset(new ProfileInfoUpdateObserver(self));
|
| + profileInfoObserver_.reset(
|
| + new ProfileInfoUpdateObserver(browser_->profile(), self));
|
| }
|
| return self;
|
| }
|
| @@ -170,6 +202,9 @@ class ProfileInfoUpdateObserver : public ProfileInfoCacheObserver {
|
| NOTREACHED();
|
| }
|
|
|
| +- (void)updateErrorStatus:(BOOL)hasError {
|
| +}
|
| +
|
| - (BaseBubbleController*)menuController {
|
| return menuController_;
|
| }
|
|
|