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/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/lifetime/application_lifetime.h" | 10 #include "chrome/browser/lifetime/application_lifetime.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "chrome/browser/ui/browser.h" | 23 #include "chrome/browser/ui/browser.h" |
24 #include "chrome/browser/ui/browser_commands.h" | 24 #include "chrome/browser/ui/browser_commands.h" |
25 #include "chrome/browser/ui/browser_dialogs.h" | 25 #include "chrome/browser/ui/browser_dialogs.h" |
26 #include "chrome/browser/ui/chrome_pages.h" | 26 #include "chrome/browser/ui/chrome_pages.h" |
27 #include "chrome/browser/ui/singleton_tabs.h" | 27 #include "chrome/browser/ui/singleton_tabs.h" |
28 #include "chrome/browser/ui/views/profiles/user_manager_view.h" | 28 #include "chrome/browser/ui/views/profiles/user_manager_view.h" |
29 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 29 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
30 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 30 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
31 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
32 #include "chrome/common/url_constants.h" | 32 #include "chrome/common/url_constants.h" |
| 33 #include "chrome/grit/chromium_strings.h" |
| 34 #include "chrome/grit/generated_resources.h" |
33 #include "components/signin/core/browser/mutable_profile_oauth2_token_service.h" | 35 #include "components/signin/core/browser/mutable_profile_oauth2_token_service.h" |
34 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 36 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
35 #include "components/signin/core/browser/signin_error_controller.h" | 37 #include "components/signin/core/browser/signin_error_controller.h" |
36 #include "components/signin/core/browser/signin_manager.h" | 38 #include "components/signin/core/browser/signin_manager.h" |
37 #include "components/signin/core/common/profile_management_switches.h" | 39 #include "components/signin/core/common/profile_management_switches.h" |
38 #include "grit/chromium_strings.h" | |
39 #include "grit/generated_resources.h" | |
40 #include "grit/theme_resources.h" | 40 #include "grit/theme_resources.h" |
41 #include "third_party/skia/include/core/SkColor.h" | 41 #include "third_party/skia/include/core/SkColor.h" |
42 #include "ui/base/l10n/l10n_util.h" | 42 #include "ui/base/l10n/l10n_util.h" |
43 #include "ui/base/resource/resource_bundle.h" | 43 #include "ui/base/resource/resource_bundle.h" |
44 #include "ui/gfx/canvas.h" | 44 #include "ui/gfx/canvas.h" |
45 #include "ui/gfx/image/image.h" | 45 #include "ui/gfx/image/image.h" |
46 #include "ui/gfx/image/image_skia.h" | 46 #include "ui/gfx/image/image_skia.h" |
47 #include "ui/gfx/path.h" | 47 #include "ui/gfx/path.h" |
48 #include "ui/gfx/skia_util.h" | 48 #include "ui/gfx/skia_util.h" |
49 #include "ui/gfx/text_elider.h" | 49 #include "ui/gfx/text_elider.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 } | 190 } |
191 | 191 |
192 protected: | 192 protected: |
193 virtual void Layout() OVERRIDE { | 193 virtual void Layout() OVERRIDE { |
194 // This layout trick keeps the text left-aligned and the icon right-aligned. | 194 // This layout trick keeps the text left-aligned and the icon right-aligned. |
195 SetHorizontalAlignment(gfx::ALIGN_RIGHT); | 195 SetHorizontalAlignment(gfx::ALIGN_RIGHT); |
196 views::LabelButton::Layout(); | 196 views::LabelButton::Layout(); |
197 label()->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 197 label()->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
198 } | 198 } |
199 | 199 |
| 200 private: |
200 DISALLOW_COPY_AND_ASSIGN(RightAlignedIconLabelButton); | 201 DISALLOW_COPY_AND_ASSIGN(RightAlignedIconLabelButton); |
201 }; | 202 }; |
202 | 203 |
203 // EditableProfilePhoto ------------------------------------------------- | 204 // EditableProfilePhoto ------------------------------------------------- |
204 | 205 |
205 // A custom Image control that shows a "change" button when moused over. | 206 // A custom Image control that shows a "change" button when moused over. |
206 class EditableProfilePhoto : public views::LabelButton { | 207 class EditableProfilePhoto : public views::LabelButton { |
207 public: | 208 public: |
208 EditableProfilePhoto(views::ButtonListener* listener, | 209 EditableProfilePhoto(views::ButtonListener* listener, |
209 const gfx::Image& icon, | 210 const gfx::Image& icon, |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 layout->StartRowWithPadding(1, 1, 0, views::kRelatedControlVerticalSpacing); | 446 layout->StartRowWithPadding(1, 1, 0, views::kRelatedControlVerticalSpacing); |
446 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); | 447 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); |
447 | 448 |
448 layout->StartRow(1, 1); | 449 layout->StartRow(1, 1); |
449 layout->AddView(view); | 450 layout->AddView(view); |
450 | 451 |
451 return titled_view; | 452 return titled_view; |
452 } | 453 } |
453 | 454 |
454 private: | 455 private: |
455 virtual void Layout() OVERRIDE{ | 456 virtual void Layout() OVERRIDE { |
456 int back_button_width = back_button_->GetPreferredSize().width(); | 457 int back_button_width = back_button_->GetPreferredSize().width(); |
457 back_button_->SetBounds(0, 0, back_button_width, height()); | 458 back_button_->SetBounds(0, 0, back_button_width, height()); |
458 int label_padding = back_button_width + views::kButtonHEdgeMarginNew; | 459 int label_padding = back_button_width + views::kButtonHEdgeMarginNew; |
459 int label_width = width() - 2 * label_padding; | 460 int label_width = width() - 2 * label_padding; |
460 DCHECK_GT(label_width, 0); | 461 DCHECK_GT(label_width, 0); |
461 title_label_->SetBounds(label_padding, 0, label_width, height()); | 462 title_label_->SetBounds(label_padding, 0, label_width, height()); |
462 } | 463 } |
463 | 464 |
464 virtual gfx::Size GetPreferredSize() const OVERRIDE{ | 465 virtual gfx::Size GetPreferredSize() const OVERRIDE { |
465 int height = std::max(title_label_->GetPreferredSize().height(), | 466 int height = std::max(title_label_->GetPreferredSize().height(), |
466 back_button_->GetPreferredSize().height()); | 467 back_button_->GetPreferredSize().height()); |
467 return gfx::Size(width(), height); | 468 return gfx::Size(width(), height); |
468 } | 469 } |
469 | 470 |
470 views::ImageButton* back_button_; | 471 views::ImageButton* back_button_; |
471 views::Label* title_label_; | 472 views::Label* title_label_; |
472 | 473 |
473 DISALLOW_COPY_AND_ASSIGN(TitleCard); | 474 DISALLOW_COPY_AND_ASSIGN(TitleCard); |
474 }; | 475 }; |
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 avatar_menu_.get()); | 823 avatar_menu_.get()); |
823 } else if (sender == add_account_link_) { | 824 } else if (sender == add_account_link_) { |
824 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); | 825 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); |
825 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT); | 826 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT); |
826 } else if (sender == tutorial_sync_settings_link_) { | 827 } else if (sender == tutorial_sync_settings_link_) { |
827 LoginUIServiceFactory::GetForProfile(browser_->profile())-> | 828 LoginUIServiceFactory::GetForProfile(browser_->profile())-> |
828 SyncConfirmationUIClosed(true /* configure_sync_first */); | 829 SyncConfirmationUIClosed(true /* configure_sync_first */); |
829 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; | 830 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; |
830 ProfileMetrics::LogProfileNewAvatarMenuSignin( | 831 ProfileMetrics::LogProfileNewAvatarMenuSignin( |
831 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_SETTINGS); | 832 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_SETTINGS); |
832 } else if (sender == tutorial_not_you_link_){ | 833 } else if (sender == tutorial_not_you_link_) { |
833 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( | 834 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( |
834 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_NOT_YOU); | 835 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_NOT_YOU); |
835 ShowView(profiles::BUBBLE_VIEW_MODE_SWITCH_USER, avatar_menu_.get()); | 836 ShowView(profiles::BUBBLE_VIEW_MODE_SWITCH_USER, avatar_menu_.get()); |
836 } else { | 837 } else { |
837 DCHECK(sender == tutorial_learn_more_link_); | 838 DCHECK(sender == tutorial_learn_more_link_); |
838 signin_ui_util::ShowSigninErrorLearnMorePage(browser_->profile()); | 839 signin_ui_util::ShowSigninErrorLearnMorePage(browser_->profile()); |
839 } | 840 } |
840 } | 841 } |
841 | 842 |
842 void ProfileChooserView::StyledLabelLinkClicked( | 843 void ProfileChooserView::StyledLabelLinkClicked( |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 } | 1498 } |
1498 | 1499 |
1499 TitleCard* title_card = new TitleCard( | 1500 TitleCard* title_card = new TitleCard( |
1500 l10n_util::GetStringUTF16(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE), | 1501 l10n_util::GetStringUTF16(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE), |
1501 this, &account_removal_cancel_button_); | 1502 this, &account_removal_cancel_button_); |
1502 return TitleCard::AddPaddedTitleCard(view, title_card, | 1503 return TitleCard::AddPaddedTitleCard(view, title_card, |
1503 kFixedAccountRemovalViewWidth); | 1504 kFixedAccountRemovalViewWidth); |
1504 } | 1505 } |
1505 | 1506 |
1506 views::View* ProfileChooserView::CreateWelcomeUpgradeTutorialViewIfNeeded( | 1507 views::View* ProfileChooserView::CreateWelcomeUpgradeTutorialViewIfNeeded( |
1507 bool tutorial_shown, const AvatarMenu::Item& avatar_item){ | 1508 bool tutorial_shown, const AvatarMenu::Item& avatar_item) { |
1508 Profile* profile = browser_->profile(); | 1509 Profile* profile = browser_->profile(); |
1509 | 1510 |
1510 const int show_count = profile->GetPrefs()->GetInteger( | 1511 const int show_count = profile->GetPrefs()->GetInteger( |
1511 prefs::kProfileAvatarTutorialShown); | 1512 prefs::kProfileAvatarTutorialShown); |
1512 // Do not show the tutorial if user has dismissed it. | 1513 // Do not show the tutorial if user has dismissed it. |
1513 if (show_count > signin_ui_util::kUpgradeWelcomeTutorialShowMax) | 1514 if (show_count > signin_ui_util::kUpgradeWelcomeTutorialShowMax) |
1514 return NULL; | 1515 return NULL; |
1515 | 1516 |
1516 if (!tutorial_shown) { | 1517 if (!tutorial_shown) { |
1517 if (show_count == signin_ui_util::kUpgradeWelcomeTutorialShowMax) | 1518 if (show_count == signin_ui_util::kUpgradeWelcomeTutorialShowMax) |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1635 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1636 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1636 IncognitoModePrefs::DISABLED; | 1637 IncognitoModePrefs::DISABLED; |
1637 return incognito_available && !browser_->profile()->IsGuestSession(); | 1638 return incognito_available && !browser_->profile()->IsGuestSession(); |
1638 } | 1639 } |
1639 | 1640 |
1640 void ProfileChooserView::PostActionPerformed( | 1641 void ProfileChooserView::PostActionPerformed( |
1641 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1642 ProfileMetrics::ProfileDesktopMenu action_performed) { |
1642 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1643 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
1643 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1644 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
1644 } | 1645 } |
OLD | NEW |