| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 #include "ui/views/controls/label.h" | 69 #include "ui/views/controls/label.h" |
| 70 #include "ui/views/controls/link.h" | 70 #include "ui/views/controls/link.h" |
| 71 #include "ui/views/controls/separator.h" | 71 #include "ui/views/controls/separator.h" |
| 72 #include "ui/views/controls/styled_label.h" | 72 #include "ui/views/controls/styled_label.h" |
| 73 #include "ui/views/controls/textfield/textfield.h" | 73 #include "ui/views/controls/textfield/textfield.h" |
| 74 #include "ui/views/controls/webview/webview.h" | 74 #include "ui/views/controls/webview/webview.h" |
| 75 #include "ui/views/layout/box_layout.h" | 75 #include "ui/views/layout/box_layout.h" |
| 76 #include "ui/views/layout/fill_layout.h" | 76 #include "ui/views/layout/fill_layout.h" |
| 77 #include "ui/views/layout/grid_layout.h" | 77 #include "ui/views/layout/grid_layout.h" |
| 78 #include "ui/views/layout/layout_constants.h" | 78 #include "ui/views/layout/layout_constants.h" |
| 79 #include "ui/views/style/platform_style.h" |
| 79 #include "ui/views/widget/widget.h" | 80 #include "ui/views/widget/widget.h" |
| 80 | 81 |
| 81 namespace { | 82 namespace { |
| 82 | 83 |
| 83 // Helpers -------------------------------------------------------------------- | 84 // Helpers -------------------------------------------------------------------- |
| 84 | 85 |
| 85 const int kFixedMenuWidth = 250; | 86 const int kFixedMenuWidth = 250; |
| 86 const int kButtonHeight = 32; | 87 const int kButtonHeight = 32; |
| 87 const int kPasswordCombinedFixedGaiaViewWidth = 360; | 88 const int kPasswordCombinedFixedGaiaViewWidth = 360; |
| 88 const int kFixedGaiaViewWidth = 448; | 89 const int kFixedGaiaViewWidth = 448; |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 views::ImageButton::ALIGN_MIDDLE); | 149 views::ImageButton::ALIGN_MIDDLE); |
| 149 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 150 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| 150 back_button->SetImage(views::ImageButton::STATE_NORMAL, | 151 back_button->SetImage(views::ImageButton::STATE_NORMAL, |
| 151 rb->GetImageSkiaNamed(IDR_BACK)); | 152 rb->GetImageSkiaNamed(IDR_BACK)); |
| 152 back_button->SetImage(views::ImageButton::STATE_HOVERED, | 153 back_button->SetImage(views::ImageButton::STATE_HOVERED, |
| 153 rb->GetImageSkiaNamed(IDR_BACK_H)); | 154 rb->GetImageSkiaNamed(IDR_BACK_H)); |
| 154 back_button->SetImage(views::ImageButton::STATE_PRESSED, | 155 back_button->SetImage(views::ImageButton::STATE_PRESSED, |
| 155 rb->GetImageSkiaNamed(IDR_BACK_P)); | 156 rb->GetImageSkiaNamed(IDR_BACK_P)); |
| 156 back_button->SetImage(views::ImageButton::STATE_DISABLED, | 157 back_button->SetImage(views::ImageButton::STATE_DISABLED, |
| 157 rb->GetImageSkiaNamed(IDR_BACK_D)); | 158 rb->GetImageSkiaNamed(IDR_BACK_D)); |
| 158 back_button->SetFocusable(true); | 159 views::PlatformStyle::SetControlStyleFocus(back_button); |
| 159 return back_button; | 160 return back_button; |
| 160 } | 161 } |
| 161 | 162 |
| 162 // BackgroundColorHoverButton ------------------------------------------------- | 163 // BackgroundColorHoverButton ------------------------------------------------- |
| 163 | 164 |
| 164 // 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. |
| 165 class BackgroundColorHoverButton : public views::LabelButton { | 166 class BackgroundColorHoverButton : public views::LabelButton { |
| 166 public: | 167 public: |
| 167 BackgroundColorHoverButton(views::ButtonListener* listener, | 168 BackgroundColorHoverButton(views::ButtonListener* listener, |
| 168 const base::string16& text, | 169 const base::string16& text, |
| 169 const gfx::ImageSkia& icon) | 170 const gfx::ImageSkia& icon) |
| 170 : views::LabelButton(listener, text) { | 171 : views::LabelButton(listener, text) { |
| 171 SetImageLabelSpacing(views::kItemLabelSpacing); | 172 SetImageLabelSpacing(views::kItemLabelSpacing); |
| 172 SetBorder(views::Border::CreateEmptyBorder( | 173 SetBorder(views::Border::CreateEmptyBorder( |
| 173 0, views::kButtonHEdgeMarginNew, 0, views::kButtonHEdgeMarginNew)); | 174 0, views::kButtonHEdgeMarginNew, 0, views::kButtonHEdgeMarginNew)); |
| 174 SetMinSize(gfx::Size(0, | 175 SetMinSize(gfx::Size(0, |
| 175 kButtonHeight + views::kRelatedControlVerticalSpacing)); | 176 kButtonHeight + views::kRelatedControlVerticalSpacing)); |
| 176 SetImage(STATE_NORMAL, icon); | 177 SetImage(STATE_NORMAL, icon); |
| 177 SetFocusable(true); | 178 views::PlatformStyle::SetControlStyleFocus(this); |
| 178 } | 179 } |
| 179 | 180 |
| 180 ~BackgroundColorHoverButton() override {} | 181 ~BackgroundColorHoverButton() override {} |
| 181 | 182 |
| 182 private: | 183 private: |
| 183 // views::LabelButton: | 184 // views::LabelButton: |
| 184 void OnPaint(gfx::Canvas* canvas) override { | 185 void OnPaint(gfx::Canvas* canvas) override { |
| 185 if ((state() == STATE_PRESSED) || | 186 if ((state() == STATE_PRESSED) || |
| 186 (state() == STATE_HOVERED)) { | 187 (state() == STATE_HOVERED)) { |
| 187 canvas->DrawColor(GetNativeTheme()->GetSystemColor( | 188 canvas->DrawColor(GetNativeTheme()->GetSystemColor( |
| (...skipping 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1379 // Badge the email address if there's an authentication error. | 1380 // Badge the email address if there's an authentication error. |
| 1380 if (HasAuthError(browser_->profile())) { | 1381 if (HasAuthError(browser_->profile())) { |
| 1381 auth_error_email_button_ = | 1382 auth_error_email_button_ = |
| 1382 new RightAlignedIconLabelButton(this, avatar_item.username); | 1383 new RightAlignedIconLabelButton(this, avatar_item.username); |
| 1383 auth_error_email_button_->SetElideBehavior(gfx::ELIDE_EMAIL); | 1384 auth_error_email_button_->SetElideBehavior(gfx::ELIDE_EMAIL); |
| 1384 auth_error_email_button_->SetImage( | 1385 auth_error_email_button_->SetImage( |
| 1385 views::LabelButton::STATE_NORMAL, | 1386 views::LabelButton::STATE_NORMAL, |
| 1386 gfx::CreateVectorIcon(gfx::VectorIconId::WARNING, 18, | 1387 gfx::CreateVectorIcon(gfx::VectorIconId::WARNING, 18, |
| 1387 gfx::kChromeIconGrey)); | 1388 gfx::kChromeIconGrey)); |
| 1388 | 1389 |
| 1389 auth_error_email_button_->SetFocusable(true); | 1390 views::PlatformStyle::SetControlStyleFocus(auth_error_email_button_); |
| 1390 gfx::Insets insets = | 1391 gfx::Insets insets = |
| 1391 views::LabelButtonAssetBorder::GetDefaultInsetsForStyle( | 1392 views::LabelButtonAssetBorder::GetDefaultInsetsForStyle( |
| 1392 views::Button::STYLE_TEXTBUTTON); | 1393 views::Button::STYLE_TEXTBUTTON); |
| 1393 auth_error_email_button_->SetBorder(views::Border::CreateEmptyBorder( | 1394 auth_error_email_button_->SetBorder(views::Border::CreateEmptyBorder( |
| 1394 insets.top(), insets.left(), insets.bottom(), insets.right())); | 1395 insets.top(), insets.left(), insets.bottom(), insets.right())); |
| 1395 layout->AddView(auth_error_email_button_); | 1396 layout->AddView(auth_error_email_button_); |
| 1396 } else { | 1397 } else { |
| 1397 // Add a small padding between the email button and the profile name. | 1398 // Add a small padding between the email button and the profile name. |
| 1398 layout->StartRowWithPadding(1, 0, 0, 2); | 1399 layout->StartRowWithPadding(1, 0, 0, 2); |
| 1399 views::Label* email_label = new views::Label(avatar_item.username); | 1400 views::Label* email_label = new views::Label(avatar_item.username); |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1868 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1869 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
| 1869 IncognitoModePrefs::DISABLED; | 1870 IncognitoModePrefs::DISABLED; |
| 1870 return incognito_available && !browser_->profile()->IsGuestSession(); | 1871 return incognito_available && !browser_->profile()->IsGuestSession(); |
| 1871 } | 1872 } |
| 1872 | 1873 |
| 1873 void ProfileChooserView::PostActionPerformed( | 1874 void ProfileChooserView::PostActionPerformed( |
| 1874 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1875 ProfileMetrics::ProfileDesktopMenu action_performed) { |
| 1875 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1876 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
| 1876 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1877 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
| 1877 } | 1878 } |
| OLD | NEW |