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

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

Issue 1894383002: MacViews: Implement Full Keyboard Access. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@SetFocusBehavior
Patch Set: Rebased Created 4 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/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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 views::ImageButton::ALIGN_MIDDLE); 147 views::ImageButton::ALIGN_MIDDLE);
148 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 148 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
149 back_button->SetImage(views::ImageButton::STATE_NORMAL, 149 back_button->SetImage(views::ImageButton::STATE_NORMAL,
150 rb->GetImageSkiaNamed(IDR_BACK)); 150 rb->GetImageSkiaNamed(IDR_BACK));
151 back_button->SetImage(views::ImageButton::STATE_HOVERED, 151 back_button->SetImage(views::ImageButton::STATE_HOVERED,
152 rb->GetImageSkiaNamed(IDR_BACK_H)); 152 rb->GetImageSkiaNamed(IDR_BACK_H));
153 back_button->SetImage(views::ImageButton::STATE_PRESSED, 153 back_button->SetImage(views::ImageButton::STATE_PRESSED,
154 rb->GetImageSkiaNamed(IDR_BACK_P)); 154 rb->GetImageSkiaNamed(IDR_BACK_P));
155 back_button->SetImage(views::ImageButton::STATE_DISABLED, 155 back_button->SetImage(views::ImageButton::STATE_DISABLED,
156 rb->GetImageSkiaNamed(IDR_BACK_D)); 156 rb->GetImageSkiaNamed(IDR_BACK_D));
157 back_button->SetFocusBehavior(views::View::FocusBehavior::ALWAYS); 157 views::Button::ConfigureDefaultFocus(back_button);
158 return back_button; 158 return back_button;
159 } 159 }
160 160
161 // BackgroundColorHoverButton ------------------------------------------------- 161 // BackgroundColorHoverButton -------------------------------------------------
162 162
163 // A custom button that allows for setting a background color when hovered over. 163 // A custom button that allows for setting a background color when hovered over.
164 class BackgroundColorHoverButton : public views::LabelButton { 164 class BackgroundColorHoverButton : public views::LabelButton {
165 public: 165 public:
166 BackgroundColorHoverButton(views::ButtonListener* listener, 166 BackgroundColorHoverButton(views::ButtonListener* listener,
167 const base::string16& text, 167 const base::string16& text,
168 const gfx::ImageSkia& icon) 168 const gfx::ImageSkia& icon)
169 : views::LabelButton(listener, text) { 169 : views::LabelButton(listener, text) {
170 SetImageLabelSpacing(views::kItemLabelSpacing); 170 SetImageLabelSpacing(views::kItemLabelSpacing);
171 SetBorder(views::Border::CreateEmptyBorder( 171 SetBorder(views::Border::CreateEmptyBorder(
172 0, views::kButtonHEdgeMarginNew, 0, views::kButtonHEdgeMarginNew)); 172 0, views::kButtonHEdgeMarginNew, 0, views::kButtonHEdgeMarginNew));
173 SetMinSize(gfx::Size(0, 173 SetMinSize(gfx::Size(0,
174 kButtonHeight + views::kRelatedControlVerticalSpacing)); 174 kButtonHeight + views::kRelatedControlVerticalSpacing));
175 SetImage(STATE_NORMAL, icon); 175 SetImage(STATE_NORMAL, icon);
176 SetFocusBehavior(FocusBehavior::ALWAYS); 176 Button::ConfigureDefaultFocus(this);
177 } 177 }
178 178
179 ~BackgroundColorHoverButton() override {} 179 ~BackgroundColorHoverButton() override {}
180 180
181 private: 181 private:
182 // views::LabelButton: 182 // views::LabelButton:
183 void OnPaint(gfx::Canvas* canvas) override { 183 void OnPaint(gfx::Canvas* canvas) override {
184 if ((state() == STATE_PRESSED) || 184 if ((state() == STATE_PRESSED) ||
185 (state() == STATE_HOVERED)) { 185 (state() == STATE_HOVERED)) {
186 canvas->DrawColor(GetNativeTheme()->GetSystemColor( 186 canvas->DrawColor(GetNativeTheme()->GetSystemColor(
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 } else { 1391 } else {
1392 // Badge the email address if there's an authentication error. 1392 // Badge the email address if there's an authentication error.
1393 if (HasAuthError(browser_->profile())) { 1393 if (HasAuthError(browser_->profile())) {
1394 auth_error_email_button_ = 1394 auth_error_email_button_ =
1395 new RightAlignedIconLabelButton(this, avatar_item.username); 1395 new RightAlignedIconLabelButton(this, avatar_item.username);
1396 auth_error_email_button_->SetElideBehavior(gfx::ELIDE_EMAIL); 1396 auth_error_email_button_->SetElideBehavior(gfx::ELIDE_EMAIL);
1397 auth_error_email_button_->SetImage( 1397 auth_error_email_button_->SetImage(
1398 views::LabelButton::STATE_NORMAL, 1398 views::LabelButton::STATE_NORMAL,
1399 gfx::CreateVectorIcon(gfx::VectorIconId::WARNING, 18, 1399 gfx::CreateVectorIcon(gfx::VectorIconId::WARNING, 18,
1400 gfx::kChromeIconGrey)); 1400 gfx::kChromeIconGrey));
1401 1401 views::Button::ConfigureDefaultFocus(auth_error_email_button_);
1402 auth_error_email_button_->SetFocusBehavior(FocusBehavior::ALWAYS);
1403 gfx::Insets insets = 1402 gfx::Insets insets =
1404 views::LabelButtonAssetBorder::GetDefaultInsetsForStyle( 1403 views::LabelButtonAssetBorder::GetDefaultInsetsForStyle(
1405 views::Button::STYLE_TEXTBUTTON); 1404 views::Button::STYLE_TEXTBUTTON);
1406 auth_error_email_button_->SetBorder(views::Border::CreateEmptyBorder( 1405 auth_error_email_button_->SetBorder(views::Border::CreateEmptyBorder(
1407 insets.top(), insets.left(), insets.bottom(), insets.right())); 1406 insets.top(), insets.left(), insets.bottom(), insets.right()));
1408 layout->AddView(auth_error_email_button_); 1407 layout->AddView(auth_error_email_button_);
1409 } else { 1408 } else {
1410 // Add a small padding between the email button and the profile name. 1409 // Add a small padding between the email button and the profile name.
1411 layout->StartRowWithPadding(1, 0, 0, 2); 1410 layout->StartRowWithPadding(1, 0, 0, 2);
1412 views::Label* email_label = new views::Label(avatar_item.username); 1411 views::Label* email_label = new views::Label(avatar_item.username);
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
1881 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 1880 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
1882 IncognitoModePrefs::DISABLED; 1881 IncognitoModePrefs::DISABLED;
1883 return incognito_available && !browser_->profile()->IsGuestSession(); 1882 return incognito_available && !browser_->profile()->IsGuestSession();
1884 } 1883 }
1885 1884
1886 void ProfileChooserView::PostActionPerformed( 1885 void ProfileChooserView::PostActionPerformed(
1887 ProfileMetrics::ProfileDesktopMenu action_performed) { 1886 ProfileMetrics::ProfileDesktopMenu action_performed) {
1888 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 1887 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
1889 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 1888 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
1890 } 1889 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698