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" |
11 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 11 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
12 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 12 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
13 #include "chrome/browser/profiles/profile_info_cache.h" | 13 #include "chrome/browser/profiles/profile_info_cache.h" |
14 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
15 #include "chrome/browser/profiles/profile_metrics.h" | 15 #include "chrome/browser/profiles/profile_metrics.h" |
16 #include "chrome/browser/profiles/profile_window.h" | 16 #include "chrome/browser/profiles/profile_window.h" |
17 #include "chrome/browser/profiles/profiles_state.h" | 17 #include "chrome/browser/profiles/profiles_state.h" |
18 #include "chrome/browser/signin/chrome_signin_helper.h" | 18 #include "chrome/browser/signin/chrome_signin_helper.h" |
19 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 19 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
20 #include "chrome/browser/signin/signin_error_controller_factory.h" | 20 #include "chrome/browser/signin/signin_error_controller_factory.h" |
21 #include "chrome/browser/signin/signin_manager_factory.h" | 21 #include "chrome/browser/signin/signin_manager_factory.h" |
22 #include "chrome/browser/signin/signin_promo.h" | 22 #include "chrome/browser/signin/signin_promo.h" |
23 #include "chrome/browser/signin/signin_ui_util.h" | 23 #include "chrome/browser/signin/signin_ui_util.h" |
24 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
25 #include "chrome/browser/ui/browser_commands.h" | 25 #include "chrome/browser/ui/browser_commands.h" |
26 #include "chrome/browser/ui/browser_dialogs.h" | 26 #include "chrome/browser/ui/browser_dialogs.h" |
27 #include "chrome/browser/ui/chrome_pages.h" | 27 #include "chrome/browser/ui/chrome_pages.h" |
28 #include "chrome/browser/ui/singleton_tabs.h" | 28 #include "chrome/browser/ui/singleton_tabs.h" |
29 #include "chrome/browser/ui/user_manager.h" | 29 #include "chrome/browser/ui/user_manager.h" |
| 30 #include "chrome/browser/ui/views/profiles/signin_view_controller.h" |
30 #include "chrome/browser/ui/views/profiles/user_manager_view.h" | 31 #include "chrome/browser/ui/views/profiles/user_manager_view.h" |
31 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 32 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
32 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 33 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
33 #include "chrome/common/pref_names.h" | 34 #include "chrome/common/pref_names.h" |
34 #include "chrome/common/url_constants.h" | 35 #include "chrome/common/url_constants.h" |
35 #include "chrome/grit/chromium_strings.h" | 36 #include "chrome/grit/chromium_strings.h" |
36 #include "chrome/grit/generated_resources.h" | 37 #include "chrome/grit/generated_resources.h" |
37 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 38 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
38 #include "components/signin/core/browser/signin_error_controller.h" | 39 #include "components/signin/core/browser/signin_error_controller.h" |
39 #include "components/signin/core/browser/signin_header_helper.h" | 40 #include "components/signin/core/browser/signin_header_helper.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 #include "ui/views/layout/grid_layout.h" | 73 #include "ui/views/layout/grid_layout.h" |
73 #include "ui/views/layout/layout_constants.h" | 74 #include "ui/views/layout/layout_constants.h" |
74 #include "ui/views/widget/widget.h" | 75 #include "ui/views/widget/widget.h" |
75 | 76 |
76 namespace { | 77 namespace { |
77 | 78 |
78 // Helpers -------------------------------------------------------------------- | 79 // Helpers -------------------------------------------------------------------- |
79 | 80 |
80 const int kFixedMenuWidth = 250; | 81 const int kFixedMenuWidth = 250; |
81 const int kButtonHeight = 32; | 82 const int kButtonHeight = 32; |
82 const int kPasswordCombinedFixedGaiaViewHeight = 440; | |
83 const int kPasswordCombinedFixedGaiaViewWidth = 360; | 83 const int kPasswordCombinedFixedGaiaViewWidth = 360; |
84 const int kFixedGaiaViewHeight = 512; | |
85 const int kFixedGaiaViewWidth = 448; | 84 const int kFixedGaiaViewWidth = 448; |
86 const int kFixedAccountRemovalViewWidth = 280; | 85 const int kFixedAccountRemovalViewWidth = 280; |
87 const int kFixedSwitchUserViewWidth = 320; | 86 const int kFixedSwitchUserViewWidth = 320; |
88 const int kLargeImageSide = 88; | 87 const int kLargeImageSide = 88; |
89 | 88 |
90 const int kVerticalSpacing = 16; | 89 const int kVerticalSpacing = 16; |
91 | 90 |
92 const int kTitleViewNativeWidgetOffset = 8; | 91 const int kTitleViewNativeWidgetOffset = 8; |
93 | 92 |
94 bool IsProfileChooser(profiles::BubbleViewMode mode) { | 93 bool IsProfileChooser(profiles::BubbleViewMode mode) { |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 profile->IsChild() | 586 profile->IsChild() |
588 ? new ProfileBadge(gfx::VectorIconId::ACCOUNT_CHILD_INVERT, 26) | 587 ? new ProfileBadge(gfx::VectorIconId::ACCOUNT_CHILD_INVERT, 26) |
589 : new ProfileBadge(gfx::VectorIconId::SUPERVISOR_ACCOUNT, 20); | 588 : new ProfileBadge(gfx::VectorIconId::SUPERVISOR_ACCOUNT, 20); |
590 | 589 |
591 return gfx::ImageSkia(badge, badge->size()); | 590 return gfx::ImageSkia(badge, badge->size()); |
592 } | 591 } |
593 | 592 |
594 // ProfileChooserView --------------------------------------------------------- | 593 // ProfileChooserView --------------------------------------------------------- |
595 | 594 |
596 // static | 595 // static |
597 ProfileChooserView* ProfileChooserView::profile_bubble_ = NULL; | 596 ProfileChooserView* ProfileChooserView::profile_bubble_ = nullptr; |
598 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; | 597 bool ProfileChooserView::close_on_deactivate_for_testing_ = true; |
599 | 598 |
600 // static | 599 // static |
601 void ProfileChooserView::ShowBubble( | 600 void ProfileChooserView::ShowBubble( |
602 profiles::BubbleViewMode view_mode, | 601 profiles::BubbleViewMode view_mode, |
603 profiles::TutorialMode tutorial_mode, | 602 profiles::TutorialMode tutorial_mode, |
604 const signin::ManageAccountsParams& manage_accounts_params, | 603 const signin::ManageAccountsParams& manage_accounts_params, |
605 views::View* anchor_view, | 604 views::View* anchor_view, |
606 views::BubbleBorder::Arrow arrow, | 605 views::BubbleBorder::Arrow arrow, |
607 views::BubbleBorder::BubbleAlignment border_alignment, | 606 views::BubbleBorder::BubbleAlignment border_alignment, |
608 Browser* browser) { | 607 Browser* browser) { |
609 // Don't start creating the view if it would be an empty fast user switcher. | 608 // Don't start creating the view if it would be an empty fast user switcher. |
610 // It has to happen here to prevent the view system from creating an empty | 609 // It has to happen here to prevent the view system from creating an empty |
611 // container. | 610 // container. |
612 if (view_mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER && | 611 if (view_mode == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER && |
613 !profiles::HasProfileSwitchTargets(browser->profile())) { | 612 !profiles::HasProfileSwitchTargets(browser->profile())) { |
614 return; | 613 return; |
615 } | 614 } |
616 | 615 |
617 if (IsShowing()) { | 616 if (IsShowing()) { |
618 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) { | 617 if (tutorial_mode != profiles::TUTORIAL_MODE_NONE) { |
619 profile_bubble_->tutorial_mode_ = tutorial_mode; | 618 profile_bubble_->tutorial_mode_ = tutorial_mode; |
620 profile_bubble_->ShowView(view_mode, profile_bubble_->avatar_menu_.get()); | 619 profile_bubble_->ShowViewFromMode(view_mode); |
621 } | 620 } |
622 return; | 621 return; |
623 } | 622 } |
624 | 623 |
625 profile_bubble_ = new ProfileChooserView(anchor_view, arrow, browser, | 624 profile_bubble_ = new ProfileChooserView(anchor_view, arrow, browser, |
626 view_mode, tutorial_mode, manage_accounts_params.service_type); | 625 view_mode, tutorial_mode, manage_accounts_params.service_type); |
627 views::BubbleDelegateView::CreateBubble(profile_bubble_); | 626 views::BubbleDelegateView::CreateBubble(profile_bubble_); |
628 profile_bubble_->set_close_on_deactivate(close_on_deactivate_for_testing_); | 627 profile_bubble_->set_close_on_deactivate(close_on_deactivate_for_testing_); |
629 profile_bubble_->SetAlignment(border_alignment); | 628 profile_bubble_->SetAlignment(border_alignment); |
630 profile_bubble_->GetWidget()->Show(); | 629 profile_bubble_->GetWidget()->Show(); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 switches::IsEnableAccountConsistency() && | 714 switches::IsEnableAccountConsistency() && |
716 avatar_menu_->GetItemAt(avatar_menu_->GetActiveProfileIndex()). | 715 avatar_menu_->GetItemAt(avatar_menu_->GetActiveProfileIndex()). |
717 signed_in) { | 716 signed_in) { |
718 view_mode_ = profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT; | 717 view_mode_ = profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT; |
719 } | 718 } |
720 | 719 |
721 // The arrow keys can be used to tab between items. | 720 // The arrow keys can be used to tab between items. |
722 AddAccelerator(ui::Accelerator(ui::VKEY_DOWN, ui::EF_NONE)); | 721 AddAccelerator(ui::Accelerator(ui::VKEY_DOWN, ui::EF_NONE)); |
723 AddAccelerator(ui::Accelerator(ui::VKEY_UP, ui::EF_NONE)); | 722 AddAccelerator(ui::Accelerator(ui::VKEY_UP, ui::EF_NONE)); |
724 | 723 |
725 ShowView(view_mode_, avatar_menu_.get()); | 724 ShowViewFromMode(view_mode_); |
726 } | 725 } |
727 | 726 |
728 void ProfileChooserView::OnAvatarMenuChanged( | 727 void ProfileChooserView::OnAvatarMenuChanged( |
729 AvatarMenu* avatar_menu) { | 728 AvatarMenu* avatar_menu) { |
730 if (IsProfileChooser(view_mode_) || | 729 if (IsProfileChooser(view_mode_) || |
731 view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { | 730 view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { |
732 // Refresh the view with the new menu. We can't just update the local copy | 731 // Refresh the view with the new menu. We can't just update the local copy |
733 // as this may have been triggered by a sign out action, in which case | 732 // as this may have been triggered by a sign out action, in which case |
734 // the view is being destroyed. | 733 // the view is being destroyed. |
735 ShowView(view_mode_, avatar_menu); | 734 ShowView(view_mode_, avatar_menu); |
736 } | 735 } |
737 } | 736 } |
738 | 737 |
739 void ProfileChooserView::OnRefreshTokenAvailable( | 738 void ProfileChooserView::OnRefreshTokenAvailable( |
740 const std::string& account_id) { | 739 const std::string& account_id) { |
741 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT || | 740 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT || |
742 view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || | 741 view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || |
743 view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) { | 742 view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) { |
744 // The account management UI is only available through the | 743 // The account management UI is only available through the |
745 // --enable-account-consistency flag. | 744 // --enable-account-consistency flag. |
746 ShowView(switches::IsEnableAccountConsistency() ? | 745 ShowViewFromMode(switches::IsEnableAccountConsistency() ? |
747 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : | 746 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : |
748 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); | 747 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); |
749 } | 748 } |
750 } | 749 } |
751 | 750 |
752 void ProfileChooserView::OnRefreshTokenRevoked(const std::string& account_id) { | 751 void ProfileChooserView::OnRefreshTokenRevoked(const std::string& account_id) { |
753 // Refresh the account management view when an account is removed from the | 752 // Refresh the account management view when an account is removed from the |
754 // profile. | 753 // profile. |
755 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) | 754 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) |
756 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); | 755 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT); |
757 } | 756 } |
758 | 757 |
759 void ProfileChooserView::ShowView(profiles::BubbleViewMode view_to_display, | 758 void ProfileChooserView::ShowView(profiles::BubbleViewMode view_to_display, |
760 AvatarMenu* avatar_menu) { | 759 AvatarMenu* avatar_menu) { |
761 // The account management view should only be displayed if the active profile | 760 // The account management view should only be displayed if the active profile |
762 // is signed in. | 761 // is signed in. |
763 if (view_to_display == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { | 762 if (view_to_display == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { |
764 DCHECK(switches::IsEnableAccountConsistency()); | 763 DCHECK(switches::IsEnableAccountConsistency()); |
765 const AvatarMenu::Item& active_item = avatar_menu->GetItemAt( | 764 const AvatarMenu::Item& active_item = avatar_menu->GetItemAt( |
766 avatar_menu->GetActiveProfileIndex()); | 765 avatar_menu->GetActiveProfileIndex()); |
(...skipping 14 matching lines...) Expand all Loading... |
781 views::GridLayout* layout = nullptr; | 780 views::GridLayout* layout = nullptr; |
782 views::View* sub_view = nullptr; | 781 views::View* sub_view = nullptr; |
783 views::View* view_to_focus = nullptr; | 782 views::View* view_to_focus = nullptr; |
784 switch (view_mode_) { | 783 switch (view_mode_) { |
785 case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN: | 784 case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN: |
786 case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: | 785 case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: |
787 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: { | 786 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: { |
788 const int width = switches::UsePasswordSeparatedSigninFlow() | 787 const int width = switches::UsePasswordSeparatedSigninFlow() |
789 ? kFixedGaiaViewWidth : kPasswordCombinedFixedGaiaViewWidth; | 788 ? kFixedGaiaViewWidth : kPasswordCombinedFixedGaiaViewWidth; |
790 layout = CreateSingleColumnLayout(this, width); | 789 layout = CreateSingleColumnLayout(this, width); |
| 790 DCHECK(!switches::UsePasswordSeparatedSigninFlow()); |
791 sub_view = CreateGaiaSigninView(&view_to_focus); | 791 sub_view = CreateGaiaSigninView(&view_to_focus); |
792 break; | 792 break; |
793 } | 793 } |
794 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: | 794 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: |
795 layout = CreateSingleColumnLayout(this, kFixedAccountRemovalViewWidth); | 795 layout = CreateSingleColumnLayout(this, kFixedAccountRemovalViewWidth); |
796 sub_view = CreateAccountRemovalView(); | 796 sub_view = CreateAccountRemovalView(); |
797 break; | 797 break; |
798 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: | 798 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: |
799 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); | 799 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); |
800 sub_view = CreateSwitchUserView(); | 800 sub_view = CreateSwitchUserView(); |
(...skipping 13 matching lines...) Expand all Loading... |
814 | 814 |
815 layout->StartRow(1, 0); | 815 layout->StartRow(1, 0); |
816 layout->AddView(sub_view); | 816 layout->AddView(sub_view); |
817 Layout(); | 817 Layout(); |
818 if (GetBubbleFrameView()) | 818 if (GetBubbleFrameView()) |
819 SizeToContents(); | 819 SizeToContents(); |
820 if (view_to_focus) | 820 if (view_to_focus) |
821 view_to_focus->RequestFocus(); | 821 view_to_focus->RequestFocus(); |
822 } | 822 } |
823 | 823 |
| 824 void ProfileChooserView::ShowViewFromMode(profiles::BubbleViewMode mode) { |
| 825 if (SigninViewController::ShouldShowModalSigninForMode(mode)) { |
| 826 BrowserWindow::AvatarBubbleMode converted_mode = |
| 827 BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT; |
| 828 if (mode == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN) { |
| 829 converted_mode = BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN; |
| 830 } else if (mode == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT) { |
| 831 converted_mode = BrowserWindow::AVATAR_BUBBLE_MODE_ADD_ACCOUNT; |
| 832 } else if (mode == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) { |
| 833 converted_mode = BrowserWindow::AVATAR_BUBBLE_MODE_REAUTH; |
| 834 } |
| 835 |
| 836 browser_->window()->ShowModalSigninWindow(converted_mode); |
| 837 } else { |
| 838 ShowView(mode, avatar_menu_.get()); |
| 839 } |
| 840 } |
| 841 |
824 void ProfileChooserView::WindowClosing() { | 842 void ProfileChooserView::WindowClosing() { |
825 DCHECK_EQ(profile_bubble_, this); | 843 DCHECK_EQ(profile_bubble_, this); |
826 profile_bubble_ = NULL; | 844 profile_bubble_ = NULL; |
827 | 845 |
828 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) { | 846 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) { |
829 LoginUIServiceFactory::GetForProfile(browser_->profile())-> | 847 LoginUIServiceFactory::GetForProfile(browser_->profile())-> |
830 SyncConfirmationUIClosed(false /* configure_sync_first */); | 848 SyncConfirmationUIClosed(false /* configure_sync_first */); |
831 } | 849 } |
832 } | 850 } |
833 | 851 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 } | 883 } |
866 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER); | 884 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER); |
867 } else if (sender == go_incognito_button_) { | 885 } else if (sender == go_incognito_button_) { |
868 DCHECK(ShouldShowGoIncognito()); | 886 DCHECK(ShouldShowGoIncognito()); |
869 chrome::NewIncognitoWindow(browser_); | 887 chrome::NewIncognitoWindow(browser_); |
870 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_GO_INCOGNITO); | 888 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_GO_INCOGNITO); |
871 } else if (sender == lock_button_) { | 889 } else if (sender == lock_button_) { |
872 profiles::LockProfile(browser_->profile()); | 890 profiles::LockProfile(browser_->profile()); |
873 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK); | 891 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK); |
874 } else if (sender == auth_error_email_button_) { | 892 } else if (sender == auth_error_email_button_) { |
875 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH, avatar_menu_.get()); | 893 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH); |
876 } else if (sender == tutorial_sync_settings_ok_button_) { | 894 } else if (sender == tutorial_sync_settings_ok_button_) { |
877 LoginUIServiceFactory::GetForProfile(browser_->profile())-> | 895 LoginUIServiceFactory::GetForProfile(browser_->profile())-> |
878 SyncConfirmationUIClosed(false /* configure_sync_first */); | 896 SyncConfirmationUIClosed(false /* configure_sync_first */); |
879 DismissTutorial(); | 897 DismissTutorial(); |
880 ProfileMetrics::LogProfileNewAvatarMenuSignin( | 898 ProfileMetrics::LogProfileNewAvatarMenuSignin( |
881 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_OK); | 899 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_OK); |
882 } else if (sender == tutorial_close_button_) { | 900 } else if (sender == tutorial_close_button_) { |
883 DCHECK(tutorial_mode_ != profiles::TUTORIAL_MODE_NONE && | 901 DCHECK(tutorial_mode_ != profiles::TUTORIAL_MODE_NONE && |
884 tutorial_mode_ != profiles::TUTORIAL_MODE_CONFIRM_SIGNIN); | 902 tutorial_mode_ != profiles::TUTORIAL_MODE_CONFIRM_SIGNIN); |
885 DismissTutorial(); | 903 DismissTutorial(); |
886 } else if (sender == tutorial_see_whats_new_button_) { | 904 } else if (sender == tutorial_see_whats_new_button_) { |
887 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( | 905 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( |
888 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_WHATS_NEW); | 906 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_WHATS_NEW); |
889 UserManager::Show(base::FilePath(), | 907 UserManager::Show(base::FilePath(), |
890 profiles::USER_MANAGER_TUTORIAL_OVERVIEW, | 908 profiles::USER_MANAGER_TUTORIAL_OVERVIEW, |
891 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | 909 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
892 } else if (sender == remove_account_button_) { | 910 } else if (sender == remove_account_button_) { |
893 RemoveAccount(); | 911 RemoveAccount(); |
894 } else if (sender == account_removal_cancel_button_) { | 912 } else if (sender == account_removal_cancel_button_) { |
895 account_id_to_remove_.clear(); | 913 account_id_to_remove_.clear(); |
896 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); | 914 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT); |
897 } else if (sender == gaia_signin_cancel_button_) { | 915 } else if (sender == gaia_signin_cancel_button_) { |
898 // The account management view is only available with the | 916 // The account management view is only available with the |
899 // --enable-account-consistency flag. | 917 // --enable-account-consistency flag. |
900 bool account_management_available = | 918 bool account_management_available = |
901 SigninManagerFactory::GetForProfile(browser_->profile())-> | 919 SigninManagerFactory::GetForProfile(browser_->profile())-> |
902 IsAuthenticated() && | 920 IsAuthenticated() && |
903 switches::IsEnableAccountConsistency(); | 921 switches::IsEnableAccountConsistency(); |
904 ShowView(account_management_available ? | 922 ShowViewFromMode(account_management_available ? |
905 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : | 923 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : |
906 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); | 924 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); |
907 } else if (sender == current_profile_photo_) { | 925 } else if (sender == current_profile_photo_) { |
908 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); | 926 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); |
909 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); | 927 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); |
910 } else if (sender == signin_current_profile_link_) { | 928 } else if (sender == signin_current_profile_link_) { |
911 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get()); | 929 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN); |
912 } else if (sender == add_person_button_) { | 930 } else if (sender == add_person_button_) { |
913 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 931 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
914 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON); | 932 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON); |
915 UserManager::Show(base::FilePath(), | 933 UserManager::Show(base::FilePath(), |
916 profiles::USER_MANAGER_NO_TUTORIAL, | 934 profiles::USER_MANAGER_NO_TUTORIAL, |
917 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | 935 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
918 } else if (sender == disconnect_button_) { | 936 } else if (sender == disconnect_button_) { |
919 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 937 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
920 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT); | 938 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT); |
921 chrome::ShowSettings(browser_); | 939 chrome::ShowSettings(browser_); |
922 } else if (sender == switch_user_cancel_button_) { | 940 } else if (sender == switch_user_cancel_button_) { |
923 ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); | 941 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); |
924 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 942 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
925 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_BACK); | 943 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_BACK); |
926 } else { | 944 } else { |
927 // Either one of the "other profiles", or one of the profile accounts | 945 // Either one of the "other profiles", or one of the profile accounts |
928 // buttons was pressed. | 946 // buttons was pressed. |
929 ButtonIndexes::const_iterator profile_match = | 947 ButtonIndexes::const_iterator profile_match = |
930 open_other_profile_indexes_map_.find(sender); | 948 open_other_profile_indexes_map_.find(sender); |
931 if (profile_match != open_other_profile_indexes_map_.end()) { | 949 if (profile_match != open_other_profile_indexes_map_.end()) { |
932 avatar_menu_->SwitchToProfile( | 950 avatar_menu_->SwitchToProfile( |
933 profile_match->second, | 951 profile_match->second, |
934 ui::DispositionFromEventFlags(event.flags()) == NEW_WINDOW, | 952 ui::DispositionFromEventFlags(event.flags()) == NEW_WINDOW, |
935 ProfileMetrics::SWITCH_PROFILE_ICON); | 953 ProfileMetrics::SWITCH_PROFILE_ICON); |
936 } else { | 954 } else { |
937 // This was a profile accounts button. | 955 // This was a profile accounts button. |
938 AccountButtonIndexes::const_iterator account_match = | 956 AccountButtonIndexes::const_iterator account_match = |
939 delete_account_button_map_.find(sender); | 957 delete_account_button_map_.find(sender); |
940 if (account_match != delete_account_button_map_.end()) { | 958 if (account_match != delete_account_button_map_.end()) { |
941 account_id_to_remove_ = account_match->second; | 959 account_id_to_remove_ = account_match->second; |
942 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL, | 960 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL); |
943 avatar_menu_.get()); | |
944 } else { | 961 } else { |
945 account_match = reauth_account_button_map_.find(sender); | 962 account_match = reauth_account_button_map_.find(sender); |
946 DCHECK(account_match != reauth_account_button_map_.end()); | 963 DCHECK(account_match != reauth_account_button_map_.end()); |
947 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH, avatar_menu_.get()); | 964 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH); |
948 } | 965 } |
949 } | 966 } |
950 } | 967 } |
951 } | 968 } |
952 | 969 |
953 void ProfileChooserView::RemoveAccount() { | 970 void ProfileChooserView::RemoveAccount() { |
954 DCHECK(!account_id_to_remove_.empty()); | 971 DCHECK(!account_id_to_remove_.empty()); |
955 ProfileOAuth2TokenService* oauth2_token_service = | 972 ProfileOAuth2TokenService* oauth2_token_service = |
956 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); | 973 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); |
957 if (oauth2_token_service) { | 974 if (oauth2_token_service) { |
958 oauth2_token_service->RevokeCredentials(account_id_to_remove_); | 975 oauth2_token_service->RevokeCredentials(account_id_to_remove_); |
959 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_REMOVE_ACCT); | 976 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_REMOVE_ACCT); |
960 } | 977 } |
961 account_id_to_remove_.clear(); | 978 account_id_to_remove_.clear(); |
962 | 979 |
963 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); | 980 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT); |
964 } | 981 } |
965 | 982 |
966 void ProfileChooserView::LinkClicked(views::Link* sender, int event_flags) { | 983 void ProfileChooserView::LinkClicked(views::Link* sender, int event_flags) { |
967 if (sender == manage_accounts_link_) { | 984 if (sender == manage_accounts_link_) { |
968 // This link can either mean show/hide the account management view, | 985 // This link can either mean show/hide the account management view, |
969 // depending on which view it is displayed. ShowView() will DCHECK if | 986 // depending on which view it is displayed. ShowView() will DCHECK if |
970 // the account management view is displayed for non signed-in users. | 987 // the account management view is displayed for non signed-in users. |
971 ShowView( | 988 ShowViewFromMode( |
972 view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ? | 989 view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ? |
973 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER : | 990 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER : |
974 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, | 991 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT); |
975 avatar_menu_.get()); | |
976 } else if (sender == add_account_link_) { | 992 } else if (sender == add_account_link_) { |
977 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); | 993 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT); |
978 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT); | 994 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT); |
979 } else if (sender == tutorial_sync_settings_link_) { | 995 } else if (sender == tutorial_sync_settings_link_) { |
980 LoginUIServiceFactory::GetForProfile(browser_->profile())-> | 996 LoginUIServiceFactory::GetForProfile(browser_->profile())-> |
981 SyncConfirmationUIClosed(true /* configure_sync_first */); | 997 SyncConfirmationUIClosed(true /* configure_sync_first */); |
982 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; | 998 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; |
983 ProfileMetrics::LogProfileNewAvatarMenuSignin( | 999 ProfileMetrics::LogProfileNewAvatarMenuSignin( |
984 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_SETTINGS); | 1000 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_SETTINGS); |
985 } else if (sender == tutorial_not_you_link_) { | 1001 } else if (sender == tutorial_not_you_link_) { |
986 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( | 1002 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( |
987 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_NOT_YOU); | 1003 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_NOT_YOU); |
988 ShowView(profiles::BUBBLE_VIEW_MODE_SWITCH_USER, avatar_menu_.get()); | 1004 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_SWITCH_USER); |
989 } else { | 1005 } else { |
990 DCHECK(sender == tutorial_learn_more_link_); | 1006 DCHECK(sender == tutorial_learn_more_link_); |
991 signin_ui_util::ShowSigninErrorLearnMorePage(browser_->profile()); | 1007 signin_ui_util::ShowSigninErrorLearnMorePage(browser_->profile()); |
992 } | 1008 } |
993 } | 1009 } |
994 | 1010 |
995 void ProfileChooserView::StyledLabelLinkClicked(views::StyledLabel* label, | 1011 void ProfileChooserView::StyledLabelLinkClicked(views::StyledLabel* label, |
996 const gfx::Range& range, | 1012 const gfx::Range& range, |
997 int event_flags) { | 1013 int event_flags) { |
998 chrome::ShowSettings(browser_); | 1014 chrome::ShowSettings(browser_); |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1136 signin_ui_util::kUpgradeWelcomeTutorialShowMax + 1); | 1152 signin_ui_util::kUpgradeWelcomeTutorialShowMax + 1); |
1137 } | 1153 } |
1138 | 1154 |
1139 if (tutorial_mode_ == profiles::TUTORIAL_MODE_RIGHT_CLICK_SWITCHING) { | 1155 if (tutorial_mode_ == profiles::TUTORIAL_MODE_RIGHT_CLICK_SWITCHING) { |
1140 PrefService* local_state = g_browser_process->local_state(); | 1156 PrefService* local_state = g_browser_process->local_state(); |
1141 local_state->SetBoolean( | 1157 local_state->SetBoolean( |
1142 prefs::kProfileAvatarRightClickTutorialDismissed, true); | 1158 prefs::kProfileAvatarRightClickTutorialDismissed, true); |
1143 } | 1159 } |
1144 | 1160 |
1145 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; | 1161 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; |
1146 ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); | 1162 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER); |
1147 } | 1163 } |
1148 | 1164 |
1149 views::View* ProfileChooserView::CreateTutorialViewIfNeeded( | 1165 views::View* ProfileChooserView::CreateTutorialViewIfNeeded( |
1150 const AvatarMenu::Item& item) { | 1166 const AvatarMenu::Item& item) { |
1151 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) | 1167 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) |
1152 return CreateSigninConfirmationView(); | 1168 return CreateSigninConfirmationView(); |
1153 | 1169 |
1154 if (tutorial_mode_ == profiles::TUTORIAL_MODE_SHOW_ERROR) | 1170 if (tutorial_mode_ == profiles::TUTORIAL_MODE_SHOW_ERROR) |
1155 return CreateSigninErrorView(); | 1171 return CreateSigninErrorView(); |
1156 | 1172 |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1607 email_button->set_notify_enter_exit_on_child(true); | 1623 email_button->set_notify_enter_exit_on_child(true); |
1608 email_button->AddChildView(delete_button); | 1624 email_button->AddChildView(delete_button); |
1609 | 1625 |
1610 // Save the original email address, as the button text could be elided. | 1626 // Save the original email address, as the button text could be elided. |
1611 delete_account_button_map_[delete_button] = account_id; | 1627 delete_account_button_map_[delete_button] = account_id; |
1612 } | 1628 } |
1613 } | 1629 } |
1614 | 1630 |
1615 views::View* ProfileChooserView::CreateGaiaSigninView( | 1631 views::View* ProfileChooserView::CreateGaiaSigninView( |
1616 views::View** signin_content_view) { | 1632 views::View** signin_content_view) { |
1617 GURL url; | 1633 views::WebView* web_view = SigninViewController::CreateGaiaWebView( |
| 1634 this, view_mode_, browser_->profile()); |
| 1635 |
1618 int message_id; | 1636 int message_id; |
1619 | |
1620 switch (view_mode_) { | 1637 switch (view_mode_) { |
1621 case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN: | 1638 case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN: |
1622 url = signin::GetPromoURL(signin_metrics::SOURCE_AVATAR_BUBBLE_SIGN_IN, | |
1623 false /* auto_close */, | |
1624 true /* is_constrained */); | |
1625 message_id = IDS_PROFILES_GAIA_SIGNIN_TITLE; | 1639 message_id = IDS_PROFILES_GAIA_SIGNIN_TITLE; |
1626 break; | 1640 break; |
1627 case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: | 1641 case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: |
1628 url = signin::GetPromoURL( | |
1629 signin_metrics::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT, | |
1630 false /* auto_close */, | |
1631 true /* is_constrained */); | |
1632 message_id = IDS_PROFILES_GAIA_ADD_ACCOUNT_TITLE; | 1642 message_id = IDS_PROFILES_GAIA_ADD_ACCOUNT_TITLE; |
1633 break; | 1643 break; |
1634 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: { | 1644 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: { |
1635 DCHECK(HasAuthError(browser_->profile())); | |
1636 url = signin::GetReauthURL(browser_->profile(), | |
1637 GetAuthErrorAccountId(browser_->profile())); | |
1638 message_id = IDS_PROFILES_GAIA_REAUTH_TITLE; | 1645 message_id = IDS_PROFILES_GAIA_REAUTH_TITLE; |
1639 break; | 1646 break; |
1640 } | 1647 } |
1641 default: | 1648 default: |
1642 NOTREACHED() << "Called with invalid mode=" << view_mode_; | 1649 NOTREACHED() << "Called with invalid mode=" << view_mode_; |
1643 return NULL; | 1650 return NULL; |
1644 } | 1651 } |
1645 | 1652 |
1646 // Adds Gaia signin webview. | |
1647 const gfx::Size pref_size = switches::UsePasswordSeparatedSigninFlow() | |
1648 ? gfx::Size(kFixedGaiaViewWidth, kFixedGaiaViewHeight) | |
1649 : gfx::Size(kPasswordCombinedFixedGaiaViewWidth, | |
1650 kPasswordCombinedFixedGaiaViewHeight); | |
1651 Profile* profile = browser_->profile(); | |
1652 views::WebView* web_view = new views::WebView(profile); | |
1653 web_view->LoadInitialURL(url); | |
1654 web_view->GetWebContents()->SetDelegate(this); | |
1655 web_view->SetPreferredSize(pref_size); | |
1656 content::RenderWidgetHostView* rwhv = | |
1657 web_view->GetWebContents()->GetRenderWidgetHostView(); | |
1658 if (rwhv) | |
1659 rwhv->SetBackgroundColor(profiles::kAvatarBubbleGaiaBackgroundColor); | |
1660 | |
1661 if (signin_content_view) | 1653 if (signin_content_view) |
1662 *signin_content_view = web_view; | 1654 *signin_content_view = web_view; |
1663 | 1655 |
1664 if (switches::UsePasswordSeparatedSigninFlow()) { | |
1665 gaia_signin_cancel_button_ = CreateBackButton(this); | |
1666 HostView* host = new HostView(); | |
1667 host->Initialize(gaia_signin_cancel_button_, web_view); | |
1668 return host; | |
1669 } | |
1670 | |
1671 TitleCard* title_card = new TitleCard(l10n_util::GetStringUTF16(message_id), | 1656 TitleCard* title_card = new TitleCard(l10n_util::GetStringUTF16(message_id), |
1672 this, | 1657 this, |
1673 &gaia_signin_cancel_button_); | 1658 &gaia_signin_cancel_button_); |
1674 return TitleCard::AddPaddedTitleCard( | 1659 return TitleCard::AddPaddedTitleCard( |
1675 web_view, title_card, kPasswordCombinedFixedGaiaViewWidth); | 1660 web_view, title_card, kPasswordCombinedFixedGaiaViewWidth); |
1676 } | 1661 } |
1677 | 1662 |
1678 views::View* ProfileChooserView::CreateAccountRemovalView() { | 1663 views::View* ProfileChooserView::CreateAccountRemovalView() { |
1679 views::View* view = new views::View(); | 1664 views::View* view = new views::View(); |
1680 views::GridLayout* layout = CreateSingleColumnLayout( | 1665 views::GridLayout* layout = CreateSingleColumnLayout( |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1871 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1856 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1872 IncognitoModePrefs::DISABLED; | 1857 IncognitoModePrefs::DISABLED; |
1873 return incognito_available && !browser_->profile()->IsGuestSession(); | 1858 return incognito_available && !browser_->profile()->IsGuestSession(); |
1874 } | 1859 } |
1875 | 1860 |
1876 void ProfileChooserView::PostActionPerformed( | 1861 void ProfileChooserView::PostActionPerformed( |
1877 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1862 ProfileMetrics::ProfileDesktopMenu action_performed) { |
1878 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1863 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
1879 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1864 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
1880 } | 1865 } |
OLD | NEW |