| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/profile_chooser_view.h" | 5 #include "chrome/browser/ui/views/profile_chooser_view.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/profiles/profile_info_util.h" | 9 #include "chrome/browser/profiles/profile_info_util.h" |
| 10 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 BackgroundColorHoverButton::BackgroundColorHoverButton( | 112 BackgroundColorHoverButton::BackgroundColorHoverButton( |
| 113 views::ButtonListener* listener, | 113 views::ButtonListener* listener, |
| 114 const base::string16& text, | 114 const base::string16& text, |
| 115 const gfx::ImageSkia& normal_icon, | 115 const gfx::ImageSkia& normal_icon, |
| 116 const gfx::ImageSkia& hover_icon) | 116 const gfx::ImageSkia& hover_icon) |
| 117 : views::TextButton(listener, text) { | 117 : views::TextButton(listener, text) { |
| 118 scoped_ptr<views::TextButtonBorder> text_button_border( | 118 scoped_ptr<views::TextButtonBorder> text_button_border( |
| 119 new views::TextButtonBorder()); | 119 new views::TextButtonBorder()); |
| 120 text_button_border->SetInsets(gfx::Insets(0, views::kButtonHEdgeMarginNew, | 120 text_button_border->SetInsets(gfx::Insets(0, views::kButtonHEdgeMarginNew, |
| 121 0, views::kButtonHEdgeMarginNew)); | 121 0, views::kButtonHEdgeMarginNew)); |
| 122 set_border(text_button_border.release()); | 122 SetBorder(text_button_border.PassAs<views::Border>()); |
| 123 set_min_height(kButtonHeight); | 123 set_min_height(kButtonHeight); |
| 124 set_icon_text_spacing(views::kItemLabelSpacing); | 124 set_icon_text_spacing(views::kItemLabelSpacing); |
| 125 SetIcon(normal_icon); | 125 SetIcon(normal_icon); |
| 126 SetHoverIcon(hover_icon); | 126 SetHoverIcon(hover_icon); |
| 127 SetPushedIcon(hover_icon); | 127 SetPushedIcon(hover_icon); |
| 128 SetHoverColor(GetNativeTheme()->GetSystemColor( | 128 SetHoverColor(GetNativeTheme()->GetSystemColor( |
| 129 ui::NativeTheme::kColorId_SelectedMenuItemForegroundColor)); | 129 ui::NativeTheme::kColorId_SelectedMenuItemForegroundColor)); |
| 130 OnHighlightStateChanged(); | 130 OnHighlightStateChanged(); |
| 131 } | 131 } |
| 132 | 132 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 178 |
| 179 if (!is_editing_allowed) | 179 if (!is_editing_allowed) |
| 180 return; | 180 return; |
| 181 | 181 |
| 182 set_notify_enter_exit_on_child(true); | 182 set_notify_enter_exit_on_child(true); |
| 183 | 183 |
| 184 // Button overlay that appears when hovering over the image. | 184 // Button overlay that appears when hovering over the image. |
| 185 change_photo_button_ = new views::TextButton(listener, | 185 change_photo_button_ = new views::TextButton(listener, |
| 186 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_CHANGE_PHOTO_BUTTON)); | 186 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_CHANGE_PHOTO_BUTTON)); |
| 187 change_photo_button_->set_alignment(views::TextButton::ALIGN_CENTER); | 187 change_photo_button_->set_alignment(views::TextButton::ALIGN_CENTER); |
| 188 change_photo_button_->set_border(NULL); | 188 change_photo_button_->SetBorder(views::Border::NullBorder()); |
| 189 change_photo_button_->SetEnabledColor(SK_ColorWHITE); | 189 change_photo_button_->SetEnabledColor(SK_ColorWHITE); |
| 190 change_photo_button_->SetHoverColor(SK_ColorWHITE); | 190 change_photo_button_->SetHoverColor(SK_ColorWHITE); |
| 191 | 191 |
| 192 change_photo_button_->set_background( | 192 change_photo_button_->set_background( |
| 193 views::Background::CreateSolidBackground(kBackgroundColor)); | 193 views::Background::CreateSolidBackground(kBackgroundColor)); |
| 194 // Need to take in account the border padding on the avatar. | 194 // Need to take in account the border padding on the avatar. |
| 195 change_photo_button_->SetBounds( | 195 change_photo_button_->SetBounds( |
| 196 profiles::kAvatarIconPadding, | 196 profiles::kAvatarIconPadding, |
| 197 kLargeImageSide - kOverlayHeight, | 197 kLargeImageSide - kOverlayHeight, |
| 198 kLargeImageSide - profiles::kAvatarIconPadding, | 198 kLargeImageSide - profiles::kAvatarIconPadding, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 public: | 233 public: |
| 234 EditableProfileName(views::TextfieldController* controller, | 234 EditableProfileName(views::TextfieldController* controller, |
| 235 const base::string16& text, | 235 const base::string16& text, |
| 236 bool is_editing_allowed) | 236 bool is_editing_allowed) |
| 237 : views::TextButton(this, text), | 237 : views::TextButton(this, text), |
| 238 profile_name_textfield_(NULL) { | 238 profile_name_textfield_(NULL) { |
| 239 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 239 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
| 240 const gfx::FontList& medium_font_list = | 240 const gfx::FontList& medium_font_list = |
| 241 rb->GetFontList(ui::ResourceBundle::MediumFont); | 241 rb->GetFontList(ui::ResourceBundle::MediumFont); |
| 242 SetFontList(medium_font_list); | 242 SetFontList(medium_font_list); |
| 243 set_border(NULL); | 243 SetBorder(views::Border::NullBorder()); |
| 244 | 244 |
| 245 if (!is_editing_allowed) | 245 if (!is_editing_allowed) |
| 246 return; | 246 return; |
| 247 | 247 |
| 248 SetHoverIcon(*rb->GetImageSkiaNamed(IDR_ICON_PROFILES_EDIT_HOVER)); | 248 SetHoverIcon(*rb->GetImageSkiaNamed(IDR_ICON_PROFILES_EDIT_HOVER)); |
| 249 SetPushedIcon(*rb->GetImageSkiaNamed(IDR_ICON_PROFILES_EDIT_PRESSED)); | 249 SetPushedIcon(*rb->GetImageSkiaNamed(IDR_ICON_PROFILES_EDIT_PRESSED)); |
| 250 set_icon_placement(views::TextButton::ICON_ON_RIGHT); | 250 set_icon_placement(views::TextButton::ICON_ON_RIGHT); |
| 251 set_full_justification(true); | 251 set_full_justification(true); |
| 252 | 252 |
| 253 // Textfield that overlaps the button. | 253 // Textfield that overlaps the button. |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 item.icon, true, | 715 item.icon, true, |
| 716 kSmallImageSide + profiles::kAvatarIconPadding, | 716 kSmallImageSide + profiles::kAvatarIconPadding, |
| 717 kSmallImageSide + profiles::kAvatarIconPadding); | 717 kSmallImageSide + profiles::kAvatarIconPadding); |
| 718 | 718 |
| 719 views::TextButton* button = new views::TextButton(this, item.name); | 719 views::TextButton* button = new views::TextButton(this, item.name); |
| 720 open_other_profile_indexes_map_[button] = index; | 720 open_other_profile_indexes_map_[button] = index; |
| 721 button->SetIcon(*image.ToImageSkia()); | 721 button->SetIcon(*image.ToImageSkia()); |
| 722 button->set_icon_text_spacing(views::kItemLabelSpacing); | 722 button->set_icon_text_spacing(views::kItemLabelSpacing); |
| 723 button->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( | 723 button->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
| 724 ui::ResourceBundle::MediumFont)); | 724 ui::ResourceBundle::MediumFont)); |
| 725 button->set_border(NULL); | 725 button->SetBorder(views::Border::NullBorder()); |
| 726 | 726 |
| 727 layout->StartRow(1, 0); | 727 layout->StartRow(1, 0); |
| 728 layout->AddView(button); | 728 layout->AddView(button); |
| 729 | 729 |
| 730 // The last avatar in the list does not need any bottom padding. | 730 // The last avatar in the list does not need any bottom padding. |
| 731 if (i < num_avatars_to_show - 1) | 731 if (i < num_avatars_to_show - 1) |
| 732 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 732 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 733 } | 733 } |
| 734 | 734 |
| 735 return view; | 735 return view; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 824 // Use a MenuButtonListener and not a regular ButtonListener to be | 824 // Use a MenuButtonListener and not a regular ButtonListener to be |
| 825 // able to distinguish between the unnamed "other profile" buttons and the | 825 // able to distinguish between the unnamed "other profile" buttons and the |
| 826 // unnamed "multiple accounts" buttons. | 826 // unnamed "multiple accounts" buttons. |
| 827 views::MenuButton* email_button = new views::MenuButton( | 827 views::MenuButton* email_button = new views::MenuButton( |
| 828 NULL, | 828 NULL, |
| 829 gfx::ElideEmail(base::UTF8ToUTF16(account), | 829 gfx::ElideEmail(base::UTF8ToUTF16(account), |
| 830 rb->GetFontList(ui::ResourceBundle::BaseFont), | 830 rb->GetFontList(ui::ResourceBundle::BaseFont), |
| 831 width()), | 831 width()), |
| 832 is_primary_account ? NULL : this, // Cannot delete the primary account. | 832 is_primary_account ? NULL : this, // Cannot delete the primary account. |
| 833 !is_primary_account); | 833 !is_primary_account); |
| 834 email_button->set_border(views::Border::CreateEmptyBorder(0, 0, 0, 0)); | 834 email_button->SetBorder(views::Border::CreateEmptyBorder(0, 0, 0, 0)); |
| 835 if (!is_primary_account) { | 835 if (!is_primary_account) { |
| 836 email_button->set_menu_marker( | 836 email_button->set_menu_marker( |
| 837 rb->GetImageNamed(IDR_CLOSE_1).ToImageSkia()); | 837 rb->GetImageNamed(IDR_CLOSE_1).ToImageSkia()); |
| 838 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); | 838 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); |
| 839 } | 839 } |
| 840 layout->StartRow(1, 0); | 840 layout->StartRow(1, 0); |
| 841 layout->AddView(email_button); | 841 layout->AddView(email_button); |
| 842 | 842 |
| 843 // Save the original email address, as the button text could be elided. | 843 // Save the original email address, as the button text could be elided. |
| 844 current_profile_accounts_map_[email_button] = account; | 844 current_profile_accounts_map_[email_button] = account; |
| 845 } | 845 } |
| OLD | NEW |