Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Unified Diff: chrome/browser/ui/views/profile_chooser_view.cc

Issue 58183002: Auto refresh avatar bubble after adding a secondary account (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: roger comments addressed Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/profile_chooser_view.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..3e769b38a3fe354175a45d795039f6bc0529512c 100644
--- a/chrome/browser/ui/views/profile_chooser_view.cc
+++ b/chrome/browser/ui/views/profile_chooser_view.cc
@@ -234,9 +234,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() {
@@ -250,6 +256,7 @@ void ProfileChooserView::ResetLinksAndButtons() {
add_user_button_ = NULL;
add_account_button_ = NULL;
open_other_profile_indexes_map_.clear();
+ view_mode_ = PROFILE_CHOOSER_VIEW;
sky 2013/11/04 21:19:33 Is there a reason this is here not the member init
guohui 2013/11/05 14:40:01 Because this is the current central place to initi
sky 2013/11/05 15:53:50 For view_mode_ don't you only want it reset to the
guohui 2013/11/05 20:00:50 it is the same as all other members, first reset t
}
void ProfileChooserView::Init() {
@@ -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));
« no previous file with comments | « chrome/browser/ui/views/profile_chooser_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698