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

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: move initialization of view_mode_ to constructor 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..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));
« 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