Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: chrome/browser/ui/views/profiles/profile_chooser_view.cc

Issue 2899083003: Delete unused tutorial code from profile switcher/user manager. (Closed)
Patch Set: fix merge Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 501
502 // ProfileChooserView --------------------------------------------------------- 502 // ProfileChooserView ---------------------------------------------------------
503 503
504 // static 504 // static
505 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; 505 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr;
506 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; 506 bool ProfileChooserView::close_on_deactivate_for_testing_ = true;
507 507
508 // static 508 // static
509 void ProfileChooserView::ShowBubble( 509 void ProfileChooserView::ShowBubble(
510 profiles::BubbleViewMode view_mode, 510 profiles::BubbleViewMode view_mode,
511 profiles::TutorialMode tutorial_mode,
512 const signin::ManageAccountsParams& manage_accounts_params, 511 const signin::ManageAccountsParams& manage_accounts_params,
513 signin_metrics::AccessPoint access_point, 512 signin_metrics::AccessPoint access_point,
514 views::View* anchor_view, 513 views::View* anchor_view,
515 Browser* browser, 514 Browser* browser,
516 bool is_source_keyboard) { 515 bool is_source_keyboard) {
517 if (IsShowing()) { 516 if (IsShowing())
518 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) {
519 profile_bubble_->tutorial_mode_ = tutorial_mode;
520 profile_bubble_->ShowViewFromMode(view_mode);
521 }
522 return; 517 return;
523 }
524 518
525 profile_bubble_ = 519 profile_bubble_ =
526 new ProfileChooserView(anchor_view, browser, view_mode, tutorial_mode, 520 new ProfileChooserView(anchor_view, browser, view_mode,
527 manage_accounts_params.service_type, access_point); 521 manage_accounts_params.service_type, access_point);
528 views::Widget* widget = 522 views::Widget* widget =
529 views::BubbleDialogDelegateView::CreateBubble(profile_bubble_); 523 views::BubbleDialogDelegateView::CreateBubble(profile_bubble_);
530 profile_bubble_->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE); 524 profile_bubble_->SetAlignment(views::BubbleBorder::ALIGN_EDGE_TO_ANCHOR_EDGE);
531 profile_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE); 525 profile_bubble_->SetArrowPaintType(views::BubbleBorder::PAINT_NONE);
532 widget->Show(); 526 widget->Show();
533 if (is_source_keyboard) 527 if (is_source_keyboard)
534 profile_bubble_->FocusFirstProfileButton(); 528 profile_bubble_->FocusFirstProfileButton();
535 } 529 }
536 530
537 // static 531 // static
538 bool ProfileChooserView::IsShowing() { 532 bool ProfileChooserView::IsShowing() {
539 return profile_bubble_ != NULL; 533 return profile_bubble_ != NULL;
540 } 534 }
541 535
542 // static 536 // static
543 views::Widget* ProfileChooserView::GetCurrentBubbleWidget() { 537 views::Widget* ProfileChooserView::GetCurrentBubbleWidget() {
544 return profile_bubble_ ? profile_bubble_->GetWidget() : nullptr; 538 return profile_bubble_ ? profile_bubble_->GetWidget() : nullptr;
545 } 539 }
546 540
547 // static 541 // static
548 void ProfileChooserView::Hide() { 542 void ProfileChooserView::Hide() {
549 if (IsShowing()) 543 if (IsShowing())
550 profile_bubble_->GetWidget()->Close(); 544 profile_bubble_->GetWidget()->Close();
551 } 545 }
552 546
553 ProfileChooserView::ProfileChooserView(views::View* anchor_view, 547 ProfileChooserView::ProfileChooserView(views::View* anchor_view,
554 Browser* browser, 548 Browser* browser,
555 profiles::BubbleViewMode view_mode, 549 profiles::BubbleViewMode view_mode,
556 profiles::TutorialMode tutorial_mode,
557 signin::GAIAServiceType service_type, 550 signin::GAIAServiceType service_type,
558 signin_metrics::AccessPoint access_point) 551 signin_metrics::AccessPoint access_point)
559 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), 552 : BubbleDialogDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT),
560 browser_(browser), 553 browser_(browser),
561 view_mode_(view_mode), 554 view_mode_(view_mode),
562 tutorial_mode_(tutorial_mode),
563 gaia_service_type_(service_type), 555 gaia_service_type_(service_type),
564 access_point_(access_point) { 556 access_point_(access_point) {
565 // The sign in webview will be clipped on the bottom corners without these 557 // The sign in webview will be clipped on the bottom corners without these
566 // margins, see related bug <http://crbug.com/593203>. 558 // margins, see related bug <http://crbug.com/593203>.
567 set_margins(gfx::Insets(0, 0, 2, 0)); 559 set_margins(gfx::Insets(0, 0, 2, 0));
568 ResetView(); 560 ResetView();
569 chrome::RecordDialogCreation(chrome::DialogIdentifier::PROFILE_CHOOSER); 561 chrome::RecordDialogCreation(chrome::DialogIdentifier::PROFILE_CHOOSER);
570 } 562 }
571 563
572 ProfileChooserView::~ProfileChooserView() { 564 ProfileChooserView::~ProfileChooserView() {
573 ProfileOAuth2TokenService* oauth2_token_service = 565 ProfileOAuth2TokenService* oauth2_token_service =
574 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); 566 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile());
575 if (oauth2_token_service) 567 if (oauth2_token_service)
576 oauth2_token_service->RemoveObserver(this); 568 oauth2_token_service->RemoveObserver(this);
577 } 569 }
578 570
579 void ProfileChooserView::ResetView() { 571 void ProfileChooserView::ResetView() {
580 open_other_profile_indexes_map_.clear(); 572 open_other_profile_indexes_map_.clear();
581 delete_account_button_map_.clear(); 573 delete_account_button_map_.clear();
582 reauth_account_button_map_.clear(); 574 reauth_account_button_map_.clear();
583 tutorial_sync_settings_ok_button_ = nullptr;
584 tutorial_close_button_ = nullptr;
585 tutorial_sync_settings_link_ = nullptr;
586 tutorial_see_whats_new_button_ = nullptr;
587 tutorial_not_you_link_ = nullptr;
588 tutorial_learn_more_link_ = nullptr;
589 sync_error_signin_button_ = nullptr; 575 sync_error_signin_button_ = nullptr;
590 sync_error_passphrase_button_ = nullptr; 576 sync_error_passphrase_button_ = nullptr;
591 sync_error_upgrade_button_ = nullptr; 577 sync_error_upgrade_button_ = nullptr;
592 sync_error_signin_again_button_ = nullptr; 578 sync_error_signin_again_button_ = nullptr;
593 sync_error_signout_button_ = nullptr; 579 sync_error_signout_button_ = nullptr;
594 manage_accounts_link_ = nullptr; 580 manage_accounts_link_ = nullptr;
595 manage_accounts_button_ = nullptr; 581 manage_accounts_button_ = nullptr;
596 signin_current_profile_button_ = nullptr; 582 signin_current_profile_button_ = nullptr;
597 auth_error_email_button_ = nullptr; 583 auth_error_email_button_ = nullptr;
598 current_profile_card_ = nullptr; 584 current_profile_card_ = nullptr;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 sub_view = CreateSwitchUserView(); 718 sub_view = CreateSwitchUserView();
733 ProfileMetrics::LogProfileNewAvatarMenuNotYou( 719 ProfileMetrics::LogProfileNewAvatarMenuNotYou(
734 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW); 720 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_VIEW);
735 break; 721 break;
736 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: 722 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT:
737 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: 723 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER:
738 layout = CreateSingleColumnLayout(this, kFixedMenuWidth); 724 layout = CreateSingleColumnLayout(this, kFixedMenuWidth);
739 sub_view = CreateProfileChooserView(avatar_menu); 725 sub_view = CreateProfileChooserView(avatar_menu);
740 break; 726 break;
741 } 727 }
742 // Clears tutorial mode for all non-profile-chooser views.
743 if (view_mode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER)
744 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE;
745 728
746 layout->StartRow(1, 0); 729 layout->StartRow(1, 0);
747 layout->AddView(sub_view); 730 layout->AddView(sub_view);
748 Layout(); 731 Layout();
749 if (GetBubbleFrameView()) 732 if (GetBubbleFrameView())
750 SizeToContents(); 733 SizeToContents();
751 if (view_to_focus) 734 if (view_to_focus)
752 view_to_focus->RequestFocus(); 735 view_to_focus->RequestFocus();
753 } 736 }
754 737
(...skipping 11 matching lines...) Expand all
766 } 749 }
767 750
768 void ProfileChooserView::FocusFirstProfileButton() { 751 void ProfileChooserView::FocusFirstProfileButton() {
769 if (first_profile_button_) 752 if (first_profile_button_)
770 first_profile_button_->RequestFocus(); 753 first_profile_button_->RequestFocus();
771 } 754 }
772 755
773 void ProfileChooserView::WindowClosing() { 756 void ProfileChooserView::WindowClosing() {
774 DCHECK_EQ(profile_bubble_, this); 757 DCHECK_EQ(profile_bubble_, this);
775 profile_bubble_ = NULL; 758 profile_bubble_ = NULL;
776
777 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) {
778 LoginUIServiceFactory::GetForProfile(browser_->profile())->
779 SyncConfirmationUIClosed(LoginUIService::SYNC_WITH_DEFAULT_SETTINGS);
780 }
781 } 759 }
782 760
783 bool ProfileChooserView::AcceleratorPressed( 761 bool ProfileChooserView::AcceleratorPressed(
784 const ui::Accelerator& accelerator) { 762 const ui::Accelerator& accelerator) {
785 if (accelerator.key_code() != ui::VKEY_DOWN && 763 if (accelerator.key_code() != ui::VKEY_DOWN &&
786 accelerator.key_code() != ui::VKEY_UP) 764 accelerator.key_code() != ui::VKEY_UP)
787 return BubbleDialogDelegateView::AcceleratorPressed(accelerator); 765 return BubbleDialogDelegateView::AcceleratorPressed(accelerator);
788 766
789 // Move the focus up or down. 767 // Move the focus up or down.
790 GetFocusManager()->AdvanceFocus(accelerator.key_code() != ui::VKEY_DOWN); 768 GetFocusManager()->AdvanceFocus(accelerator.key_code() != ui::VKEY_DOWN);
(...skipping 21 matching lines...) Expand all
812 PrefService* service = g_browser_process->local_state(); 790 PrefService* service = g_browser_process->local_state();
813 DCHECK(service); 791 DCHECK(service);
814 DCHECK(service->GetBoolean(prefs::kBrowserGuestModeEnabled)); 792 DCHECK(service->GetBoolean(prefs::kBrowserGuestModeEnabled));
815 profiles::SwitchToGuestProfile(ProfileManager::CreateCallback()); 793 profiles::SwitchToGuestProfile(ProfileManager::CreateCallback());
816 } else if (sender == users_button_) { 794 } else if (sender == users_button_) {
817 // If this is a guest session, close all the guest browser windows. 795 // If this is a guest session, close all the guest browser windows.
818 if (browser_->profile()->IsGuestSession()) { 796 if (browser_->profile()->IsGuestSession()) {
819 profiles::CloseGuestProfileWindows(); 797 profiles::CloseGuestProfileWindows();
820 } else { 798 } else {
821 UserManager::Show(base::FilePath(), 799 UserManager::Show(base::FilePath(),
822 profiles::USER_MANAGER_NO_TUTORIAL,
823 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); 800 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
824 } 801 }
825 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER); 802 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER);
826 } else if (sender == go_incognito_button_) { 803 } else if (sender == go_incognito_button_) {
827 DCHECK(ShouldShowGoIncognito()); 804 DCHECK(ShouldShowGoIncognito());
828 chrome::NewIncognitoWindow(browser_); 805 chrome::NewIncognitoWindow(browser_);
829 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_GO_INCOGNITO); 806 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_GO_INCOGNITO);
830 } else if (sender == lock_button_) { 807 } else if (sender == lock_button_) {
831 profiles::LockProfile(browser_->profile()); 808 profiles::LockProfile(browser_->profile());
832 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK); 809 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK);
833 } else if (sender == close_all_windows_button_) { 810 } else if (sender == close_all_windows_button_) {
834 profiles::CloseProfileWindows(browser_->profile()); 811 profiles::CloseProfileWindows(browser_->profile());
835 } else if (sender == auth_error_email_button_ || 812 } else if (sender == auth_error_email_button_ ||
836 sender == sync_error_signin_button_) { 813 sender == sync_error_signin_button_) {
837 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH); 814 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH);
838 } else if (sender == sync_error_passphrase_button_) { 815 } else if (sender == sync_error_passphrase_button_) {
839 chrome::ShowSettingsSubPage(browser_, chrome::kSyncSetupSubPage); 816 chrome::ShowSettingsSubPage(browser_, chrome::kSyncSetupSubPage);
840 } else if (sender == sync_error_upgrade_button_) { 817 } else if (sender == sync_error_upgrade_button_) {
841 chrome::OpenUpdateChromeDialog(browser_); 818 chrome::OpenUpdateChromeDialog(browser_);
842 } else if (sender == sync_error_signin_again_button_) { 819 } else if (sender == sync_error_signin_again_button_) {
843 if (ProfileSyncServiceFactory::GetForProfile(browser_->profile())) 820 if (ProfileSyncServiceFactory::GetForProfile(browser_->profile()))
844 browser_sync::ProfileSyncService::SyncEvent( 821 browser_sync::ProfileSyncService::SyncEvent(
845 browser_sync::ProfileSyncService::STOP_FROM_OPTIONS); 822 browser_sync::ProfileSyncService::STOP_FROM_OPTIONS);
846 SigninManagerFactory::GetForProfile(browser_->profile()) 823 SigninManagerFactory::GetForProfile(browser_->profile())
847 ->SignOut(signin_metrics::USER_CLICKED_SIGNOUT_SETTINGS, 824 ->SignOut(signin_metrics::USER_CLICKED_SIGNOUT_SETTINGS,
848 signin_metrics::SignoutDelete::IGNORE_METRIC); 825 signin_metrics::SignoutDelete::IGNORE_METRIC);
849 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN); 826 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN);
850 } else if (sender == sync_error_signout_button_) { 827 } else if (sender == sync_error_signout_button_) {
851 chrome::ShowSettingsSubPage(browser_, chrome::kSignOutSubPage); 828 chrome::ShowSettingsSubPage(browser_, chrome::kSignOutSubPage);
852 } else if (sender == tutorial_sync_settings_ok_button_) {
853 LoginUIServiceFactory::GetForProfile(browser_->profile())->
854 SyncConfirmationUIClosed(LoginUIService::SYNC_WITH_DEFAULT_SETTINGS);
855 DismissTutorial();
856 ProfileMetrics::LogProfileNewAvatarMenuSignin(
857 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_OK);
858 } else if (sender == tutorial_close_button_) {
859 DCHECK(tutorial_mode_ != profiles::TUTORIAL_MODE_NONE &&
860 tutorial_mode_ != profiles::TUTORIAL_MODE_CONFIRM_SIGNIN);
861 DismissTutorial();
862 } else if (sender == tutorial_see_whats_new_button_) {
863 ProfileMetrics::LogProfileNewAvatarMenuUpgrade(
864 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_WHATS_NEW);
865 UserManager::Show(base::FilePath(),
866 profiles::USER_MANAGER_TUTORIAL_OVERVIEW,
867 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
868 } else if (sender == remove_account_button_) { 829 } else if (sender == remove_account_button_) {
869 RemoveAccount(); 830 RemoveAccount();
870 } else if (sender == account_removal_cancel_button_) { 831 } else if (sender == account_removal_cancel_button_) {
871 account_id_to_remove_.clear(); 832 account_id_to_remove_.clear();
872 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT); 833 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT);
873 } else if (sender == gaia_signin_cancel_button_) { 834 } else if (sender == gaia_signin_cancel_button_) {
874 // The account management view is only available with the 835 // The account management view is only available with the
875 // --enable-account-consistency flag. 836 // --enable-account-consistency flag.
876 bool account_management_available = 837 bool account_management_available =
877 SigninManagerFactory::GetForProfile(browser_->profile())-> 838 SigninManagerFactory::GetForProfile(browser_->profile())->
(...skipping 11 matching lines...) Expand all
889 // depending on which view it is displayed. 850 // depending on which view it is displayed.
890 ShowViewFromMode(view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT 851 ShowViewFromMode(view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT
891 ? profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER 852 ? profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER
892 : profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT); 853 : profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT);
893 } else if (sender == signin_current_profile_button_) { 854 } else if (sender == signin_current_profile_button_) {
894 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN); 855 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN);
895 } else if (sender == add_person_button_) { 856 } else if (sender == add_person_button_) {
896 ProfileMetrics::LogProfileNewAvatarMenuNotYou( 857 ProfileMetrics::LogProfileNewAvatarMenuNotYou(
897 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON); 858 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON);
898 UserManager::Show(base::FilePath(), 859 UserManager::Show(base::FilePath(),
899 profiles::USER_MANAGER_NO_TUTORIAL,
900 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); 860 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
901 } else if (sender == disconnect_button_) { 861 } else if (sender == disconnect_button_) {
902 ProfileMetrics::LogProfileNewAvatarMenuNotYou( 862 ProfileMetrics::LogProfileNewAvatarMenuNotYou(
903 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT); 863 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT);
904 chrome::ShowSettings(browser_); 864 chrome::ShowSettings(browser_);
905 } else if (sender == switch_user_cancel_button_) { 865 } else if (sender == switch_user_cancel_button_) {
906 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); 866 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER);
907 ProfileMetrics::LogProfileNewAvatarMenuNotYou( 867 ProfileMetrics::LogProfileNewAvatarMenuNotYou(
908 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_BACK); 868 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_BACK);
909 } else { 869 } else {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 // This link can either mean show/hide the account management view, 910 // This link can either mean show/hide the account management view,
951 // depending on which view it is displayed. ShowView() will DCHECK if 911 // depending on which view it is displayed. ShowView() will DCHECK if
952 // the account management view is displayed for non signed-in users. 912 // the account management view is displayed for non signed-in users.
953 ShowViewFromMode( 913 ShowViewFromMode(
954 view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ? 914 view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ?
955 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER : 915 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER :
956 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT); 916 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT);
957 } else if (sender == add_account_link_) { 917 } else if (sender == add_account_link_) {
958 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT); 918 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT);
959 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT); 919 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT);
960 } else if (sender == tutorial_sync_settings_link_) {
961 LoginUIServiceFactory::GetForProfile(browser_->profile())->
962 SyncConfirmationUIClosed(LoginUIService::CONFIGURE_SYNC_FIRST);
963 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE;
964 ProfileMetrics::LogProfileNewAvatarMenuSignin(
965 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_SETTINGS);
966 } else if (sender == tutorial_not_you_link_) {
967 ProfileMetrics::LogProfileNewAvatarMenuUpgrade(
968 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_NOT_YOU);
969 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_SWITCH_USER);
970 } else {
971 DCHECK(sender == tutorial_learn_more_link_);
972 signin_ui_util::ShowSigninErrorLearnMorePage(browser_->profile());
973 } 920 }
974 } 921 }
975 922
976 void ProfileChooserView::StyledLabelLinkClicked(views::StyledLabel* label, 923 void ProfileChooserView::StyledLabelLinkClicked(views::StyledLabel* label,
977 const gfx::Range& range, 924 const gfx::Range& range,
978 int event_flags) { 925 int event_flags) {
979 chrome::ShowSettings(browser_); 926 chrome::ShowSettings(browser_);
980 } 927 }
981 928
982 views::View* ProfileChooserView::CreateProfileChooserView( 929 views::View* ProfileChooserView::CreateProfileChooserView(
983 AvatarMenu* avatar_menu) { 930 AvatarMenu* avatar_menu) {
984 views::View* view = new views::View(); 931 views::View* view = new views::View();
985 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth); 932 views::GridLayout* layout = CreateSingleColumnLayout(view, kFixedMenuWidth);
986 // Separate items into active and alternatives. 933 // Separate items into active and alternatives.
987 Indexes other_profiles; 934 Indexes other_profiles;
988 views::View* tutorial_view = NULL;
989 views::View* sync_error_view = NULL; 935 views::View* sync_error_view = NULL;
990 views::View* current_profile_view = NULL; 936 views::View* current_profile_view = NULL;
991 views::View* current_profile_accounts = NULL; 937 views::View* current_profile_accounts = NULL;
992 views::View* option_buttons_view = NULL; 938 views::View* option_buttons_view = NULL;
993 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) { 939 for (size_t i = 0; i < avatar_menu->GetNumberOfItems(); ++i) {
994 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i); 940 const AvatarMenu::Item& item = avatar_menu->GetItemAt(i);
995 if (item.active) { 941 if (item.active) {
996 option_buttons_view = CreateOptionsView( 942 option_buttons_view = CreateOptionsView(
997 item.signed_in && profiles::IsLockAvailable(browser_->profile()), 943 item.signed_in && profiles::IsLockAvailable(browser_->profile()),
998 avatar_menu); 944 avatar_menu);
999 current_profile_view = CreateCurrentProfileView(item, false); 945 current_profile_view = CreateCurrentProfileView(item, false);
1000 if (!IsProfileChooser(view_mode_)) 946 if (!IsProfileChooser(view_mode_))
1001 current_profile_accounts = CreateCurrentProfileAccountsView(item); 947 current_profile_accounts = CreateCurrentProfileAccountsView(item);
1002 sync_error_view = CreateSyncErrorViewIfNeeded(); 948 sync_error_view = CreateSyncErrorViewIfNeeded();
1003 } else { 949 } else {
1004 other_profiles.push_back(i); 950 other_profiles.push_back(i);
1005 } 951 }
1006 } 952 }
1007 953
1008 if (tutorial_view) {
1009 // TODO(mlerman): update UMA stats for the new tutorial.
1010 layout->StartRow(1, 0);
1011 layout->AddView(tutorial_view);
1012 } else {
1013 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE;
1014 }
1015
1016 if (sync_error_view) { 954 if (sync_error_view) {
1017 layout->StartRow(1, 0); 955 layout->StartRow(1, 0);
1018 layout->AddView(sync_error_view); 956 layout->AddView(sync_error_view);
1019 layout->StartRow(0, 0); 957 layout->StartRow(0, 0);
1020 layout->AddView(new views::Separator()); 958 layout->AddView(new views::Separator());
1021 } 959 }
1022 960
1023 if (!current_profile_view) { 961 if (!current_profile_view) {
1024 // Guest windows don't have an active profile. 962 // Guest windows don't have an active profile.
1025 current_profile_view = CreateGuestProfileView(); 963 current_profile_view = CreateGuestProfileView();
(...skipping 19 matching lines...) Expand all
1045 layout->StartRow(0, 0); 983 layout->StartRow(0, 0);
1046 layout->AddView(new views::Separator()); 984 layout->AddView(new views::Separator());
1047 985
1048 if (option_buttons_view) { 986 if (option_buttons_view) {
1049 layout->StartRow(0, 0); 987 layout->StartRow(0, 0);
1050 layout->AddView(option_buttons_view); 988 layout->AddView(option_buttons_view);
1051 } 989 }
1052 return view; 990 return view;
1053 } 991 }
1054 992
1055 void ProfileChooserView::DismissTutorial() {
1056 // Never shows the upgrade tutorial again if manually closed.
1057 if (tutorial_mode_ == profiles::TUTORIAL_MODE_WELCOME_UPGRADE) {
1058 browser_->profile()->GetPrefs()->SetInteger(
1059 prefs::kProfileAvatarTutorialShown,
1060 signin_ui_util::kUpgradeWelcomeTutorialShowMax + 1);
1061 }
1062
1063 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE;
1064 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER);
1065 }
1066
1067 views::View* ProfileChooserView::CreateTutorialViewIfNeeded(
1068 const AvatarMenu::Item& item) {
1069 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN)
1070 return CreateSigninConfirmationView();
1071
1072 if (tutorial_mode_ == profiles::TUTORIAL_MODE_SHOW_ERROR)
1073 return CreateSigninErrorView();
1074
1075 if (profiles::ShouldShowWelcomeUpgradeTutorial(
1076 browser_->profile(), tutorial_mode_)) {
1077 if (tutorial_mode_ != profiles::TUTORIAL_MODE_WELCOME_UPGRADE) {
1078 Profile* profile = browser_->profile();
1079 const int show_count = profile->GetPrefs()->GetInteger(
1080 prefs::kProfileAvatarTutorialShown);
1081 profile->GetPrefs()->SetInteger(
1082 prefs::kProfileAvatarTutorialShown, show_count + 1);
1083 }
1084
1085 return CreateWelcomeUpgradeTutorialView(item);
1086 }
1087
1088 return nullptr;
1089 }
1090
1091 views::View* ProfileChooserView::CreateTutorialView(
1092 profiles::TutorialMode tutorial_mode,
1093 const base::string16& title_text,
1094 const base::string16& content_text,
1095 const base::string16& link_text,
1096 const base::string16& button_text,
1097 bool stack_button,
1098 views::Link** link,
1099 views::LabelButton** button,
1100 views::ImageButton** close_button) {
1101 tutorial_mode_ = tutorial_mode;
1102
1103 // TODO(ananta)
1104 // Use the dialog framework to create a dialog here instead of manually
1105 // creating one.
1106 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
1107
1108 views::View* view = new views::View();
1109 view->set_background(views::Background::CreateSolidBackground(
1110 profiles::kAvatarTutorialBackgroundColor));
1111
1112 gfx::Insets dialog_insets = provider->GetInsetsMetric(
1113 views::INSETS_DIALOG_CONTENTS);
1114
1115 view->SetBorder(views::CreateEmptyBorder(dialog_insets));
1116
1117 // TODO(ananta)
1118 // This seems to add a double margin at the side. Investigate and remove if
1119 // so.
1120 views::GridLayout* layout = CreateSingleColumnLayout(
1121 view, kFixedMenuWidth - dialog_insets.width());
1122
1123 // Creates a second column set for buttons and links.
1124 views::ColumnSet* button_columns = layout->AddColumnSet(1);
1125 button_columns->AddColumn(views::GridLayout::LEADING,
1126 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0);
1127 button_columns->AddPaddingColumn(1,
1128 provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_HORIZONTAL));
1129 button_columns->AddColumn(views::GridLayout::TRAILING,
1130 views::GridLayout::CENTER, 0, views::GridLayout::USE_PREF, 0, 0);
1131
1132 // Adds title and close button if needed.
1133 const SkColor kTitleAndButtonTextColor = SK_ColorWHITE;
1134 views::Label* title_label = new views::Label(title_text);
1135 title_label->SetMultiLine(true);
1136 title_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1137 title_label->SetAutoColorReadabilityEnabled(false);
1138 title_label->SetEnabledColor(kTitleAndButtonTextColor);
1139 title_label->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList(
1140 ui::ResourceBundle::MediumFont));
1141
1142 if (close_button) {
1143 layout->StartRow(1, 1);
1144 layout->AddView(title_label);
1145 *close_button = new views::ImageButton(this);
1146 (*close_button)->SetImageAlignment(views::ImageButton::ALIGN_RIGHT,
1147 views::ImageButton::ALIGN_MIDDLE);
1148 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
1149 (*close_button)->SetImage(views::ImageButton::STATE_NORMAL,
1150 rb->GetImageSkiaNamed(IDR_CLOSE_1));
1151 (*close_button)->SetImage(views::ImageButton::STATE_HOVERED,
1152 rb->GetImageSkiaNamed(IDR_CLOSE_1_H));
1153 (*close_button)->SetImage(views::ImageButton::STATE_PRESSED,
1154 rb->GetImageSkiaNamed(IDR_CLOSE_1_P));
1155 layout->AddView(*close_button);
1156 } else {
1157 layout->StartRow(1, 0);
1158 layout->AddView(title_label);
1159 }
1160
1161 // Adds body content.
1162 views::Label* content_label = new views::Label(content_text);
1163 content_label->SetMultiLine(true);
1164 content_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1165 content_label->SetAutoColorReadabilityEnabled(false);
1166 content_label->SetEnabledColor(profiles::kAvatarTutorialContentTextColor);
1167
1168 const int related_control_vertical =
1169 provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL);
1170
1171 layout->StartRowWithPadding(1, 0, 0, related_control_vertical);
1172 layout->AddView(content_label);
1173
1174 // Adds links and buttons.
1175 bool has_button = !button_text.empty();
1176 if (has_button) {
1177 *button = views::MdTextButton::CreateSecondaryUiButton(this, button_text);
1178 if (ui::MaterialDesignController::IsSecondaryUiMaterial())
1179 (*button)->SetEnabledTextColors(kTitleAndButtonTextColor);
1180 else
1181 (*button)->SetHorizontalAlignment(gfx::ALIGN_CENTER);
1182 }
1183
1184 bool has_link = !link_text.empty();
1185 if (has_link) {
1186 *link = CreateLink(link_text, this);
1187 (*link)->SetHorizontalAlignment(gfx::ALIGN_LEFT);
1188 (*link)->SetAutoColorReadabilityEnabled(false);
1189 (*link)->SetEnabledColor(kTitleAndButtonTextColor);
1190 }
1191
1192 const int unrelated_control_vertical =
1193 provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL);
1194
1195 if (stack_button) {
1196 DCHECK(has_button);
1197 layout->StartRowWithPadding(1, 0, 0, unrelated_control_vertical);
1198 layout->AddView(*button);
1199 if (has_link) {
1200 layout->StartRowWithPadding(1, 0, 0, related_control_vertical);
1201 (*link)->SetHorizontalAlignment(gfx::ALIGN_CENTER);
1202 layout->AddView(*link);
1203 }
1204 } else {
1205 DCHECK(has_link || has_button);
1206 layout->StartRowWithPadding(1, 1, 0, unrelated_control_vertical);
1207 if (has_link)
1208 layout->AddView(*link);
1209 else
1210 layout->SkipColumns(1);
1211 if (has_button)
1212 layout->AddView(*button);
1213 else
1214 layout->SkipColumns(1);
1215 }
1216
1217 return view;
1218 }
1219
1220 views::View* ProfileChooserView::CreateSyncErrorViewIfNeeded() { 993 views::View* ProfileChooserView::CreateSyncErrorViewIfNeeded() {
1221 int content_string_id, button_string_id; 994 int content_string_id, button_string_id;
1222 views::LabelButton** button_out = nullptr; 995 views::LabelButton** button_out = nullptr;
1223 sync_ui_util::AvatarSyncErrorType error = 996 sync_ui_util::AvatarSyncErrorType error =
1224 sync_ui_util::GetMessagesForAvatarSyncError( 997 sync_ui_util::GetMessagesForAvatarSyncError(
1225 browser_->profile(), &content_string_id, &button_string_id); 998 browser_->profile(), &content_string_id, &button_string_id);
1226 switch (error) { 999 switch (error) {
1227 case sync_ui_util::MANAGED_USER_UNRECOVERABLE_ERROR: 1000 case sync_ui_util::MANAGED_USER_UNRECOVERABLE_ERROR:
1228 button_out = &sync_error_signout_button_; 1001 button_out = &sync_error_signout_button_;
1229 break; 1002 break;
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
1780 layout->AddPaddingRow(0, unrelated_vertical_spacing); 1553 layout->AddPaddingRow(0, unrelated_vertical_spacing);
1781 } 1554 }
1782 1555
1783 TitleCard* title_card = new TitleCard( 1556 TitleCard* title_card = new TitleCard(
1784 l10n_util::GetStringUTF16(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE), 1557 l10n_util::GetStringUTF16(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE),
1785 this, &account_removal_cancel_button_); 1558 this, &account_removal_cancel_button_);
1786 return TitleCard::AddPaddedTitleCard(view, title_card, 1559 return TitleCard::AddPaddedTitleCard(view, title_card,
1787 kFixedAccountRemovalViewWidth); 1560 kFixedAccountRemovalViewWidth);
1788 } 1561 }
1789 1562
1790 views::View* ProfileChooserView::CreateWelcomeUpgradeTutorialView(
1791 const AvatarMenu::Item& avatar_item) {
1792 ProfileMetrics::LogProfileNewAvatarMenuUpgrade(
1793 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_VIEW);
1794
1795 // For local profiles, the "Not you" link doesn't make sense.
1796 base::string16 link_message = avatar_item.signed_in ?
1797 l10n_util::GetStringFUTF16(IDS_PROFILES_NOT_YOU, avatar_item.name) :
1798 base::string16();
1799
1800 return CreateTutorialView(
1801 profiles::TUTORIAL_MODE_WELCOME_UPGRADE,
1802 l10n_util::GetStringUTF16(
1803 IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_TITLE),
1804 l10n_util::GetStringUTF16(
1805 IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_CONTENT_TEXT),
1806 link_message,
1807 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_WHATS_NEW_BUTTON),
1808 true /* stack_button */,
1809 &tutorial_not_you_link_,
1810 &tutorial_see_whats_new_button_,
1811 &tutorial_close_button_);
1812 }
1813
1814 views::View* ProfileChooserView::CreateSigninConfirmationView() {
1815 ProfileMetrics::LogProfileNewAvatarMenuSignin(
1816 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_VIEW);
1817
1818 return CreateTutorialView(
1819 profiles::TUTORIAL_MODE_CONFIRM_SIGNIN,
1820 l10n_util::GetStringUTF16(IDS_PROFILES_CONFIRM_SIGNIN_TUTORIAL_TITLE),
1821 l10n_util::GetStringUTF16(
1822 IDS_PROFILES_CONFIRM_SIGNIN_TUTORIAL_CONTENT_TEXT),
1823 l10n_util::GetStringUTF16(IDS_PROFILES_SYNC_SETTINGS_LINK),
1824 l10n_util::GetStringUTF16(IDS_PROFILES_TUTORIAL_OK_BUTTON),
1825 false /* stack_button */,
1826 &tutorial_sync_settings_link_,
1827 &tutorial_sync_settings_ok_button_,
1828 NULL /* close_button*/);
1829 }
1830
1831 views::View* ProfileChooserView::CreateSigninErrorView() {
1832 LoginUIService* login_ui_service =
1833 LoginUIServiceFactory::GetForProfile(browser_->profile());
1834 base::string16 last_login_result(login_ui_service->GetLastLoginResult());
1835 return CreateTutorialView(
1836 profiles::TUTORIAL_MODE_SHOW_ERROR,
1837 l10n_util::GetStringUTF16(IDS_PROFILES_ERROR_TUTORIAL_TITLE),
1838 last_login_result,
1839 l10n_util::GetStringUTF16(IDS_PROFILES_PROFILE_TUTORIAL_LEARN_MORE),
1840 base::string16(),
1841 false /* stack_button */,
1842 &tutorial_learn_more_link_,
1843 NULL,
1844 &tutorial_close_button_);
1845 }
1846
1847 views::View* ProfileChooserView::CreateSwitchUserView() { 1563 views::View* ProfileChooserView::CreateSwitchUserView() {
1848 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); 1564 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
1849 views::View* view = new views::View(); 1565 views::View* view = new views::View();
1850 views::GridLayout* layout = CreateSingleColumnLayout( 1566 views::GridLayout* layout = CreateSingleColumnLayout(
1851 view, kFixedSwitchUserViewWidth); 1567 view, kFixedSwitchUserViewWidth);
1852 views::ColumnSet* columns = layout->AddColumnSet(1); 1568 views::ColumnSet* columns = layout->AddColumnSet(1);
1853 gfx::Insets dialog_insets = provider->GetInsetsMetric( 1569 gfx::Insets dialog_insets = provider->GetInsetsMetric(
1854 views::INSETS_DIALOG_CONTENTS); 1570 views::INSETS_DIALOG_CONTENTS);
1855 columns->AddPaddingColumn(0, dialog_insets.left()); 1571 columns->AddPaddingColumn(0, dialog_insets.left());
1856 int label_width = kFixedSwitchUserViewWidth - dialog_insets.width(); 1572 int label_width = kFixedSwitchUserViewWidth - dialog_insets.width();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1909 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 1625 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
1910 IncognitoModePrefs::DISABLED; 1626 IncognitoModePrefs::DISABLED;
1911 return incognito_available && !browser_->profile()->IsGuestSession(); 1627 return incognito_available && !browser_->profile()->IsGuestSession();
1912 } 1628 }
1913 1629
1914 void ProfileChooserView::PostActionPerformed( 1630 void ProfileChooserView::PostActionPerformed(
1915 ProfileMetrics::ProfileDesktopMenu action_performed) { 1631 ProfileMetrics::ProfileDesktopMenu action_performed) {
1916 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 1632 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
1917 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 1633 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
1918 } 1634 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.h ('k') | chrome/browser/ui/views/profiles/user_manager_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698