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

Side by Side Diff: chrome/browser/ui/views/profiles/new_avatar_button.cc

Issue 1136693002: Chrome user menu shouldn't close if a tab steals focus (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Chrome user menu shouldn't close if a tab steals focus Created 5 years, 7 months 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" 5 #include "chrome/browser/ui/views/profiles/new_avatar_button.h"
6 6
7 #include "base/win/windows_version.h" 7 #include "base/win/windows_version.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/profiles/profile_manager.h" 9 #include "chrome/browser/profiles/profile_manager.h"
10 #include "chrome/browser/profiles/profiles_state.h" 10 #include "chrome/browser/profiles/profiles_state.h"
(...skipping 30 matching lines...) Expand all
41 return border.Pass(); 41 return border.Pass();
42 } 42 }
43 43
44 } // namespace 44 } // namespace
45 45
46 NewAvatarButton::NewAvatarButton(views::ButtonListener* listener, 46 NewAvatarButton::NewAvatarButton(views::ButtonListener* listener,
47 AvatarButtonStyle button_style, 47 AvatarButtonStyle button_style,
48 Browser* browser) 48 Browser* browser)
49 : LabelButton(listener, base::string16()), 49 : LabelButton(listener, base::string16()),
50 browser_(browser), 50 browser_(browser),
51 has_auth_error_(false), 51 has_auth_error_(false) {
52 suppress_mouse_released_action_(false) {
53 set_triggerable_event_flags( 52 set_triggerable_event_flags(
54 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON); 53 ui::EF_LEFT_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON);
55 set_animate_on_state_change(false); 54 set_animate_on_state_change(false);
56 SetTextColor(views::Button::STATE_NORMAL, SK_ColorWHITE); 55 SetTextColor(views::Button::STATE_NORMAL, SK_ColorWHITE);
57 SetTextColor(views::Button::STATE_HOVERED, SK_ColorWHITE); 56 SetTextColor(views::Button::STATE_HOVERED, SK_ColorWHITE);
58 SetTextColor(views::Button::STATE_PRESSED, SK_ColorWHITE); 57 SetTextColor(views::Button::STATE_PRESSED, SK_ColorWHITE);
59 SetTextSubpixelRenderingEnabled(false); 58 SetTextSubpixelRenderingEnabled(false);
60 SetHorizontalAlignment(gfx::ALIGN_CENTER); 59 SetHorizontalAlignment(gfx::ALIGN_CENTER);
61 60
62 // The largest text height that fits in the button. If the font list height 61 // The largest text height that fits in the button. If the font list height
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 NewAvatarButton::~NewAvatarButton() { 112 NewAvatarButton::~NewAvatarButton() {
114 g_browser_process->profile_manager()-> 113 g_browser_process->profile_manager()->
115 GetProfileInfoCache().RemoveObserver(this); 114 GetProfileInfoCache().RemoveObserver(this);
116 SigninErrorController* error = 115 SigninErrorController* error =
117 profiles::GetSigninErrorController(browser_->profile()); 116 profiles::GetSigninErrorController(browser_->profile());
118 if (error) 117 if (error)
119 error->RemoveObserver(this); 118 error->RemoveObserver(this);
120 } 119 }
121 120
122 bool NewAvatarButton::OnMousePressed(const ui::MouseEvent& event) { 121 bool NewAvatarButton::OnMousePressed(const ui::MouseEvent& event) {
123 // Prevent the bubble from being re-shown if it's already showing. 122 if (ProfileChooserView::IsShowing())
124 suppress_mouse_released_action_ = ProfileChooserView::IsShowing(); 123 ProfileChooserView::Hide();
125 return LabelButton::OnMousePressed(event); 124 return LabelButton::OnMousePressed(event);
126 } 125 }
127 126
128 void NewAvatarButton::OnMouseReleased(const ui::MouseEvent& event) { 127 void NewAvatarButton::OnMouseReleased(const ui::MouseEvent& event) {
129 if (suppress_mouse_released_action_)
130 suppress_mouse_released_action_ = false;
131 else
Roger Tawa OOO till Jul 10th 2015/05/14 18:55:03 This change makes it so that clicking a second tim
gogerald1 2015/05/14 21:35:22 Done.
132 LabelButton::OnMouseReleased(event); 128 LabelButton::OnMouseReleased(event);
133 } 129 }
134 130
135 void NewAvatarButton::OnProfileAdded(const base::FilePath& profile_path) { 131 void NewAvatarButton::OnProfileAdded(const base::FilePath& profile_path) {
136 Update(); 132 Update();
137 } 133 }
138 134
139 void NewAvatarButton::OnProfileWasRemoved( 135 void NewAvatarButton::OnProfileWasRemoved(
140 const base::FilePath& profile_path, 136 const base::FilePath& profile_path,
141 const base::string16& profile_name) { 137 const base::string16& profile_name) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 SetImage(views::Button::STATE_NORMAL, gfx::ImageSkia()); 198 SetImage(views::Button::STATE_NORMAL, gfx::ImageSkia());
203 } 199 }
204 200
205 // If we are not using the generic button, then reset the spacing between 201 // If we are not using the generic button, then reset the spacing between
206 // the text and the possible authentication error icon. 202 // the text and the possible authentication error icon.
207 const int kDefaultImageTextSpacing = 5; 203 const int kDefaultImageTextSpacing = 5;
208 SetImageLabelSpacing(use_generic_button ? 0 : kDefaultImageTextSpacing); 204 SetImageLabelSpacing(use_generic_button ? 0 : kDefaultImageTextSpacing);
209 205
210 PreferredSizeChanged(); 206 PreferredSizeChanged();
211 } 207 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698