Commit 798b02e5 authored by guohui's avatar guohui Committed by Commit bot

Refresh the avatar bubble with the current view

The new avatar menu has multiple views, and on any view, the avatar menu
change event may occur and trigger refresh. Thus instead of always refreshing
with the profile chooser view mode, we should refresh with the current view mode.

BUG=

Review URL: https://codereview.chromium.org/530113002

Cr-Commit-Position: refs/heads/master@{#293123}
parent a04fbdc9
...@@ -312,18 +312,11 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, ...@@ -312,18 +312,11 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver,
// AvatarMenuObserver: // AvatarMenuObserver:
virtual void OnAvatarMenuChanged(AvatarMenu* avatar_menu) OVERRIDE { virtual void OnAvatarMenuChanged(AvatarMenu* avatar_menu) OVERRIDE {
// Do not refresh the avatar menu if the user is on a signin related view.
profiles::BubbleViewMode viewMode = [controller_ viewMode]; profiles::BubbleViewMode viewMode = [controller_ viewMode];
if (viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN || if (viewMode == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER ||
viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || viewMode == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) {
viewMode == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) { [controller_ initMenuContentsWithView:viewMode];
return;
} }
// While the bubble is open, the avatar menu can only change from the
// profile chooser view by modifying the current profile's photo or name.
[controller_
initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER];
} }
// content::NotificationObserver: // content::NotificationObserver:
......
...@@ -602,17 +602,13 @@ void ProfileChooserView::Init() { ...@@ -602,17 +602,13 @@ void ProfileChooserView::Init() {
void ProfileChooserView::OnAvatarMenuChanged( void ProfileChooserView::OnAvatarMenuChanged(
AvatarMenu* avatar_menu) { AvatarMenu* avatar_menu) {
// Do not refresh the avatar menu if the user is on a signin related view. if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER ||
if (view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN || view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) {
view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || // Refresh the view with the new menu. We can't just update the local copy
view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) { // as this may have been triggered by a sign out action, in which case
return; // the view is being destroyed.
ShowView(view_mode_, avatar_menu);
} }
// Refresh the view with the new menu. We can't just update the local copy
// as this may have been triggered by a sign out action, in which case
// the view is being destroyed.
ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu);
} }
void ProfileChooserView::OnRefreshTokenAvailable( void ProfileChooserView::OnRefreshTokenAvailable(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment