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 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
549 remove_account_button_ = NULL; | 549 remove_account_button_ = NULL; |
550 account_removal_cancel_button_ = NULL; | 550 account_removal_cancel_button_ = NULL; |
551 add_person_button_ = NULL; | 551 add_person_button_ = NULL; |
552 disconnect_button_ = NULL; | 552 disconnect_button_ = NULL; |
553 switch_user_cancel_button_ = NULL; | 553 switch_user_cancel_button_ = NULL; |
554 tutorial_sync_settings_ok_button_ = NULL; | 554 tutorial_sync_settings_ok_button_ = NULL; |
555 tutorial_close_button_ = NULL; | 555 tutorial_close_button_ = NULL; |
556 tutorial_sync_settings_link_ = NULL; | 556 tutorial_sync_settings_link_ = NULL; |
557 tutorial_see_whats_new_button_ = NULL; | 557 tutorial_see_whats_new_button_ = NULL; |
558 tutorial_not_you_link_ = NULL; | 558 tutorial_not_you_link_ = NULL; |
559 tutorial_learn_more_link_ = NULL; | |
559 } | 560 } |
560 | 561 |
561 void ProfileChooserView::Init() { | 562 void ProfileChooserView::Init() { |
562 // If view mode is PROFILE_CHOOSER but there is an auth error, force | 563 // If view mode is PROFILE_CHOOSER but there is an auth error, force |
563 // ACCOUNT_MANAGEMENT mode. | 564 // ACCOUNT_MANAGEMENT mode. |
564 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER && | 565 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER && |
565 HasAuthError(browser_->profile()) && | 566 HasAuthError(browser_->profile()) && |
566 switches::IsEnableAccountConsistency() && | 567 switches::IsEnableAccountConsistency() && |
567 avatar_menu_->GetItemAt(avatar_menu_->GetActiveProfileIndex()). | 568 avatar_menu_->GetItemAt(avatar_menu_->GetActiveProfileIndex()). |
568 signed_in) { | 569 signed_in) { |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
800 avatar_menu_.get()); | 801 avatar_menu_.get()); |
801 } else if (sender == add_account_link_) { | 802 } else if (sender == add_account_link_) { |
802 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); | 803 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); |
803 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT); | 804 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT); |
804 } else if (sender == tutorial_sync_settings_link_) { | 805 } else if (sender == tutorial_sync_settings_link_) { |
805 LoginUIServiceFactory::GetForProfile(browser_->profile())-> | 806 LoginUIServiceFactory::GetForProfile(browser_->profile())-> |
806 SyncConfirmationUIClosed(true /* configure_sync_first */); | 807 SyncConfirmationUIClosed(true /* configure_sync_first */); |
807 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; | 808 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; |
808 ProfileMetrics::LogProfileNewAvatarMenuSignin( | 809 ProfileMetrics::LogProfileNewAvatarMenuSignin( |
809 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_SETTINGS); | 810 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_SETTINGS); |
810 } else { | 811 } else if (sender == tutorial_not_you_link_){ |
811 DCHECK(sender == tutorial_not_you_link_); | |
812 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( | 812 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( |
813 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_NOT_YOU); | 813 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_NOT_YOU); |
814 ShowView(profiles::BUBBLE_VIEW_MODE_SWITCH_USER, avatar_menu_.get()); | 814 ShowView(profiles::BUBBLE_VIEW_MODE_SWITCH_USER, avatar_menu_.get()); |
815 } else { | |
816 DCHECK(sender == tutorial_learn_more_link_); | |
817 signin_ui_util::ShowSigninErrorLearnMorePage(browser_->profile()); | |
815 } | 818 } |
816 } | 819 } |
817 | 820 |
818 void ProfileChooserView::StyledLabelLinkClicked( | 821 void ProfileChooserView::StyledLabelLinkClicked( |
819 const gfx::Range& range, int event_flags) { | 822 const gfx::Range& range, int event_flags) { |
820 chrome::ShowSettings(browser_); | 823 chrome::ShowSettings(browser_); |
821 } | 824 } |
822 | 825 |
823 bool ProfileChooserView::HandleKeyEvent(views::Textfield* sender, | 826 bool ProfileChooserView::HandleKeyEvent(views::Textfield* sender, |
824 const ui::KeyEvent& key_event) { | 827 const ui::KeyEvent& key_event) { |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
872 case profiles::TUTORIAL_MODE_NONE: | 875 case profiles::TUTORIAL_MODE_NONE: |
873 case profiles::TUTORIAL_MODE_WELCOME_UPGRADE: | 876 case profiles::TUTORIAL_MODE_WELCOME_UPGRADE: |
874 tutorial_view = CreateWelcomeUpgradeTutorialViewIfNeeded( | 877 tutorial_view = CreateWelcomeUpgradeTutorialViewIfNeeded( |
875 tutorial_mode_ == profiles::TUTORIAL_MODE_WELCOME_UPGRADE, | 878 tutorial_mode_ == profiles::TUTORIAL_MODE_WELCOME_UPGRADE, |
876 item); | 879 item); |
877 break; | 880 break; |
878 case profiles::TUTORIAL_MODE_CONFIRM_SIGNIN: | 881 case profiles::TUTORIAL_MODE_CONFIRM_SIGNIN: |
879 tutorial_view = CreateSigninConfirmationView(); | 882 tutorial_view = CreateSigninConfirmationView(); |
880 break; | 883 break; |
881 case profiles::TUTORIAL_MODE_SHOW_ERROR: | 884 case profiles::TUTORIAL_MODE_SHOW_ERROR: |
882 // TODO(guohui): not implemented yet. | 885 tutorial_view = CreateSigninErrorView(); |
sky
2014/08/19 19:57:12
Add break.
guohui
2014/08/19 20:03:30
Done.
| |
883 NOTREACHED(); | |
884 } | 886 } |
885 } else { | 887 } else { |
886 current_profile_accounts = CreateCurrentProfileAccountsView(item); | 888 current_profile_accounts = CreateCurrentProfileAccountsView(item); |
887 } | 889 } |
888 } else { | 890 } else { |
889 other_profiles.push_back(i); | 891 other_profiles.push_back(i); |
890 } | 892 } |
891 } | 893 } |
892 | 894 |
893 if (tutorial_view) { | 895 if (tutorial_view) { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1012 // Adds body content. | 1014 // Adds body content. |
1013 views::Label* content_label = new views::Label(content_text); | 1015 views::Label* content_label = new views::Label(content_text); |
1014 content_label->SetMultiLine(true); | 1016 content_label->SetMultiLine(true); |
1015 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1017 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
1016 content_label->SetAutoColorReadabilityEnabled(false); | 1018 content_label->SetAutoColorReadabilityEnabled(false); |
1017 content_label->SetEnabledColor(profiles::kAvatarTutorialContentTextColor); | 1019 content_label->SetEnabledColor(profiles::kAvatarTutorialContentTextColor); |
1018 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); | 1020 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); |
1019 layout->AddView(content_label); | 1021 layout->AddView(content_label); |
1020 | 1022 |
1021 // Adds links and buttons. | 1023 // Adds links and buttons. |
1022 *button = new views::LabelButton(this, button_text); | 1024 bool has_button = !button_text.empty(); |
1023 (*button)->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 1025 if (has_button) { |
1024 (*button)->SetStyle(views::Button::STYLE_BUTTON); | 1026 *button = new views::LabelButton(this, button_text); |
1027 (*button)->SetHorizontalAlignment(gfx::ALIGN_CENTER); | |
1028 (*button)->SetStyle(views::Button::STYLE_BUTTON); | |
1029 } | |
1025 | 1030 |
1026 bool has_link = !link_text.empty(); | 1031 bool has_link = !link_text.empty(); |
1027 if (has_link) { | 1032 if (has_link) { |
1028 *link = CreateLink(link_text, this); | 1033 *link = CreateLink(link_text, this); |
1029 (*link)->SetHorizontalAlignment(gfx::ALIGN_LEFT); | 1034 (*link)->SetHorizontalAlignment(gfx::ALIGN_LEFT); |
1030 (*link)->SetAutoColorReadabilityEnabled(false); | 1035 (*link)->SetAutoColorReadabilityEnabled(false); |
1031 (*link)->SetEnabledColor(SK_ColorWHITE); | 1036 (*link)->SetEnabledColor(SK_ColorWHITE); |
1032 } | 1037 } |
1033 | 1038 |
1034 if (stack_button) { | 1039 if (stack_button) { |
1040 DCHECK(has_button); | |
1035 layout->StartRowWithPadding( | 1041 layout->StartRowWithPadding( |
1036 1, 0, 0, views::kUnrelatedControlVerticalSpacing); | 1042 1, 0, 0, views::kUnrelatedControlVerticalSpacing); |
1037 layout->AddView(*button); | 1043 layout->AddView(*button); |
1038 if (has_link) { | 1044 if (has_link) { |
1039 layout->StartRowWithPadding( | 1045 layout->StartRowWithPadding( |
1040 1, 0, 0, views::kRelatedControlVerticalSpacing); | 1046 1, 0, 0, views::kRelatedControlVerticalSpacing); |
1041 (*link)->SetHorizontalAlignment(gfx::ALIGN_CENTER); | 1047 (*link)->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
1042 layout->AddView(*link); | 1048 layout->AddView(*link); |
1043 } | 1049 } |
1044 } else { | 1050 } else { |
1051 DCHECK(has_link || has_button); | |
1045 layout->StartRowWithPadding( | 1052 layout->StartRowWithPadding( |
1046 1, 1, 0, views::kUnrelatedControlVerticalSpacing); | 1053 1, 1, 0, views::kUnrelatedControlVerticalSpacing); |
1047 if (has_link) | 1054 if (has_link) |
1048 layout->AddView(*link); | 1055 layout->AddView(*link); |
1049 else | 1056 else |
1050 layout->SkipColumns(1); | 1057 layout->SkipColumns(1); |
1051 layout->AddView(*button); | 1058 if (has_button) |
1059 layout->AddView(*button); | |
1060 else | |
1061 layout->SkipColumns(1); | |
1052 } | 1062 } |
1053 | 1063 |
1054 return view; | 1064 return view; |
1055 } | 1065 } |
1056 | 1066 |
1057 views::View* ProfileChooserView::CreateCurrentProfileView( | 1067 views::View* ProfileChooserView::CreateCurrentProfileView( |
1058 const AvatarMenu::Item& avatar_item, | 1068 const AvatarMenu::Item& avatar_item, |
1059 bool is_guest) { | 1069 bool is_guest) { |
1060 views::View* view = new views::View(); | 1070 views::View* view = new views::View(); |
1061 int column_width = kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew; | 1071 int column_width = kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew; |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1501 l10n_util::GetStringUTF16( | 1511 l10n_util::GetStringUTF16( |
1502 IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_CONTENT_TEXT), | 1512 IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_CONTENT_TEXT), |
1503 link_message, | 1513 link_message, |
1504 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_WHATS_NEW_BUTTON), | 1514 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_WHATS_NEW_BUTTON), |
1505 true /* stack_button */, | 1515 true /* stack_button */, |
1506 &tutorial_not_you_link_, | 1516 &tutorial_not_you_link_, |
1507 &tutorial_see_whats_new_button_, | 1517 &tutorial_see_whats_new_button_, |
1508 &tutorial_close_button_); | 1518 &tutorial_close_button_); |
1509 } | 1519 } |
1510 | 1520 |
1511 views::View* ProfileChooserView::CreateSigninConfirmationView(){ | 1521 views::View* ProfileChooserView::CreateSigninConfirmationView() { |
1512 ProfileMetrics::LogProfileNewAvatarMenuSignin( | 1522 ProfileMetrics::LogProfileNewAvatarMenuSignin( |
1513 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_VIEW); | 1523 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_VIEW); |
1514 | 1524 |
1515 return CreateTutorialView( | 1525 return CreateTutorialView( |
1516 profiles::TUTORIAL_MODE_CONFIRM_SIGNIN, | 1526 profiles::TUTORIAL_MODE_CONFIRM_SIGNIN, |
1517 l10n_util::GetStringUTF16(IDS_PROFILES_CONFIRM_SIGNIN_TUTORIAL_TITLE), | 1527 l10n_util::GetStringUTF16(IDS_PROFILES_CONFIRM_SIGNIN_TUTORIAL_TITLE), |
1518 l10n_util::GetStringUTF16( | 1528 l10n_util::GetStringUTF16( |
1519 IDS_PROFILES_CONFIRM_SIGNIN_TUTORIAL_CONTENT_TEXT), | 1529 IDS_PROFILES_CONFIRM_SIGNIN_TUTORIAL_CONTENT_TEXT), |
1520 l10n_util::GetStringUTF16(IDS_PROFILES_SYNC_SETTINGS_LINK), | 1530 l10n_util::GetStringUTF16(IDS_PROFILES_SYNC_SETTINGS_LINK), |
1521 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_OK_BUTTON), | 1531 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_OK_BUTTON), |
1522 false /* stack_button */, | 1532 false /* stack_button */, |
1523 &tutorial_sync_settings_link_, | 1533 &tutorial_sync_settings_link_, |
1524 &tutorial_sync_settings_ok_button_, | 1534 &tutorial_sync_settings_ok_button_, |
1525 NULL /* close_button*/); | 1535 NULL /* close_button*/); |
1526 } | 1536 } |
1527 | 1537 |
1538 views::View* ProfileChooserView::CreateSigninErrorView() { | |
1539 LoginUIService* login_ui_service = | |
1540 LoginUIServiceFactory::GetForProfile(browser_->profile()); | |
1541 base::string16 last_login_result(login_ui_service->GetLastLoginResult()); | |
1542 return CreateTutorialView( | |
1543 profiles::TUTORIAL_MODE_SHOW_ERROR, | |
1544 l10n_util::GetStringUTF16(IDS_PROFILES_ERROR_TUTORIAL_TITLE), | |
1545 last_login_result, | |
1546 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE), | |
1547 base::string16(), | |
1548 false /* stack_button */, | |
1549 &tutorial_learn_more_link_, | |
1550 NULL, | |
1551 &tutorial_close_button_); | |
1552 } | |
1553 | |
1528 views::View* ProfileChooserView::CreateSwitchUserView() { | 1554 views::View* ProfileChooserView::CreateSwitchUserView() { |
1529 views::View* view = new views::View(); | 1555 views::View* view = new views::View(); |
1530 views::GridLayout* layout = CreateSingleColumnLayout( | 1556 views::GridLayout* layout = CreateSingleColumnLayout( |
1531 view, kFixedSwitchUserViewWidth); | 1557 view, kFixedSwitchUserViewWidth); |
1532 views::ColumnSet* columns = layout->AddColumnSet(1); | 1558 views::ColumnSet* columns = layout->AddColumnSet(1); |
1533 columns->AddPaddingColumn(0, views::kButtonHEdgeMarginNew); | 1559 columns->AddPaddingColumn(0, views::kButtonHEdgeMarginNew); |
1534 int label_width = | 1560 int label_width = |
1535 kFixedSwitchUserViewWidth - 2 * views::kButtonHEdgeMarginNew; | 1561 kFixedSwitchUserViewWidth - 2 * views::kButtonHEdgeMarginNew; |
1536 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, | 1562 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, |
1537 views::GridLayout::FIXED, label_width, label_width); | 1563 views::GridLayout::FIXED, label_width, label_width); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1586 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1612 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1587 IncognitoModePrefs::DISABLED; | 1613 IncognitoModePrefs::DISABLED; |
1588 return incognito_available && !browser_->profile()->IsGuestSession(); | 1614 return incognito_available && !browser_->profile()->IsGuestSession(); |
1589 } | 1615 } |
1590 | 1616 |
1591 void ProfileChooserView::PostActionPerformed( | 1617 void ProfileChooserView::PostActionPerformed( |
1592 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1618 ProfileMetrics::ProfileDesktopMenu action_performed) { |
1593 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1619 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
1594 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1620 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
1595 } | 1621 } |
OLD | NEW |