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

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

Issue 2589863002: Don't request focus on press for buttons in profile menu. (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/profile_chooser_view.h" 5 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h"
6 6
7 #include "base/macros.h" 7 #include "base/macros.h"
8 #include "base/metrics/user_metrics.h" 8 #include "base/metrics/user_metrics.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 170 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
171 back_button->SetImage(views::ImageButton::STATE_NORMAL, 171 back_button->SetImage(views::ImageButton::STATE_NORMAL,
172 rb->GetImageSkiaNamed(IDR_BACK)); 172 rb->GetImageSkiaNamed(IDR_BACK));
173 back_button->SetImage(views::ImageButton::STATE_HOVERED, 173 back_button->SetImage(views::ImageButton::STATE_HOVERED,
174 rb->GetImageSkiaNamed(IDR_BACK_H)); 174 rb->GetImageSkiaNamed(IDR_BACK_H));
175 back_button->SetImage(views::ImageButton::STATE_PRESSED, 175 back_button->SetImage(views::ImageButton::STATE_PRESSED,
176 rb->GetImageSkiaNamed(IDR_BACK_P)); 176 rb->GetImageSkiaNamed(IDR_BACK_P));
177 back_button->SetImage(views::ImageButton::STATE_DISABLED, 177 back_button->SetImage(views::ImageButton::STATE_DISABLED,
178 rb->GetImageSkiaNamed(IDR_BACK_D)); 178 rb->GetImageSkiaNamed(IDR_BACK_D));
179 back_button->SetFocusForPlatform(); 179 back_button->SetFocusForPlatform();
180 back_button->set_request_focus_on_press(true);
181 return back_button; 180 return back_button;
182 } 181 }
183 182
184 // BackgroundColorHoverButton ------------------------------------------------- 183 // BackgroundColorHoverButton -------------------------------------------------
185 184
186 // A custom button that allows for setting a background color when hovered over. 185 // A custom button that allows for setting a background color when hovered over.
187 class BackgroundColorHoverButton : public views::LabelButton { 186 class BackgroundColorHoverButton : public views::LabelButton {
188 public: 187 public:
189 BackgroundColorHoverButton(views::ButtonListener* listener, 188 BackgroundColorHoverButton(views::ButtonListener* listener,
190 const base::string16& text) 189 const base::string16& text)
191 : views::LabelButton(listener, text) { 190 : views::LabelButton(listener, text) {
192 SetImageLabelSpacing(switches::IsMaterialDesignUserMenu() 191 SetImageLabelSpacing(switches::IsMaterialDesignUserMenu()
193 ? (kMaterialMenuEdgeMargin - 2) 192 ? (kMaterialMenuEdgeMargin - 2)
194 : views::kItemLabelSpacing); 193 : views::kItemLabelSpacing);
195 const int button_margin = switches::IsMaterialDesignUserMenu() 194 const int button_margin = switches::IsMaterialDesignUserMenu()
196 ? kMaterialMenuEdgeMargin 195 ? kMaterialMenuEdgeMargin
197 : views::kButtonHEdgeMarginNew; 196 : views::kButtonHEdgeMarginNew;
198 SetBorder(views::CreateEmptyBorder(0, button_margin, 0, button_margin)); 197 SetBorder(views::CreateEmptyBorder(0, button_margin, 0, button_margin));
199 SetFocusForPlatform(); 198 SetFocusForPlatform();
200 set_request_focus_on_press(true);
201 199
202 if (switches::IsMaterialDesignUserMenu()) { 200 if (switches::IsMaterialDesignUserMenu()) {
203 label()->SetHandlesTooltips(false); 201 label()->SetHandlesTooltips(false);
204 } 202 }
205 } 203 }
206 204
207 BackgroundColorHoverButton(views::ButtonListener* listener, 205 BackgroundColorHoverButton(views::ButtonListener* listener,
208 const base::string16& text, 206 const base::string16& text,
209 const gfx::ImageSkia& icon) 207 const gfx::ImageSkia& icon)
210 : BackgroundColorHoverButton(listener, text) { 208 : BackgroundColorHoverButton(listener, text) {
(...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1616 // Badge the email address if there's an authentication error. 1614 // Badge the email address if there's an authentication error.
1617 if (HasAuthError(browser_->profile())) { 1615 if (HasAuthError(browser_->profile())) {
1618 auth_error_email_button_ = 1616 auth_error_email_button_ =
1619 new RightAlignedIconLabelButton(this, avatar_item.username); 1617 new RightAlignedIconLabelButton(this, avatar_item.username);
1620 auth_error_email_button_->SetElideBehavior(gfx::ELIDE_EMAIL); 1618 auth_error_email_button_->SetElideBehavior(gfx::ELIDE_EMAIL);
1621 auth_error_email_button_->SetImage( 1619 auth_error_email_button_->SetImage(
1622 views::LabelButton::STATE_NORMAL, 1620 views::LabelButton::STATE_NORMAL,
1623 gfx::CreateVectorIcon(gfx::VectorIconId::WARNING, 18, 1621 gfx::CreateVectorIcon(gfx::VectorIconId::WARNING, 18,
1624 gfx::kChromeIconGrey)); 1622 gfx::kChromeIconGrey));
1625 auth_error_email_button_->SetFocusForPlatform(); 1623 auth_error_email_button_->SetFocusForPlatform();
1626 auth_error_email_button_->set_request_focus_on_press(true);
1627 gfx::Insets insets = 1624 gfx::Insets insets =
1628 views::LabelButtonAssetBorder::GetDefaultInsetsForStyle( 1625 views::LabelButtonAssetBorder::GetDefaultInsetsForStyle(
1629 views::Button::STYLE_TEXTBUTTON); 1626 views::Button::STYLE_TEXTBUTTON);
1630 auth_error_email_button_->SetBorder(views::CreateEmptyBorder( 1627 auth_error_email_button_->SetBorder(views::CreateEmptyBorder(
1631 insets.top(), insets.left(), insets.bottom(), insets.right())); 1628 insets.top(), insets.left(), insets.bottom(), insets.right()));
1632 layout->AddView(auth_error_email_button_); 1629 layout->AddView(auth_error_email_button_);
1633 } else { 1630 } else {
1634 // Add a small padding between the email button and the profile name. 1631 // Add a small padding between the email button and the profile name.
1635 layout->StartRowWithPadding(1, 0, 0, 2); 1632 layout->StartRowWithPadding(1, 0, 0, 2);
1636 views::Label* email_label = new views::Label(avatar_item.username); 1633 views::Label* email_label = new views::Label(avatar_item.username);
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after
2311 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 2308 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
2312 IncognitoModePrefs::DISABLED; 2309 IncognitoModePrefs::DISABLED;
2313 return incognito_available && !browser_->profile()->IsGuestSession(); 2310 return incognito_available && !browser_->profile()->IsGuestSession();
2314 } 2311 }
2315 2312
2316 void ProfileChooserView::PostActionPerformed( 2313 void ProfileChooserView::PostActionPerformed(
2317 ProfileMetrics::ProfileDesktopMenu action_performed) { 2314 ProfileMetrics::ProfileDesktopMenu action_performed) {
2318 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 2315 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
2319 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 2316 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
2320 } 2317 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698