OLD | NEW |
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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 #include "ui/views/controls/label.h" | 68 #include "ui/views/controls/label.h" |
69 #include "ui/views/controls/link.h" | 69 #include "ui/views/controls/link.h" |
70 #include "ui/views/controls/separator.h" | 70 #include "ui/views/controls/separator.h" |
71 #include "ui/views/controls/styled_label.h" | 71 #include "ui/views/controls/styled_label.h" |
72 #include "ui/views/controls/textfield/textfield.h" | 72 #include "ui/views/controls/textfield/textfield.h" |
73 #include "ui/views/controls/webview/webview.h" | 73 #include "ui/views/controls/webview/webview.h" |
74 #include "ui/views/layout/box_layout.h" | 74 #include "ui/views/layout/box_layout.h" |
75 #include "ui/views/layout/fill_layout.h" | 75 #include "ui/views/layout/fill_layout.h" |
76 #include "ui/views/layout/grid_layout.h" | 76 #include "ui/views/layout/grid_layout.h" |
77 #include "ui/views/layout/layout_constants.h" | 77 #include "ui/views/layout/layout_constants.h" |
| 78 #include "ui/views/style/platform_style.h" |
78 #include "ui/views/widget/widget.h" | 79 #include "ui/views/widget/widget.h" |
79 | 80 |
80 namespace { | 81 namespace { |
81 | 82 |
82 // Helpers -------------------------------------------------------------------- | 83 // Helpers -------------------------------------------------------------------- |
83 | 84 |
84 const int kFixedMenuWidth = 250; | 85 const int kFixedMenuWidth = 250; |
85 const int kButtonHeight = 32; | 86 const int kButtonHeight = 32; |
86 const int kPasswordCombinedFixedGaiaViewWidth = 360; | 87 const int kPasswordCombinedFixedGaiaViewWidth = 360; |
87 const int kFixedGaiaViewWidth = 448; | 88 const int kFixedGaiaViewWidth = 448; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 views::ImageButton::ALIGN_MIDDLE); | 148 views::ImageButton::ALIGN_MIDDLE); |
148 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 149 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
149 back_button->SetImage(views::ImageButton::STATE_NORMAL, | 150 back_button->SetImage(views::ImageButton::STATE_NORMAL, |
150 rb->GetImageSkiaNamed(IDR_BACK)); | 151 rb->GetImageSkiaNamed(IDR_BACK)); |
151 back_button->SetImage(views::ImageButton::STATE_HOVERED, | 152 back_button->SetImage(views::ImageButton::STATE_HOVERED, |
152 rb->GetImageSkiaNamed(IDR_BACK_H)); | 153 rb->GetImageSkiaNamed(IDR_BACK_H)); |
153 back_button->SetImage(views::ImageButton::STATE_PRESSED, | 154 back_button->SetImage(views::ImageButton::STATE_PRESSED, |
154 rb->GetImageSkiaNamed(IDR_BACK_P)); | 155 rb->GetImageSkiaNamed(IDR_BACK_P)); |
155 back_button->SetImage(views::ImageButton::STATE_DISABLED, | 156 back_button->SetImage(views::ImageButton::STATE_DISABLED, |
156 rb->GetImageSkiaNamed(IDR_BACK_D)); | 157 rb->GetImageSkiaNamed(IDR_BACK_D)); |
157 back_button->SetFocusable(true); | 158 views::PlatformStyle::ConfigureFocus(views::PlatformStyle::CONTROL::BUTTON, |
| 159 back_button); |
158 return back_button; | 160 return back_button; |
159 } | 161 } |
160 | 162 |
161 // BackgroundColorHoverButton ------------------------------------------------- | 163 // BackgroundColorHoverButton ------------------------------------------------- |
162 | 164 |
163 // A custom button that allows for setting a background color when hovered over. | 165 // A custom button that allows for setting a background color when hovered over. |
164 class BackgroundColorHoverButton : public views::LabelButton { | 166 class BackgroundColorHoverButton : public views::LabelButton { |
165 public: | 167 public: |
166 BackgroundColorHoverButton(views::ButtonListener* listener, | 168 BackgroundColorHoverButton(views::ButtonListener* listener, |
167 const base::string16& text, | 169 const base::string16& text, |
168 const gfx::ImageSkia& icon) | 170 const gfx::ImageSkia& icon) |
169 : views::LabelButton(listener, text) { | 171 : views::LabelButton(listener, text) { |
170 SetImageLabelSpacing(views::kItemLabelSpacing); | 172 SetImageLabelSpacing(views::kItemLabelSpacing); |
171 SetBorder(views::Border::CreateEmptyBorder( | 173 SetBorder(views::Border::CreateEmptyBorder( |
172 0, views::kButtonHEdgeMarginNew, 0, views::kButtonHEdgeMarginNew)); | 174 0, views::kButtonHEdgeMarginNew, 0, views::kButtonHEdgeMarginNew)); |
173 SetMinSize(gfx::Size(0, | 175 SetMinSize(gfx::Size(0, |
174 kButtonHeight + views::kRelatedControlVerticalSpacing)); | 176 kButtonHeight + views::kRelatedControlVerticalSpacing)); |
175 SetImage(STATE_NORMAL, icon); | 177 SetImage(STATE_NORMAL, icon); |
176 SetFocusable(true); | 178 views::PlatformStyle::ConfigureFocus(views::PlatformStyle::CONTROL::BUTTON, |
| 179 this); |
177 } | 180 } |
178 | 181 |
179 ~BackgroundColorHoverButton() override {} | 182 ~BackgroundColorHoverButton() override {} |
180 | 183 |
181 private: | 184 private: |
182 // views::LabelButton: | 185 // views::LabelButton: |
183 void OnPaint(gfx::Canvas* canvas) override { | 186 void OnPaint(gfx::Canvas* canvas) override { |
184 if ((state() == STATE_PRESSED) || | 187 if ((state() == STATE_PRESSED) || |
185 (state() == STATE_HOVERED)) { | 188 (state() == STATE_HOVERED)) { |
186 canvas->DrawColor(GetNativeTheme()->GetSystemColor( | 189 canvas->DrawColor(GetNativeTheme()->GetSystemColor( |
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1388 } else { | 1391 } else { |
1389 // Badge the email address if there's an authentication error. | 1392 // Badge the email address if there's an authentication error. |
1390 if (HasAuthError(browser_->profile())) { | 1393 if (HasAuthError(browser_->profile())) { |
1391 auth_error_email_button_ = | 1394 auth_error_email_button_ = |
1392 new RightAlignedIconLabelButton(this, avatar_item.username); | 1395 new RightAlignedIconLabelButton(this, avatar_item.username); |
1393 auth_error_email_button_->SetElideBehavior(gfx::ELIDE_EMAIL); | 1396 auth_error_email_button_->SetElideBehavior(gfx::ELIDE_EMAIL); |
1394 auth_error_email_button_->SetImage( | 1397 auth_error_email_button_->SetImage( |
1395 views::LabelButton::STATE_NORMAL, | 1398 views::LabelButton::STATE_NORMAL, |
1396 gfx::CreateVectorIcon(gfx::VectorIconId::WARNING, 18, | 1399 gfx::CreateVectorIcon(gfx::VectorIconId::WARNING, 18, |
1397 gfx::kChromeIconGrey)); | 1400 gfx::kChromeIconGrey)); |
1398 | 1401 views::PlatformStyle::ConfigureFocus( |
1399 auth_error_email_button_->SetFocusable(true); | 1402 views::PlatformStyle::CONTROL::BUTTON, auth_error_email_button_); |
1400 gfx::Insets insets = | 1403 gfx::Insets insets = |
1401 views::LabelButtonAssetBorder::GetDefaultInsetsForStyle( | 1404 views::LabelButtonAssetBorder::GetDefaultInsetsForStyle( |
1402 views::Button::STYLE_TEXTBUTTON); | 1405 views::Button::STYLE_TEXTBUTTON); |
1403 auth_error_email_button_->SetBorder(views::Border::CreateEmptyBorder( | 1406 auth_error_email_button_->SetBorder(views::Border::CreateEmptyBorder( |
1404 insets.top(), insets.left(), insets.bottom(), insets.right())); | 1407 insets.top(), insets.left(), insets.bottom(), insets.right())); |
1405 layout->AddView(auth_error_email_button_); | 1408 layout->AddView(auth_error_email_button_); |
1406 } else { | 1409 } else { |
1407 // Add a small padding between the email button and the profile name. | 1410 // Add a small padding between the email button and the profile name. |
1408 layout->StartRowWithPadding(1, 0, 0, 2); | 1411 layout->StartRowWithPadding(1, 0, 0, 2); |
1409 views::Label* email_label = new views::Label(avatar_item.username); | 1412 views::Label* email_label = new views::Label(avatar_item.username); |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1878 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1881 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1879 IncognitoModePrefs::DISABLED; | 1882 IncognitoModePrefs::DISABLED; |
1880 return incognito_available && !browser_->profile()->IsGuestSession(); | 1883 return incognito_available && !browser_->profile()->IsGuestSession(); |
1881 } | 1884 } |
1882 | 1885 |
1883 void ProfileChooserView::PostActionPerformed( | 1886 void ProfileChooserView::PostActionPerformed( |
1884 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1887 ProfileMetrics::ProfileDesktopMenu action_performed) { |
1885 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1888 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
1886 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1889 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
1887 } | 1890 } |
OLD | NEW |