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/app/vector_icons/vector_icons.h" | 10 #include "chrome/app/vector_icons/vector_icons.h" |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
491 | 491 |
492 // ProfileChooserView --------------------------------------------------------- | 492 // ProfileChooserView --------------------------------------------------------- |
493 | 493 |
494 // static | 494 // static |
495 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; | 495 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; |
496 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; | 496 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; |
497 | 497 |
498 // static | 498 // static |
499 void ProfileChooserView::ShowBubble( | 499 void ProfileChooserView::ShowBubble( |
500 profiles::BubbleViewMode view_mode, | 500 profiles::BubbleViewMode view_mode, |
501 profiles::TutorialMode tutorial_mode, | |
502 const signin::ManageAccountsParams& manage_accounts_params, | 501 const signin::ManageAccountsParams& manage_accounts_params, |
503 signin_metrics::AccessPoint access_point, | 502 signin_metrics::AccessPoint access_point, |
504 views::View* anchor_view, | 503 views::View* anchor_view, |
505 Browser* browser, | 504 Browser* browser, |
506 bool is_source_keyboard) { | 505 bool is_source_keyboard) { |
507 if (IsShowing()) { | 506 if (IsShowing()) |
508 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) { | |
sky
2017/05/25 19:32:07
Previously wouldn't tutorial_mode always be MODE_N
Bret
2017/05/25 20:32:25
Hmm, I think you have the logic here backwards. I
sky
2017/05/25 22:56:13
D'OH! You are correct, I read it wrong.
| |
509 profile_bubble_->tutorial_mode_ = tutorial_mode; | |
510 profile_bubble_->ShowViewFromMode(view_mode); | |
511 } | |
512 return; | 507 return; |
513 } | |
514 | 508 |
515 profile_bubble_ = | 509 profile_bubble_ = |
516 new ProfileChooserView(anchor_view, browser, view_mode, tutorial_mode, | 510 new ProfileChooserView(anchor_view, browser, view_mode, |
517 manage_accounts_params.service_type, access_point); | 511 manage_accounts_params.service_type, access_point); |
518 views::Widget* widget = | 512 views::Widget* widget = |
519 views::BubbleDialogDelegateView::CreateBubble(profile_bubble_); | 513 views::BubbleDialogDelegateView::CreateBubble(profile_bubble_); |
520 profile_bubble_->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); | 514 profile_bubble_->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); |
521 profile_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); | 515 profile_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); |
522 widget->Show(); | 516 widget->Show(); |
523 if (is_source_keyboard) | 517 if (is_source_keyboard) |
524 profile_bubble_->FocusFirstProfileButton(); | 518 profile_bubble_->FocusFirstProfileButton(); |
525 } | 519 } |
526 | 520 |
527 // static | 521 // static |
528 bool ProfileChooserView::IsShowing() { | 522 bool ProfileChooserView::IsShowing() { |
529 return profile_bubble_ != NULL; | 523 return profile_bubble_ != NULL; |
530 } | 524 } |
531 | 525 |
532 // static | 526 // static |
533 views::Widget* ProfileChooserView::GetCurrentBubbleWidget() { | 527 views::Widget* ProfileChooserView::GetCurrentBubbleWidget() { |
534 return profile_bubble_ ? profile_bubble_->GetWidget() : nullptr; | 528 return profile_bubble_ ? profile_bubble_->GetWidget() : nullptr; |
535 } | 529 } |
536 | 530 |
537 // static | 531 // static |
538 void ProfileChooserView::Hide() { | 532 void ProfileChooserView::Hide() { |
539 if (IsShowing()) | 533 if (IsShowing()) |
540 profile_bubble_->GetWidget()->Close(); | 534 profile_bubble_->GetWidget()->Close(); |
541 } | 535 } |
542 | 536 |
543 ProfileChooserView::ProfileChooserView(views::View* anchor_view, | 537 ProfileChooserView::ProfileChooserView(views::View* anchor_view, |
544 Browser* browser, | 538 Browser* browser, |
545 profiles::BubbleViewMode view_mode, | 539 profiles::BubbleViewMode view_mode, |
546 profiles::TutorialMode tutorial_mode, | |
547 signin::GAIAServiceType service_type, | 540 signin::GAIAServiceType service_type, |
548 signin_metrics::AccessPoint access_point) | 541 signin_metrics::AccessPoint access_point) |
549 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), | 542 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), |
550 browser_(browser), | 543 browser_(browser), |
551 view_mode_(view_mode), | 544 view_mode_(view_mode), |
552 tutorial_mode_(tutorial_mode), | |
553 gaia_service_type_(service_type), | 545 gaia_service_type_(service_type), |
554 access_point_(access_point) { | 546 access_point_(access_point) { |
555 // The sign in webview will be clipped on the bottom corners without these | 547 // The sign in webview will be clipped on the bottom corners without these |
556 // margins, see related bug <http://crbug.com/593203>. | 548 // margins, see related bug <http://crbug.com/593203>. |
557 set_margins(gfx::Insets(0, 0, 2, 0)); | 549 set_margins(gfx::Insets(0, 0, 2, 0)); |
558 ResetView(); | 550 ResetView(); |
559 chrome::RecordDialogCreation(chrome::DialogIdentifier::PROFILE_CHOOSER); | 551 chrome::RecordDialogCreation(chrome::DialogIdentifier::PROFILE_CHOOSER); |
560 } | 552 } |
561 | 553 |
562 ProfileChooserView::~ProfileChooserView() { | 554 ProfileChooserView::~ProfileChooserView() { |
563 ProfileOAuth2TokenService* oauth2_token_service = | 555 ProfileOAuth2TokenService* oauth2_token_service = |
564 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); | 556 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); |
565 if (oauth2_token_service) | 557 if (oauth2_token_service) |
566 oauth2_token_service->RemoveObserver(this); | 558 oauth2_token_service->RemoveObserver(this); |
567 } | 559 } |
568 | 560 |
569 void ProfileChooserView::ResetView() { | 561 void ProfileChooserView::ResetView() { |
570 open_other_profile_indexes_map_.clear(); | 562 open_other_profile_indexes_map_.clear(); |
571 delete_account_button_map_.clear(); | 563 delete_account_button_map_.clear(); |
572 reauth_account_button_map_.clear(); | 564 reauth_account_button_map_.clear(); |
573 tutorial_sync_settings_ok_button_ = nullptr; | |
574 tutorial_close_button_ = nullptr; | |
575 tutorial_sync_settings_link_ = nullptr; | |
576 tutorial_see_whats_new_button_ = nullptr; | |
577 tutorial_not_you_link_ = nullptr; | |
578 tutorial_learn_more_link_ = nullptr; | |
579 sync_error_signin_button_ = nullptr; | 565 sync_error_signin_button_ = nullptr; |
580 sync_error_passphrase_button_ = nullptr; | 566 sync_error_passphrase_button_ = nullptr; |
581 sync_error_upgrade_button_ = nullptr; | 567 sync_error_upgrade_button_ = nullptr; |
582 sync_error_signin_again_button_ = nullptr; | 568 sync_error_signin_again_button_ = nullptr; |
583 sync_error_signout_button_ = nullptr; | 569 sync_error_signout_button_ = nullptr; |
584 manage_accounts_link_ = nullptr; | 570 manage_accounts_link_ = nullptr; |
585 manage_accounts_button_ = nullptr; | 571 manage_accounts_button_ = nullptr; |
586 signin_current_profile_button_ = nullptr; | 572 signin_current_profile_button_ = nullptr; |
587 auth_error_email_button_ = nullptr; | 573 auth_error_email_button_ = nullptr; |
588 current_profile_card_ = nullptr; | 574 current_profile_card_ = nullptr; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
722 sub_view = CreateSwitchUserView(); | 708 sub_view = CreateSwitchUserView(); |
723 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 709 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
724 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); | 710 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); |
725 break; | 711 break; |
726 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: | 712 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: |
727 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: | 713 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: |
728 layout = CreateSingleColumnLayout(this, kFixedMenuWidth); | 714 layout = CreateSingleColumnLayout(this, kFixedMenuWidth); |
729 sub_view = CreateProfileChooserView(avatar_menu); | 715 sub_view = CreateProfileChooserView(avatar_menu); |
730 break; | 716 break; |
731 } | 717 } |
732 // Clears tutorial mode for all non-profile-chooser views. | |
733 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) | |
734 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; | |
735 | 718 |
736 layout->StartRow(1, 0); | 719 layout->StartRow(1, 0); |
737 layout->AddView(sub_view); | 720 layout->AddView(sub_view); |
738 Layout(); | 721 Layout(); |
739 if (GetBubbleFrameView()) | 722 if (GetBubbleFrameView()) |
740 SizeToContents(); | 723 SizeToContents(); |
741 if (view_to_focus) | 724 if (view_to_focus) |
742 view_to_focus->RequestFocus(); | 725 view_to_focus->RequestFocus(); |
743 } | 726 } |
744 | 727 |
(...skipping 11 matching lines...) Expand all Loading... | |
756 } | 739 } |
757 | 740 |
758 void ProfileChooserView::FocusFirstProfileButton() { | 741 void ProfileChooserView::FocusFirstProfileButton() { |
759 if (first_profile_button_) | 742 if (first_profile_button_) |
760 first_profile_button_->RequestFocus(); | 743 first_profile_button_->RequestFocus(); |
761 } | 744 } |
762 | 745 |
763 void ProfileChooserView::WindowClosing() { | 746 void ProfileChooserView::WindowClosing() { |
764 DCHECK_EQ(profile_bubble_, this); | 747 DCHECK_EQ(profile_bubble_, this); |
765 profile_bubble_ = NULL; | 748 profile_bubble_ = NULL; |
766 | |
767 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) { | |
768 LoginUIServiceFactory::GetForProfile(browser_->profile())-> | |
769 SyncConfirmationUIClosed(LoginUIService::SYNC_WITH_DEFAULT_SETTINGS); | |
770 } | |
771 } | 749 } |
772 | 750 |
773 bool ProfileChooserView::AcceleratorPressed( | 751 bool ProfileChooserView::AcceleratorPressed( |
774 const ui::Accelerator& accelerator) { | 752 const ui::Accelerator& accelerator) { |
775 if (accelerator.key_code() != ui::VKEY_DOWN && | 753 if (accelerator.key_code() != ui::VKEY_DOWN && |
776 accelerator.key_code() != ui::VKEY_UP) | 754 accelerator.key_code() != ui::VKEY_UP) |
777 return BubbleDialogDelegateView::AcceleratorPressed(accelerator); | 755 return BubbleDialogDelegateView::AcceleratorPressed(accelerator); |
778 | 756 |
779 // Move the focus up or down. | 757 // Move the focus up or down. |
780 GetFocusManager()->AdvanceFocus(accelerator.key_code() != ui::VKEY_DOWN); | 758 GetFocusManager()->AdvanceFocus(accelerator.key_code() != ui::VKEY_DOWN); |
(...skipping 21 matching lines...) Expand all Loading... | |
802 PrefService* service = g_browser_process->local_state(); | 780 PrefService* service = g_browser_process->local_state(); |
803 DCHECK(service); | 781 DCHECK(service); |
804 DCHECK(service->GetBoolean(prefs::kBrowserGuestModeEnabled)); | 782 DCHECK(service->GetBoolean(prefs::kBrowserGuestModeEnabled)); |
805 profiles::SwitchToGuestProfile(ProfileManager::CreateCallback()); | 783 profiles::SwitchToGuestProfile(ProfileManager::CreateCallback()); |
806 } else if (sender == users_button_) { | 784 } else if (sender == users_button_) { |
807 // If this is a guest session, close all the guest browser windows. | 785 // If this is a guest session, close all the guest browser windows. |
808 if (browser_->profile()->IsGuestSession()) { | 786 if (browser_->profile()->IsGuestSession()) { |
809 profiles::CloseGuestProfileWindows(); | 787 profiles::CloseGuestProfileWindows(); |
810 } else { | 788 } else { |
811 UserManager::Show(base::FilePath(), | 789 UserManager::Show(base::FilePath(), |
812 profiles::USER_MANAGER_NO_TUTORIAL, | |
813 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | 790 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
814 } | 791 } |
815 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER); | 792 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER); |
816 } else if (sender == go_incognito_button_) { | 793 } else if (sender == go_incognito_button_) { |
817 DCHECK(ShouldShowGoIncognito()); | 794 DCHECK(ShouldShowGoIncognito()); |
818 chrome::NewIncognitoWindow(browser_); | 795 chrome::NewIncognitoWindow(browser_); |
819 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_GO_INCOGNITO); | 796 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_GO_INCOGNITO); |
820 } else if (sender == lock_button_) { | 797 } else if (sender == lock_button_) { |
821 profiles::LockProfile(browser_->profile()); | 798 profiles::LockProfile(browser_->profile()); |
822 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK); | 799 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK); |
823 } else if (sender == close_all_windows_button_) { | 800 } else if (sender == close_all_windows_button_) { |
824 profiles::CloseProfileWindows(browser_->profile()); | 801 profiles::CloseProfileWindows(browser_->profile()); |
825 } else if (sender == auth_error_email_button_ || | 802 } else if (sender == auth_error_email_button_ || |
826 sender == sync_error_signin_button_) { | 803 sender == sync_error_signin_button_) { |
827 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH); | 804 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH); |
828 } else if (sender == sync_error_passphrase_button_) { | 805 } else if (sender == sync_error_passphrase_button_) { |
829 chrome::ShowSettingsSubPage(browser_, chrome::kSyncSetupSubPage); | 806 chrome::ShowSettingsSubPage(browser_, chrome::kSyncSetupSubPage); |
830 } else if (sender == sync_error_upgrade_button_) { | 807 } else if (sender == sync_error_upgrade_button_) { |
831 chrome::OpenUpdateChromeDialog(browser_); | 808 chrome::OpenUpdateChromeDialog(browser_); |
832 } else if (sender == sync_error_signin_again_button_) { | 809 } else if (sender == sync_error_signin_again_button_) { |
833 if (ProfileSyncServiceFactory::GetForProfile(browser_->profile())) | 810 if (ProfileSyncServiceFactory::GetForProfile(browser_->profile())) |
834 browser_sync::ProfileSyncService::SyncEvent( | 811 browser_sync::ProfileSyncService::SyncEvent( |
835 browser_sync::ProfileSyncService::STOP_FROM_OPTIONS); | 812 browser_sync::ProfileSyncService::STOP_FROM_OPTIONS); |
836 SigninManagerFactory::GetForProfile(browser_->profile()) | 813 SigninManagerFactory::GetForProfile(browser_->profile()) |
837 ->SignOut(signin_metrics::USER_CLICKED_SIGNOUT_SETTINGS, | 814 ->SignOut(signin_metrics::USER_CLICKED_SIGNOUT_SETTINGS, |
838 signin_metrics::SignoutDelete::IGNORE_METRIC); | 815 signin_metrics::SignoutDelete::IGNORE_METRIC); |
839 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN); | 816 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN); |
840 } else if (sender == sync_error_signout_button_) { | 817 } else if (sender == sync_error_signout_button_) { |
841 chrome::ShowSettingsSubPage(browser_, chrome::kSignOutSubPage); | 818 chrome::ShowSettingsSubPage(browser_, chrome::kSignOutSubPage); |
842 } else if (sender == tutorial_sync_settings_ok_button_) { | |
843 LoginUIServiceFactory::GetForProfile(browser_->profile())-> | |
844 SyncConfirmationUIClosed(LoginUIService::SYNC_WITH_DEFAULT_SETTINGS); | |
845 DismissTutorial(); | |
846 ProfileMetrics::LogProfileNewAvatarMenuSignin( | |
847 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_OK); | |
848 } else if (sender == tutorial_close_button_) { | |
849 DCHECK(tutorial_mode_ != profiles::TUTORIAL_MODE_NONE && | |
850 tutorial_mode_ != profiles::TUTORIAL_MODE_CONFIRM_SIGNIN); | |
851 DismissTutorial(); | |
852 } else if (sender == tutorial_see_whats_new_button_) { | |
853 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( | |
854 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_WHATS_NEW); | |
855 UserManager::Show(base::FilePath(), | |
856 profiles::USER_MANAGER_TUTORIAL_OVERVIEW, | |
857 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | |
858 } else if (sender == remove_account_button_) { | 819 } else if (sender == remove_account_button_) { |
859 RemoveAccount(); | 820 RemoveAccount(); |
860 } else if (sender == account_removal_cancel_button_) { | 821 } else if (sender == account_removal_cancel_button_) { |
861 account_id_to_remove_.clear(); | 822 account_id_to_remove_.clear(); |
862 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT); | 823 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT); |
863 } else if (sender == gaia_signin_cancel_button_) { | 824 } else if (sender == gaia_signin_cancel_button_) { |
864 // The account management view is only available with the | 825 // The account management view is only available with the |
865 // --enable-account-consistency flag. | 826 // --enable-account-consistency flag. |
866 bool account_management_available = | 827 bool account_management_available = |
867 SigninManagerFactory::GetForProfile(browser_->profile())-> | 828 SigninManagerFactory::GetForProfile(browser_->profile())-> |
(...skipping 11 matching lines...) Expand all Loading... | |
879 // depending on which view it is displayed. | 840 // depending on which view it is displayed. |
880 ShowViewFromMode(view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT | 841 ShowViewFromMode(view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT |
881 ? profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER | 842 ? profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER |
882 : profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT); | 843 : profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT); |
883 } else if (sender == signin_current_profile_button_) { | 844 } else if (sender == signin_current_profile_button_) { |
884 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN); | 845 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN); |
885 } else if (sender == add_person_button_) { | 846 } else if (sender == add_person_button_) { |
886 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 847 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
887 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON); | 848 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON); |
888 UserManager::Show(base::FilePath(), | 849 UserManager::Show(base::FilePath(), |
889 profiles::USER_MANAGER_NO_TUTORIAL, | |
890 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | 850 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
891 } else if (sender == disconnect_button_) { | 851 } else if (sender == disconnect_button_) { |
892 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 852 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
893 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT); | 853 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT); |
894 chrome::ShowSettings(browser_); | 854 chrome::ShowSettings(browser_); |
895 } else if (sender == switch_user_cancel_button_) { | 855 } else if (sender == switch_user_cancel_button_) { |
896 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); | 856 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); |
897 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 857 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
898 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_BACK); | 858 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_BACK); |
899 } else { | 859 } else { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
940 // This link can either mean show/hide the account management view, | 900 // This link can either mean show/hide the account management view, |
941 // depending on which view it is displayed. ShowView() will DCHECK if | 901 // depending on which view it is displayed. ShowView() will DCHECK if |
942 // the account management view is displayed for non signed-in users. | 902 // the account management view is displayed for non signed-in users. |
943 ShowViewFromMode( | 903 ShowViewFromMode( |
944 view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ? | 904 view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ? |
945 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER : | 905 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER : |
946 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT); | 906 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT); |
947 } else if (sender == add_account_link_) { | 907 } else if (sender == add_account_link_) { |
948 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT); | 908 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT); |
949 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT); | 909 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT); |
950 } else if (sender == tutorial_sync_settings_link_) { | |
951 LoginUIServiceFactory::GetForProfile(browser_->profile())-> | |
952 SyncConfirmationUIClosed(LoginUIService::CONFIGURE_SYNC_FIRST); | |
953 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; | |
954 ProfileMetrics::LogProfileNewAvatarMenuSignin( | |
955 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_SETTINGS); | |
956 } else if (sender == tutorial_not_you_link_) { | |
957 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( | |
958 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_NOT_YOU); | |
959 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_SWITCH_USER); | |
960 } else { | |
961 DCHECK(sender == tutorial_learn_more_link_); | |
962 signin_ui_util::ShowSigninErrorLearnMorePage(browser_->profile()); | |
963 } | 910 } |
964 } | 911 } |
965 | 912 |
966 void ProfileChooserView::StyledLabelLinkClicked(views::StyledLabel* label, | 913 void ProfileChooserView::StyledLabelLinkClicked(views::StyledLabel* label, |
967 const gfx::Range& range, | 914 const gfx::Range& range, |
968 int event_flags) { | 915 int event_flags) { |
969 chrome::ShowSettings(browser_); | 916 chrome::ShowSettings(browser_); |
970 } | 917 } |
971 | 918 |
972 views::View* ProfileChooserView::CreateProfileChooserView( | 919 views::View* ProfileChooserView::CreateProfileChooserView( |
973 AvatarMenu* avatar_menu) { | 920 AvatarMenu* avatar_menu) { |
974 views::View* view = new views::View(); | 921 views::View* view = new views::View(); |
975 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); | 922 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); |
976 // Separate items into active and alternatives. | 923 // Separate items into active and alternatives. |
977 Indexes other_profiles; | 924 Indexes other_profiles; |
978 views::View* tutorial_view = NULL; | |
979 views::View* sync_error_view = NULL; | 925 views::View* sync_error_view = NULL; |
980 views::View* current_profile_view = NULL; | 926 views::View* current_profile_view = NULL; |
981 views::View* current_profile_accounts = NULL; | 927 views::View* current_profile_accounts = NULL; |
982 views::View* option_buttons_view = NULL; | 928 views::View* option_buttons_view = NULL; |
983 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { | 929 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { |
984 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); | 930 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); |
985 if (item.active) { | 931 if (item.active) { |
986 option_buttons_view = CreateOptionsView( | 932 option_buttons_view = CreateOptionsView( |
987 item.signed_in && profiles::IsLockAvailable(browser_->profile()), | 933 item.signed_in && profiles::IsLockAvailable(browser_->profile()), |
988 avatar_menu); | 934 avatar_menu); |
989 current_profile_view = CreateCurrentProfileView(item, false); | 935 current_profile_view = CreateCurrentProfileView(item, false); |
990 if (!IsProfileChooser(view_mode_)) | 936 if (!IsProfileChooser(view_mode_)) |
991 current_profile_accounts = CreateCurrentProfileAccountsView(item); | 937 current_profile_accounts = CreateCurrentProfileAccountsView(item); |
992 sync_error_view = CreateSyncErrorViewIfNeeded(); | 938 sync_error_view = CreateSyncErrorViewIfNeeded(); |
993 } else { | 939 } else { |
994 other_profiles.push_back(i); | 940 other_profiles.push_back(i); |
995 } | 941 } |
996 } | 942 } |
997 | 943 |
998 if (tutorial_view) { | |
999 // TODO(mlerman): update UMA stats for the new tutorial. | |
1000 layout->StartRow(1, 0); | |
1001 layout->AddView(tutorial_view); | |
1002 } else { | |
1003 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; | |
1004 } | |
1005 | |
1006 if (sync_error_view) { | 944 if (sync_error_view) { |
1007 layout->StartRow(1, 0); | 945 layout->StartRow(1, 0); |
1008 layout->AddView(sync_error_view); | 946 layout->AddView(sync_error_view); |
1009 layout->StartRow(0, 0); | 947 layout->StartRow(0, 0); |
1010 layout->AddView(new views::Separator()); | 948 layout->AddView(new views::Separator()); |
1011 } | 949 } |
1012 | 950 |
1013 if (!current_profile_view) { | 951 if (!current_profile_view) { |
1014 // Guest windows don't have an active profile. | 952 // Guest windows don't have an active profile. |
1015 current_profile_view = CreateGuestProfileView(); | 953 current_profile_view = CreateGuestProfileView(); |
(...skipping 19 matching lines...) Expand all Loading... | |
1035 layout->StartRow(0, 0); | 973 layout->StartRow(0, 0); |
1036 layout->AddView(new views::Separator()); | 974 layout->AddView(new views::Separator()); |
1037 | 975 |
1038 if (option_buttons_view) { | 976 if (option_buttons_view) { |
1039 layout->StartRow(0, 0); | 977 layout->StartRow(0, 0); |
1040 layout->AddView(option_buttons_view); | 978 layout->AddView(option_buttons_view); |
1041 } | 979 } |
1042 return view; | 980 return view; |
1043 } | 981 } |
1044 | 982 |
1045 void ProfileChooserView::DismissTutorial() { | |
1046 // Never shows the upgrade tutorial again if manually closed. | |
1047 if (tutorial_mode_ == profiles::TUTORIAL_MODE_WELCOME_UPGRADE) { | |
1048 browser_->profile()->GetPrefs()->SetInteger( | |
1049 prefs::kProfileAvatarTutorialShown, | |
1050 signin_ui_util::kUpgradeWelcomeTutorialShowMax + 1); | |
1051 } | |
1052 | |
1053 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; | |
1054 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); | |
1055 } | |
1056 | |
1057 views::View* ProfileChooserView::CreateTutorialViewIfNeeded( | |
1058 const AvatarMenu::Item& item) { | |
1059 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) | |
1060 return CreateSigninConfirmationView(); | |
1061 | |
1062 if (tutorial_mode_ == profiles::TUTORIAL_MODE_SHOW_ERROR) | |
1063 return CreateSigninErrorView(); | |
1064 | |
1065 if (profiles::ShouldShowWelcomeUpgradeTutorial( | |
1066 browser_->profile(), tutorial_mode_)) { | |
1067 if (tutorial_mode_ != profiles::TUTORIAL_MODE_WELCOME_UPGRADE) { | |
1068 Profile* profile = browser_->profile(); | |
1069 const int show_count = profile->GetPrefs()->GetInteger( | |
1070 prefs::kProfileAvatarTutorialShown); | |
1071 profile->GetPrefs()->SetInteger( | |
1072 prefs::kProfileAvatarTutorialShown, show_count + 1); | |
1073 } | |
1074 | |
1075 return CreateWelcomeUpgradeTutorialView(item); | |
1076 } | |
1077 | |
1078 return nullptr; | |
1079 } | |
1080 | |
1081 views::View* ProfileChooserView::CreateTutorialView( | |
1082 profiles::TutorialMode tutorial_mode, | |
1083 const base::string16& title_text, | |
1084 const base::string16& content_text, | |
1085 const base::string16& link_text, | |
1086 const base::string16& button_text, | |
1087 bool stack_button, | |
1088 views::Link** link, | |
1089 views::LabelButton** button, | |
1090 views::ImageButton** close_button) { | |
1091 tutorial_mode_ = tutorial_mode; | |
1092 | |
1093 views::View* view = new views::View(); | |
1094 view->set_background(views::Background::CreateSolidBackground( | |
1095 profiles::kAvatarTutorialBackgroundColor)); | |
1096 view->SetBorder(views::CreateEmptyBorder( | |
1097 views::kButtonVEdgeMarginNew, views::kButtonHEdgeMarginNew, | |
1098 views::kButtonVEdgeMarginNew, views::kButtonHEdgeMarginNew)); | |
1099 views::GridLayout* layout = CreateSingleColumnLayout( | |
1100 view, kFixedMenuWidth - 2 * views::kButtonHEdgeMarginNew); | |
1101 // Creates a second column set for buttons and links. | |
1102 views::ColumnSet* button_columns = layout->AddColumnSet(1); | |
1103 button_columns->AddColumn(views::GridLayout::LEADING, | |
1104 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); | |
1105 button_columns->AddPaddingColumn( | |
1106 1, views::kUnrelatedControlHorizontalSpacing); | |
1107 button_columns->AddColumn(views::GridLayout::TRAILING, | |
1108 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0); | |
1109 | |
1110 // Adds title and close button if needed. | |
1111 const SkColor kTitleAndButtonTextColor = SK_ColorWHITE; | |
1112 views::Label* title_label = new views::Label(title_text); | |
1113 title_label->SetMultiLine(true); | |
1114 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
1115 title_label->SetAutoColorReadabilityEnabled(false); | |
1116 title_label->SetEnabledColor(kTitleAndButtonTextColor); | |
1117 title_label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( | |
1118 ui::ResourceBundle::MediumFont)); | |
1119 | |
1120 if (close_button) { | |
1121 layout->StartRow(1, 1); | |
1122 layout->AddView(title_label); | |
1123 *close_button = new views::ImageButton(this); | |
1124 (*close_button)->SetImageAlignment(views::ImageButton::ALIGN_RIGHT, | |
1125 views::ImageButton::ALIGN_MIDDLE); | |
1126 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | |
1127 (*close_button)->SetImage(views::ImageButton::STATE_NORMAL, | |
1128 rb->GetImageSkiaNamed(IDR_CLOSE_1)); | |
1129 (*close_button)->SetImage(views::ImageButton::STATE_HOVERED, | |
1130 rb->GetImageSkiaNamed(IDR_CLOSE_1_H)); | |
1131 (*close_button)->SetImage(views::ImageButton::STATE_PRESSED, | |
1132 rb->GetImageSkiaNamed(IDR_CLOSE_1_P)); | |
1133 layout->AddView(*close_button); | |
1134 } else { | |
1135 layout->StartRow(1, 0); | |
1136 layout->AddView(title_label); | |
1137 } | |
1138 | |
1139 // Adds body content. | |
1140 views::Label* content_label = new views::Label(content_text); | |
1141 content_label->SetMultiLine(true); | |
1142 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
1143 content_label->SetAutoColorReadabilityEnabled(false); | |
1144 content_label->SetEnabledColor(profiles::kAvatarTutorialContentTextColor); | |
1145 layout->StartRowWithPadding(1, 0, 0, views::kRelatedControlVerticalSpacing); | |
1146 layout->AddView(content_label); | |
1147 | |
1148 // Adds links and buttons. | |
1149 bool has_button = !button_text.empty(); | |
1150 if (has_button) { | |
1151 *button = views::MdTextButton::CreateSecondaryUiButton(this, button_text); | |
1152 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) | |
1153 (*button)->SetEnabledTextColors(kTitleAndButtonTextColor); | |
1154 else | |
1155 (*button)->SetHorizontalAlignment(gfx::ALIGN_CENTER); | |
1156 } | |
1157 | |
1158 bool has_link = !link_text.empty(); | |
1159 if (has_link) { | |
1160 *link = CreateLink(link_text, this); | |
1161 (*link)->SetHorizontalAlignment(gfx::ALIGN_LEFT); | |
1162 (*link)->SetAutoColorReadabilityEnabled(false); | |
1163 (*link)->SetEnabledColor(kTitleAndButtonTextColor); | |
1164 } | |
1165 | |
1166 if (stack_button) { | |
1167 DCHECK(has_button); | |
1168 layout->StartRowWithPadding( | |
1169 1, 0, 0, views::kUnrelatedControlVerticalSpacing); | |
1170 layout->AddView(*button); | |
1171 if (has_link) { | |
1172 layout->StartRowWithPadding( | |
1173 1, 0, 0, views::kRelatedControlVerticalSpacing); | |
1174 (*link)->SetHorizontalAlignment(gfx::ALIGN_CENTER); | |
1175 layout->AddView(*link); | |
1176 } | |
1177 } else { | |
1178 DCHECK(has_link || has_button); | |
1179 layout->StartRowWithPadding( | |
1180 1, 1, 0, views::kUnrelatedControlVerticalSpacing); | |
1181 if (has_link) | |
1182 layout->AddView(*link); | |
1183 else | |
1184 layout->SkipColumns(1); | |
1185 if (has_button) | |
1186 layout->AddView(*button); | |
1187 else | |
1188 layout->SkipColumns(1); | |
1189 } | |
1190 | |
1191 return view; | |
1192 } | |
1193 | |
1194 views::View* ProfileChooserView::CreateSyncErrorViewIfNeeded() { | 983 views::View* ProfileChooserView::CreateSyncErrorViewIfNeeded() { |
1195 int content_string_id, button_string_id; | 984 int content_string_id, button_string_id; |
1196 views::LabelButton** button_out = nullptr; | 985 views::LabelButton** button_out = nullptr; |
1197 sync_ui_util::AvatarSyncErrorType error = | 986 sync_ui_util::AvatarSyncErrorType error = |
1198 sync_ui_util::GetMessagesForAvatarSyncError( | 987 sync_ui_util::GetMessagesForAvatarSyncError( |
1199 browser_->profile(), &content_string_id, &button_string_id); | 988 browser_->profile(), &content_string_id, &button_string_id); |
1200 switch (error) { | 989 switch (error) { |
1201 case sync_ui_util::MANAGED_USER_UNRECOVERABLE_ERROR: | 990 case sync_ui_util::MANAGED_USER_UNRECOVERABLE_ERROR: |
1202 button_out = &sync_error_signout_button_; | 991 button_out = &sync_error_signout_button_; |
1203 break; | 992 break; |
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1722 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); | 1511 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); |
1723 } | 1512 } |
1724 | 1513 |
1725 TitleCard* title_card = new TitleCard( | 1514 TitleCard* title_card = new TitleCard( |
1726 l10n_util::GetStringUTF16(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE), | 1515 l10n_util::GetStringUTF16(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE), |
1727 this, &account_removal_cancel_button_); | 1516 this, &account_removal_cancel_button_); |
1728 return TitleCard::AddPaddedTitleCard(view, title_card, | 1517 return TitleCard::AddPaddedTitleCard(view, title_card, |
1729 kFixedAccountRemovalViewWidth); | 1518 kFixedAccountRemovalViewWidth); |
1730 } | 1519 } |
1731 | 1520 |
1732 views::View* ProfileChooserView::CreateWelcomeUpgradeTutorialView( | |
1733 const AvatarMenu::Item& avatar_item) { | |
1734 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( | |
1735 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_VIEW); | |
1736 | |
1737 // For local profiles, the "Not you" link doesn't make sense. | |
1738 base::string16 link_message = avatar_item.signed_in ? | |
1739 l10n_util::GetStringFUTF16(IDS_PROFILES_NOT_YOU, avatar_item.name) : | |
1740 base::string16(); | |
1741 | |
1742 return CreateTutorialView( | |
1743 profiles::TUTORIAL_MODE_WELCOME_UPGRADE, | |
1744 l10n_util::GetStringUTF16( | |
1745 IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_TITLE), | |
1746 l10n_util::GetStringUTF16( | |
1747 IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_CONTENT_TEXT), | |
1748 link_message, | |
1749 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_WHATS_NEW_BUTTON), | |
1750 true /* stack_button */, | |
1751 &tutorial_not_you_link_, | |
1752 &tutorial_see_whats_new_button_, | |
1753 &tutorial_close_button_); | |
1754 } | |
1755 | |
1756 views::View* ProfileChooserView::CreateSigninConfirmationView() { | |
1757 ProfileMetrics::LogProfileNewAvatarMenuSignin( | |
1758 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_VIEW); | |
1759 | |
1760 return CreateTutorialView( | |
1761 profiles::TUTORIAL_MODE_CONFIRM_SIGNIN, | |
1762 l10n_util::GetStringUTF16(IDS_PROFILES_CONFIRM_SIGNIN_TUTORIAL_TITLE), | |
1763 l10n_util::GetStringUTF16( | |
1764 IDS_PROFILES_CONFIRM_SIGNIN_TUTORIAL_CONTENT_TEXT), | |
1765 l10n_util::GetStringUTF16(IDS_PROFILES_SYNC_SETTINGS_LINK), | |
1766 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_OK_BUTTON), | |
1767 false /* stack_button */, | |
1768 &tutorial_sync_settings_link_, | |
1769 &tutorial_sync_settings_ok_button_, | |
1770 NULL /* close_button*/); | |
1771 } | |
1772 | |
1773 views::View* ProfileChooserView::CreateSigninErrorView() { | |
1774 LoginUIService* login_ui_service = | |
1775 LoginUIServiceFactory::GetForProfile(browser_->profile()); | |
1776 base::string16 last_login_result(login_ui_service->GetLastLoginResult()); | |
1777 return CreateTutorialView( | |
1778 profiles::TUTORIAL_MODE_SHOW_ERROR, | |
1779 l10n_util::GetStringUTF16(IDS_PROFILES_ERROR_TUTORIAL_TITLE), | |
1780 last_login_result, | |
1781 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE), | |
1782 base::string16(), | |
1783 false /* stack_button */, | |
1784 &tutorial_learn_more_link_, | |
1785 NULL, | |
1786 &tutorial_close_button_); | |
1787 } | |
1788 | |
1789 views::View* ProfileChooserView::CreateSwitchUserView() { | 1521 views::View* ProfileChooserView::CreateSwitchUserView() { |
1790 views::View* view = new views::View(); | 1522 views::View* view = new views::View(); |
1791 views::GridLayout* layout = CreateSingleColumnLayout( | 1523 views::GridLayout* layout = CreateSingleColumnLayout( |
1792 view, kFixedSwitchUserViewWidth); | 1524 view, kFixedSwitchUserViewWidth); |
1793 views::ColumnSet* columns = layout->AddColumnSet(1); | 1525 views::ColumnSet* columns = layout->AddColumnSet(1); |
1794 columns->AddPaddingColumn(0, views::kButtonHEdgeMarginNew); | 1526 columns->AddPaddingColumn(0, views::kButtonHEdgeMarginNew); |
1795 int label_width = | 1527 int label_width = |
1796 kFixedSwitchUserViewWidth - 2 * views::kButtonHEdgeMarginNew; | 1528 kFixedSwitchUserViewWidth - 2 * views::kButtonHEdgeMarginNew; |
1797 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, | 1529 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 0, |
1798 views::GridLayout::FIXED, label_width, label_width); | 1530 views::GridLayout::FIXED, label_width, label_width); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1846 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1578 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1847 IncognitoModePrefs::DISABLED; | 1579 IncognitoModePrefs::DISABLED; |
1848 return incognito_available && !browser_->profile()->IsGuestSession(); | 1580 return incognito_available && !browser_->profile()->IsGuestSession(); |
1849 } | 1581 } |
1850 | 1582 |
1851 void ProfileChooserView::PostActionPerformed( | 1583 void ProfileChooserView::PostActionPerformed( |
1852 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1584 ProfileMetrics::ProfileDesktopMenu action_performed) { |
1853 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1585 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
1854 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1586 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
1855 } | 1587 } |
OLD | NEW |