Commit ffb81aba authored by Bret Sepulveda's avatar Bret Sepulveda Committed by Commit Bot

Fix first profile being highlighted when the avatar button is clicked.

When the avatar button is activated using the keyboard the first profile
should be highlighted. But the new Refresh avatar button was using a
code path that always indicated the keyboard was used.

As a short-term fix, this patch avoids that code path entirely.

Bug: 849810
Change-Id: I87c32cf76870d92911f227afd74a9dd1e201a4b2
Reviewed-on: https://chromium-review.googlesource.com/1119385Reviewed-by: default avatarPeter Boström <pbos@chromium.org>
Commit-Queue: Bret Sepulveda <bsep@chromium.org>
Cr-Commit-Position: refs/heads/master@{#571333}
parent 023d8009
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "chrome/browser/signin/signin_ui_util.h" #include "chrome/browser/signin/signin_ui_util.h"
#include "chrome/browser/sync/sync_ui_util.h" #include "chrome/browser/sync/sync_ui_util.h"
#include "chrome/browser/themes/theme_properties.h" #include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/layout_constants.h" #include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/view_ids.h" #include "chrome/browser/ui/view_ids.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
...@@ -33,10 +34,10 @@ ...@@ -33,10 +34,10 @@
#include "ui/gfx/paint_vector_icon.h" #include "ui/gfx/paint_vector_icon.h"
#include "ui/views/controls/button/label_button_border.h" #include "ui/views/controls/button/label_button_border.h"
AvatarToolbarButton::AvatarToolbarButton(Profile* profile, AvatarToolbarButton::AvatarToolbarButton(Browser* browser)
views::ButtonListener* listener) : ToolbarButton(nullptr, nullptr),
: ToolbarButton(listener, nullptr), browser_(browser),
profile_(profile), profile_(browser_->profile()),
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
error_controller_(this, profile_), error_controller_(this, profile_),
#endif // !defined(OS_CHROMEOS) #endif // !defined(OS_CHROMEOS)
...@@ -99,6 +100,17 @@ void AvatarToolbarButton::UpdateTooltipText() { ...@@ -99,6 +100,17 @@ void AvatarToolbarButton::UpdateTooltipText() {
SetTooltipText(GetAvatarTooltipText()); SetTooltipText(GetAvatarTooltipText());
} }
void AvatarToolbarButton::NotifyClick(const ui::Event& event) {
Button::NotifyClick(event);
// TODO(bsep): Other toolbar buttons have ToolbarView as a listener and let it
// call ExecuteCommandWithDisposition on their behalf. Unfortunately, it's not
// possible to plumb IsKeyEvent through, so this has to be a special case.
browser_->window()->ShowAvatarBubbleFromAvatarButton(
BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT, signin::ManageAccountsParams(),
signin_metrics::AccessPoint::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN,
event.IsKeyEvent());
}
void AvatarToolbarButton::OnAvatarErrorChanged() { void AvatarToolbarButton::OnAvatarErrorChanged() {
UpdateIcon(); UpdateIcon();
UpdateTooltipText(); UpdateTooltipText();
......
...@@ -14,6 +14,9 @@ ...@@ -14,6 +14,9 @@
#include "chrome/browser/ui/views/toolbar/toolbar_button.h" #include "chrome/browser/ui/views/toolbar/toolbar_button.h"
#include "components/signin/core/browser/account_tracker_service.h" #include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/gaia_cookie_manager_service.h" #include "components/signin/core/browser/gaia_cookie_manager_service.h"
#include "ui/events/event.h"
class Browser;
class AvatarToolbarButton : public ToolbarButton, class AvatarToolbarButton : public ToolbarButton,
public AvatarButtonErrorControllerDelegate, public AvatarButtonErrorControllerDelegate,
...@@ -21,7 +24,7 @@ class AvatarToolbarButton : public ToolbarButton, ...@@ -21,7 +24,7 @@ class AvatarToolbarButton : public ToolbarButton,
public GaiaCookieManagerService::Observer, public GaiaCookieManagerService::Observer,
public AccountTrackerService::Observer { public AccountTrackerService::Observer {
public: public:
AvatarToolbarButton(Profile* profile, views::ButtonListener* listener); explicit AvatarToolbarButton(Browser* browser);
~AvatarToolbarButton() override; ~AvatarToolbarButton() override;
void UpdateIcon(); void UpdateIcon();
...@@ -30,6 +33,9 @@ class AvatarToolbarButton : public ToolbarButton, ...@@ -30,6 +33,9 @@ class AvatarToolbarButton : public ToolbarButton,
private: private:
enum class SyncState { kNormal, kPaused, kError }; enum class SyncState { kNormal, kPaused, kError };
// ToolbarButton:
void NotifyClick(const ui::Event& event) override;
// AvatarButtonErrorControllerDelegate: // AvatarButtonErrorControllerDelegate:
void OnAvatarErrorChanged() override; void OnAvatarErrorChanged() override;
...@@ -62,6 +68,7 @@ class AvatarToolbarButton : public ToolbarButton, ...@@ -62,6 +68,7 @@ class AvatarToolbarButton : public ToolbarButton,
gfx::Image GetIconImageFromProfile() const; gfx::Image GetIconImageFromProfile() const;
SyncState GetSyncState(); SyncState GetSyncState();
Browser* const browser_;
Profile* const profile_; Profile* const profile_;
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
......
...@@ -205,7 +205,7 @@ void ToolbarView::Init() { ...@@ -205,7 +205,7 @@ void ToolbarView::Init() {
browser_->profile()->IsGuestSession(); browser_->profile()->IsGuestSession();
#endif // !defined(OS_CHROMEOS) #endif // !defined(OS_CHROMEOS)
if (show_avatar_toolbar_button) if (show_avatar_toolbar_button)
avatar_ = new AvatarToolbarButton(browser_->profile(), this); avatar_ = new AvatarToolbarButton(browser_);
} }
app_menu_button_ = new BrowserAppMenuButton(this); app_menu_button_ = new BrowserAppMenuButton(this);
......
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