| 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 ef503f002245ebf0682c24d027402f3e92851b1e..8a39e7314b245e37c99a86826e0676de7373112f 100644
|
| --- a/chrome/browser/ui/cocoa/profiles/avatar_base_controller.mm
|
| +++ b/chrome/browser/ui/cocoa/profiles/avatar_base_controller.mm
|
| @@ -8,7 +8,6 @@
|
| #include "base/macros.h"
|
| #include "chrome/app/chrome_command_ids.h"
|
| #include "chrome/browser/browser_process.h"
|
| -#include "chrome/browser/profiles/profile_attributes_storage.h"
|
| #include "chrome/browser/profiles/profile_avatar_icon_util.h"
|
| #include "chrome/browser/profiles/profile_manager.h"
|
| #include "chrome/browser/profiles/profile_metrics.h"
|
| @@ -22,7 +21,6 @@
|
| #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/cocoa/cocoa_base_utils.h"
|
|
|
| @@ -45,85 +43,68 @@ const CGFloat kMenuXOffsetAdjust = 2.0;
|
| - (void)updateAvatarButtonAndLayoutParent:(BOOL)layoutParent;
|
|
|
| // Displays an error icon if any accounts associated with this profile have an
|
| -// auth error.
|
| -- (void)updateErrorStatus:(BOOL)hasError;
|
| +// auth error or sync error.
|
| +- (void)setErrorStatus:(BOOL)hasError;
|
| @end
|
|
|
| -class ProfileAttributesUpdateObserver
|
| - : public ProfileAttributesStorage::Observer,
|
| - public SigninErrorController::Observer {
|
| - public:
|
| - ProfileAttributesUpdateObserver(Profile* profile,
|
| - AvatarBaseController* avatarController)
|
| - : profile_(profile),
|
| - avatarController_(avatarController) {
|
| - g_browser_process->profile_manager()->
|
| - GetProfileAttributesStorage().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);
|
| - }
|
| -
|
| - ~ProfileAttributesUpdateObserver() override {
|
| - g_browser_process->profile_manager()->
|
| - GetProfileAttributesStorage().RemoveObserver(this);
|
| - SigninErrorController* errorController =
|
| - profiles::GetSigninErrorController(profile_);
|
| - if (errorController)
|
| - errorController->RemoveObserver(this);
|
| - }
|
| +ProfileUpdateObserver::ProfileUpdateObserver(
|
| + Profile* profile,
|
| + AvatarBaseController* avatarController)
|
| + : errorController_(this, profile),
|
| + profile_(profile),
|
| + avatarController_(avatarController) {
|
| + g_browser_process->profile_manager()
|
| + ->GetProfileAttributesStorage()
|
| + .AddObserver(this);
|
| +}
|
|
|
| - // ProfileAttributesStorage::Observer:
|
| - void OnProfileAdded(const base::FilePath& profile_path) override {
|
| - [avatarController_ updateAvatarButtonAndLayoutParent:YES];
|
| - }
|
| +ProfileUpdateObserver::~ProfileUpdateObserver() {
|
| + g_browser_process->profile_manager()
|
| + ->GetProfileAttributesStorage()
|
| + .RemoveObserver(this);
|
| +}
|
|
|
| - void OnProfileWasRemoved(const base::FilePath& profile_path,
|
| - const base::string16& profile_name) override {
|
| - // If deleting the active profile, don't bother updating the avatar
|
| - // button, as the browser window is being closed anyway.
|
| - if (profile_->GetPath() != profile_path)
|
| - [avatarController_ updateAvatarButtonAndLayoutParent:YES];
|
| - }
|
| +void ProfileUpdateObserver::OnProfileAdded(const base::FilePath& profile_path) {
|
| + [avatarController_ updateAvatarButtonAndLayoutParent:YES];
|
| +}
|
|
|
| - void OnProfileNameChanged(const base::FilePath& profile_path,
|
| - const base::string16& old_profile_name) override {
|
| - if (profile_->GetPath() == profile_path)
|
| - [avatarController_ updateAvatarButtonAndLayoutParent:YES];
|
| - }
|
| +void ProfileUpdateObserver::OnProfileWasRemoved(
|
| + const base::FilePath& profile_path,
|
| + const base::string16& profile_name) {
|
| + // If deleting the active profile, don't bother updating the avatar
|
| + // button, as the browser window is being closed anyway.
|
| + if (profile_->GetPath() != profile_path)
|
| + [avatarController_ updateAvatarButtonAndLayoutParent:YES];
|
| +}
|
|
|
| - void OnProfileSupervisedUserIdChanged(
|
| - const base::FilePath& profile_path) override {
|
| - if (profile_->GetPath() == profile_path)
|
| - [avatarController_ updateAvatarButtonAndLayoutParent:YES];
|
| - }
|
| +void ProfileUpdateObserver::OnProfileNameChanged(
|
| + const base::FilePath& profile_path,
|
| + const base::string16& old_profile_name) {
|
| + if (profile_->GetPath() == profile_path)
|
| + [avatarController_ updateAvatarButtonAndLayoutParent:YES];
|
| +}
|
|
|
| - // SigninErrorController::Observer:
|
| - void OnErrorChanged() override {
|
| - SigninErrorController* errorController =
|
| - profiles::GetSigninErrorController(profile_);
|
| - if (errorController)
|
| - [avatarController_ updateErrorStatus:errorController->HasError()];
|
| - }
|
| +void ProfileUpdateObserver::OnProfileSupervisedUserIdChanged(
|
| + const base::FilePath& profile_path) {
|
| + if (profile_->GetPath() == profile_path)
|
| + [avatarController_ updateAvatarButtonAndLayoutParent:YES];
|
| +}
|
|
|
| - private:
|
| - Profile* profile_;
|
| - AvatarBaseController* avatarController_; // Weak; owns this.
|
| +void ProfileUpdateObserver::OnAvatarErrorChanged() {
|
| + [avatarController_ setErrorStatus:errorController_.HasAvatarError()];
|
| +}
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(ProfileAttributesUpdateObserver);
|
| -};
|
| +bool ProfileUpdateObserver::HasAvatarError() {
|
| + return errorController_.HasAvatarError();
|
| +}
|
|
|
| @implementation AvatarBaseController
|
|
|
| - (id)initWithBrowser:(Browser*)browser {
|
| if ((self = [super init])) {
|
| browser_ = browser;
|
| - profileAttributesObserver_.reset(
|
| - new ProfileAttributesUpdateObserver(browser_->profile(), self));
|
| + profileObserver_.reset(
|
| + new ProfileUpdateObserver(browser_->profile(), self));
|
| }
|
| return self;
|
| }
|
| @@ -255,7 +236,7 @@ class ProfileAttributesUpdateObserver
|
| NOTREACHED();
|
| }
|
|
|
| -- (void)updateErrorStatus:(BOOL)hasError {
|
| +- (void)setErrorStatus:(BOOL)hasError {
|
| }
|
|
|
| - (BaseBubbleController*)menuController {
|
|
|