| Index: chrome/browser/ui/views/profile_chooser_view.cc
|
| diff --git a/chrome/browser/ui/views/profile_chooser_view.cc b/chrome/browser/ui/views/profile_chooser_view.cc
|
| index fd0ea67dfc43d0f1a482c9acd1733a7aa8a34d20..7436dbf33bcbe5960b171e968ed62b2c3b771d02 100644
|
| --- a/chrome/browser/ui/views/profile_chooser_view.cc
|
| +++ b/chrome/browser/ui/views/profile_chooser_view.cc
|
| @@ -221,7 +221,8 @@ ProfileChooserView::ProfileChooserView(views::View* anchor_view,
|
| const gfx::Rect& anchor_rect,
|
| Browser* browser)
|
| : BubbleDelegateView(anchor_view, arrow),
|
| - browser_(browser) {
|
| + browser_(browser),
|
| + view_mode_(PROFILE_CHOOSER_VIEW) {
|
| // Reset the default margins inherited from the BubbleDelegateView.
|
| set_margins(gfx::Insets());
|
| // Compensate for built-in vertical padding in the anchor view's image.
|
| @@ -234,9 +235,15 @@ ProfileChooserView::ProfileChooserView(views::View* anchor_view,
|
| this,
|
| browser_));
|
| avatar_menu_->RebuildMenu();
|
| +
|
| + Profile* profile = browser_->profile();
|
| + ProfileOAuth2TokenServiceFactory::GetForProfile(profile)->AddObserver(this);
|
| }
|
|
|
| ProfileChooserView::~ProfileChooserView() {
|
| + Profile* profile = browser_->profile();
|
| + ProfileOAuth2TokenServiceFactory::GetForProfile(profile)->
|
| + RemoveObserver(this);
|
| }
|
|
|
| void ProfileChooserView::ResetLinksAndButtons() {
|
| @@ -264,6 +271,24 @@ void ProfileChooserView::OnAvatarMenuChanged(
|
| ShowView(PROFILE_CHOOSER_VIEW, avatar_menu);
|
| }
|
|
|
| +void ProfileChooserView::OnRefreshTokenAvailable(
|
| + const std::string& account_id) {
|
| + // Refresh the account management view when a new account is added to the
|
| + // profile.
|
| + if (view_mode_ == ACCOUNT_MANAGEMENT_VIEW ||
|
| + view_mode_ == GAIA_SIGNIN_VIEW ||
|
| + view_mode_ == GAIA_ADD_ACCOUNT_VIEW) {
|
| + ShowView(ACCOUNT_MANAGEMENT_VIEW, avatar_menu_.get());
|
| + }
|
| +}
|
| +
|
| +void ProfileChooserView::OnRefreshTokenRevoked(const std::string& account_id) {
|
| + // Refresh the account management view when an account is removed from the
|
| + // profile.
|
| + if (view_mode_ == ACCOUNT_MANAGEMENT_VIEW)
|
| + ShowView(ACCOUNT_MANAGEMENT_VIEW, avatar_menu_.get());
|
| +}
|
| +
|
| void ProfileChooserView::ShowView(BubbleViewMode view_to_display,
|
| AvatarMenu* avatar_menu) {
|
| // The account management view should only be displayed if the active profile
|
| @@ -276,6 +301,7 @@ void ProfileChooserView::ShowView(BubbleViewMode view_to_display,
|
|
|
| ResetLinksAndButtons();
|
| RemoveAllChildViews(true);
|
| + view_mode_ = view_to_display;
|
|
|
| views::GridLayout* layout = CreateSingleColumnLayout(this);
|
| layout->set_minimum_size(gfx::Size(kMinMenuWidth, 0));
|
|
|