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

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

Issue 1413533009: Make the new Gaia password separated signin flow modal. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add DCHECK Created 5 years 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/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
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
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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 switches::IsEnableAccountConsistency() && 711 switches::IsEnableAccountConsistency() &&
713 avatar_menu_->GetItemAt(avatar_menu_->GetActiveProfileIndex()). 712 avatar_menu_->GetItemAt(avatar_menu_->GetActiveProfileIndex()).
714 signed_in) { 713 signed_in) {
715 view_mode_ = profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT; 714 view_mode_ = profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT;
716 } 715 }
717 716
718 // The arrow keys can be used to tab between items. 717 // The arrow keys can be used to tab between items.
719 AddAccelerator(ui::Accelerator(ui::VKEY_DOWN, ui::EF_NONE)); 718 AddAccelerator(ui::Accelerator(ui::VKEY_DOWN, ui::EF_NONE));
720 AddAccelerator(ui::Accelerator(ui::VKEY_UP, ui::EF_NONE)); 719 AddAccelerator(ui::Accelerator(ui::VKEY_UP, ui::EF_NONE));
721 720
722 ShowView(view_mode_, avatar_menu_.get()); 721 ShowViewFromMode(view_mode_);
723 } 722 }
724 723
725 void ProfileChooserView::OnNativeThemeChanged( 724 void ProfileChooserView::OnNativeThemeChanged(
726 const ui::NativeTheme* native_theme) { 725 const ui::NativeTheme* native_theme) {
727 views::BubbleDelegateView::OnNativeThemeChanged(native_theme); 726 views::BubbleDelegateView::OnNativeThemeChanged(native_theme);
728 set_background(views::Background::CreateSolidBackground( 727 set_background(views::Background::CreateSolidBackground(
729 GetNativeTheme()->GetSystemColor( 728 GetNativeTheme()->GetSystemColor(
730 ui::NativeTheme::kColorId_DialogBackground))); 729 ui::NativeTheme::kColorId_DialogBackground)));
731 if (auth_error_email_button_) { 730 if (auth_error_email_button_) {
732 auth_error_email_button_->SetTextColor( 731 auth_error_email_button_->SetTextColor(
(...skipping 13 matching lines...) Expand all
746 } 745 }
747 } 746 }
748 747
749 void ProfileChooserView::OnRefreshTokenAvailable( 748 void ProfileChooserView::OnRefreshTokenAvailable(
750 const std::string& account_id) { 749 const std::string& account_id) {
751 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT || 750 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ||
752 view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT || 751 view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT ||
753 view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) { 752 view_mode_ == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) {
754 // The account management UI is only available through the 753 // The account management UI is only available through the
755 // --enable-account-consistency flag. 754 // --enable-account-consistency flag.
756 ShowView(switches::IsEnableAccountConsistency() ? 755 ShowViewFromMode(switches::IsEnableAccountConsistency() ?
757 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : 756 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT :
758 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); 757 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER);
759 } 758 }
760 } 759 }
761 760
762 void ProfileChooserView::OnRefreshTokenRevoked(const std::string& account_id) { 761 void ProfileChooserView::OnRefreshTokenRevoked(const std::string& account_id) {
763 // Refresh the account management view when an account is removed from the 762 // Refresh the account management view when an account is removed from the
764 // profile. 763 // profile.
765 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) 764 if (view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT)
766 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); 765 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT);
767 } 766 }
768 767
769 void ProfileChooserView::ShowView(profiles::BubbleViewMode view_to_display, 768 void ProfileChooserView::ShowView(profiles::BubbleViewMode view_to_display,
770 AvatarMenu* avatar_menu) { 769 AvatarMenu* avatar_menu) {
771 // The account management view should only be displayed if the active profile 770 // The account management view should only be displayed if the active profile
772 // is signed in. 771 // is signed in.
773 if (view_to_display == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { 772 if (view_to_display == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) {
774 DCHECK(switches::IsEnableAccountConsistency()); 773 DCHECK(switches::IsEnableAccountConsistency());
775 const AvatarMenu::Item& active_item = avatar_menu->GetItemAt( 774 const AvatarMenu::Item& active_item = avatar_menu->GetItemAt(
776 avatar_menu->GetActiveProfileIndex()); 775 avatar_menu->GetActiveProfileIndex());
(...skipping 14 matching lines...) Expand all
791 views::GridLayout* layout = nullptr; 790 views::GridLayout* layout = nullptr;
792 views::View* sub_view = nullptr; 791 views::View* sub_view = nullptr;
793 views::View* view_to_focus = nullptr; 792 views::View* view_to_focus = nullptr;
794 switch (view_mode_) { 793 switch (view_mode_) {
795 case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN: 794 case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN:
796 case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: 795 case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT:
797 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: { 796 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: {
798 const int width = switches::UsePasswordSeparatedSigninFlow() 797 const int width = switches::UsePasswordSeparatedSigninFlow()
799 ? kFixedGaiaViewWidth : kPasswordCombinedFixedGaiaViewWidth; 798 ? kFixedGaiaViewWidth : kPasswordCombinedFixedGaiaViewWidth;
800 layout = CreateSingleColumnLayout(this, width); 799 layout = CreateSingleColumnLayout(this, width);
800 DCHECK(!switches::UsePasswordSeparatedSigninFlow());
801 sub_view = CreateGaiaSigninView(&view_to_focus); 801 sub_view = CreateGaiaSigninView(&view_to_focus);
802 break; 802 break;
803 } 803 }
804 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: 804 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL:
805 layout = CreateSingleColumnLayout(this, kFixedAccountRemovalViewWidth); 805 layout = CreateSingleColumnLayout(this, kFixedAccountRemovalViewWidth);
806 sub_view = CreateAccountRemovalView(); 806 sub_view = CreateAccountRemovalView();
807 break; 807 break;
808 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: 808 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER:
809 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth); 809 layout = CreateSingleColumnLayout(this, kFixedSwitchUserViewWidth);
810 sub_view = CreateSwitchUserView(); 810 sub_view = CreateSwitchUserView();
(...skipping 13 matching lines...) Expand all
824 824
825 layout->StartRow(1, 0); 825 layout->StartRow(1, 0);
826 layout->AddView(sub_view); 826 layout->AddView(sub_view);
827 Layout(); 827 Layout();
828 if (GetBubbleFrameView()) 828 if (GetBubbleFrameView())
829 SizeToContents(); 829 SizeToContents();
830 if (view_to_focus) 830 if (view_to_focus)
831 view_to_focus->RequestFocus(); 831 view_to_focus->RequestFocus();
832 } 832 }
833 833
834 void ProfileChooserView::ShowViewFromMode(profiles::BubbleViewMode mode) {
835 if (SigninViewController::ShouldShowModalSigninForMode(mode)) {
836 BrowserWindow::AvatarBubbleMode converted_mode =
837 BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT;
838 if (mode == profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN) {
839 converted_mode = BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN;
840 } else if (mode == profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT) {
841 converted_mode = BrowserWindow::AVATAR_BUBBLE_MODE_ADD_ACCOUNT;
842 } else if (mode == profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH) {
843 converted_mode = BrowserWindow::AVATAR_BUBBLE_MODE_REAUTH;
844 }
845
846 browser_->window()->ShowModalSigninWindow(converted_mode);
847 } else {
848 ShowView(mode, avatar_menu_.get());
849 }
850 }
851
834 void ProfileChooserView::WindowClosing() { 852 void ProfileChooserView::WindowClosing() {
835 DCHECK_EQ(profile_bubble_, this); 853 DCHECK_EQ(profile_bubble_, this);
836 profile_bubble_ = NULL; 854 profile_bubble_ = NULL;
837 855
838 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) { 856 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) {
839 LoginUIServiceFactory::GetForProfile(browser_->profile())-> 857 LoginUIServiceFactory::GetForProfile(browser_->profile())->
840 SyncConfirmationUIClosed(false /* configure_sync_first */); 858 SyncConfirmationUIClosed(false /* configure_sync_first */);
841 } 859 }
842 } 860 }
843 861
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 } 893 }
876 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER); 894 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER);
877 } else if (sender == go_incognito_button_) { 895 } else if (sender == go_incognito_button_) {
878 DCHECK(ShouldShowGoIncognito()); 896 DCHECK(ShouldShowGoIncognito());
879 chrome::NewIncognitoWindow(browser_); 897 chrome::NewIncognitoWindow(browser_);
880 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_GO_INCOGNITO); 898 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_GO_INCOGNITO);
881 } else if (sender == lock_button_) { 899 } else if (sender == lock_button_) {
882 profiles::LockProfile(browser_->profile()); 900 profiles::LockProfile(browser_->profile());
883 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK); 901 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK);
884 } else if (sender == auth_error_email_button_) { 902 } else if (sender == auth_error_email_button_) {
885 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH, avatar_menu_.get()); 903 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH);
886 } else if (sender == tutorial_sync_settings_ok_button_) { 904 } else if (sender == tutorial_sync_settings_ok_button_) {
887 LoginUIServiceFactory::GetForProfile(browser_->profile())-> 905 LoginUIServiceFactory::GetForProfile(browser_->profile())->
888 SyncConfirmationUIClosed(false /* configure_sync_first */); 906 SyncConfirmationUIClosed(false /* configure_sync_first */);
889 DismissTutorial(); 907 DismissTutorial();
890 ProfileMetrics::LogProfileNewAvatarMenuSignin( 908 ProfileMetrics::LogProfileNewAvatarMenuSignin(
891 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_OK); 909 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_OK);
892 } else if (sender == tutorial_close_button_) { 910 } else if (sender == tutorial_close_button_) {
893 DCHECK(tutorial_mode_ != profiles::TUTORIAL_MODE_NONE && 911 DCHECK(tutorial_mode_ != profiles::TUTORIAL_MODE_NONE &&
894 tutorial_mode_ != profiles::TUTORIAL_MODE_CONFIRM_SIGNIN); 912 tutorial_mode_ != profiles::TUTORIAL_MODE_CONFIRM_SIGNIN);
895 DismissTutorial(); 913 DismissTutorial();
896 } else if (sender == tutorial_see_whats_new_button_) { 914 } else if (sender == tutorial_see_whats_new_button_) {
897 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( 915 ProfileMetrics::LogProfileNewAvatarMenuUpgrade(
898 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_WHATS_NEW); 916 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_WHATS_NEW);
899 UserManager::Show(base::FilePath(), 917 UserManager::Show(base::FilePath(),
900 profiles::USER_MANAGER_TUTORIAL_OVERVIEW, 918 profiles::USER_MANAGER_TUTORIAL_OVERVIEW,
901 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); 919 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
902 } else if (sender == remove_account_button_) { 920 } else if (sender == remove_account_button_) {
903 RemoveAccount(); 921 RemoveAccount();
904 } else if (sender == account_removal_cancel_button_) { 922 } else if (sender == account_removal_cancel_button_) {
905 account_id_to_remove_.clear(); 923 account_id_to_remove_.clear();
906 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); 924 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT);
907 } else if (sender == gaia_signin_cancel_button_) { 925 } else if (sender == gaia_signin_cancel_button_) {
908 // The account management view is only available with the 926 // The account management view is only available with the
909 // --enable-account-consistency flag. 927 // --enable-account-consistency flag.
910 bool account_management_available = 928 bool account_management_available =
911 SigninManagerFactory::GetForProfile(browser_->profile())-> 929 SigninManagerFactory::GetForProfile(browser_->profile())->
912 IsAuthenticated() && 930 IsAuthenticated() &&
913 switches::IsEnableAccountConsistency(); 931 switches::IsEnableAccountConsistency();
914 ShowView(account_management_available ? 932 ShowViewFromMode(account_management_available ?
915 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : 933 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT :
916 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); 934 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER);
917 } else if (sender == current_profile_photo_) { 935 } else if (sender == current_profile_photo_) {
918 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); 936 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex());
919 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); 937 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE);
920 } else if (sender == signin_current_profile_link_) { 938 } else if (sender == signin_current_profile_link_) {
921 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get()); 939 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN);
922 } else if (sender == add_person_button_) { 940 } else if (sender == add_person_button_) {
923 ProfileMetrics::LogProfileNewAvatarMenuNotYou( 941 ProfileMetrics::LogProfileNewAvatarMenuNotYou(
924 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON); 942 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON);
925 UserManager::Show(base::FilePath(), 943 UserManager::Show(base::FilePath(),
926 profiles::USER_MANAGER_NO_TUTORIAL, 944 profiles::USER_MANAGER_NO_TUTORIAL,
927 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); 945 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
928 } else if (sender == disconnect_button_) { 946 } else if (sender == disconnect_button_) {
929 ProfileMetrics::LogProfileNewAvatarMenuNotYou( 947 ProfileMetrics::LogProfileNewAvatarMenuNotYou(
930 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT); 948 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT);
931 chrome::ShowSettings(browser_); 949 chrome::ShowSettings(browser_);
932 } else if (sender == switch_user_cancel_button_) { 950 } else if (sender == switch_user_cancel_button_) {
933 ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); 951 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER);
934 ProfileMetrics::LogProfileNewAvatarMenuNotYou( 952 ProfileMetrics::LogProfileNewAvatarMenuNotYou(
935 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_BACK); 953 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_BACK);
936 } else { 954 } else {
937 // Either one of the "other profiles", or one of the profile accounts 955 // Either one of the "other profiles", or one of the profile accounts
938 // buttons was pressed. 956 // buttons was pressed.
939 ButtonIndexes::const_iterator profile_match = 957 ButtonIndexes::const_iterator profile_match =
940 open_other_profile_indexes_map_.find(sender); 958 open_other_profile_indexes_map_.find(sender);
941 if (profile_match != open_other_profile_indexes_map_.end()) { 959 if (profile_match != open_other_profile_indexes_map_.end()) {
942 avatar_menu_->SwitchToProfile( 960 avatar_menu_->SwitchToProfile(
943 profile_match->second, 961 profile_match->second,
944 ui::DispositionFromEventFlags(event.flags()) == NEW_WINDOW, 962 ui::DispositionFromEventFlags(event.flags()) == NEW_WINDOW,
945 ProfileMetrics::SWITCH_PROFILE_ICON); 963 ProfileMetrics::SWITCH_PROFILE_ICON);
946 } else { 964 } else {
947 // This was a profile accounts button. 965 // This was a profile accounts button.
948 AccountButtonIndexes::const_iterator account_match = 966 AccountButtonIndexes::const_iterator account_match =
949 delete_account_button_map_.find(sender); 967 delete_account_button_map_.find(sender);
950 if (account_match != delete_account_button_map_.end()) { 968 if (account_match != delete_account_button_map_.end()) {
951 account_id_to_remove_ = account_match->second; 969 account_id_to_remove_ = account_match->second;
952 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL, 970 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL);
953 avatar_menu_.get());
954 } else { 971 } else {
955 account_match = reauth_account_button_map_.find(sender); 972 account_match = reauth_account_button_map_.find(sender);
956 DCHECK(account_match != reauth_account_button_map_.end()); 973 DCHECK(account_match != reauth_account_button_map_.end());
957 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH, avatar_menu_.get()); 974 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH);
958 } 975 }
959 } 976 }
960 } 977 }
961 } 978 }
962 979
963 void ProfileChooserView::RemoveAccount() { 980 void ProfileChooserView::RemoveAccount() {
964 DCHECK(!account_id_to_remove_.empty()); 981 DCHECK(!account_id_to_remove_.empty());
965 ProfileOAuth2TokenService* oauth2_token_service = 982 ProfileOAuth2TokenService* oauth2_token_service =
966 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile()); 983 ProfileOAuth2TokenServiceFactory::GetForProfile(browser_->profile());
967 if (oauth2_token_service) { 984 if (oauth2_token_service) {
968 oauth2_token_service->RevokeCredentials(account_id_to_remove_); 985 oauth2_token_service->RevokeCredentials(account_id_to_remove_);
969 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_REMOVE_ACCT); 986 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_REMOVE_ACCT);
970 } 987 }
971 account_id_to_remove_.clear(); 988 account_id_to_remove_.clear();
972 989
973 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); 990 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT);
974 } 991 }
975 992
976 void ProfileChooserView::LinkClicked(views::Link* sender, int event_flags) { 993 void ProfileChooserView::LinkClicked(views::Link* sender, int event_flags) {
977 if (sender == manage_accounts_link_) { 994 if (sender == manage_accounts_link_) {
978 // This link can either mean show/hide the account management view, 995 // This link can either mean show/hide the account management view,
979 // depending on which view it is displayed. ShowView() will DCHECK if 996 // depending on which view it is displayed. ShowView() will DCHECK if
980 // the account management view is displayed for non signed-in users. 997 // the account management view is displayed for non signed-in users.
981 ShowView( 998 ShowViewFromMode(
982 view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ? 999 view_mode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT ?
983 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER : 1000 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER :
984 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, 1001 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT);
985 avatar_menu_.get());
986 } else if (sender == add_account_link_) { 1002 } else if (sender == add_account_link_) {
987 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT, avatar_menu_.get()); 1003 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT);
988 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT); 1004 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT);
989 } else if (sender == tutorial_sync_settings_link_) { 1005 } else if (sender == tutorial_sync_settings_link_) {
990 LoginUIServiceFactory::GetForProfile(browser_->profile())-> 1006 LoginUIServiceFactory::GetForProfile(browser_->profile())->
991 SyncConfirmationUIClosed(true /* configure_sync_first */); 1007 SyncConfirmationUIClosed(true /* configure_sync_first */);
992 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; 1008 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE;
993 ProfileMetrics::LogProfileNewAvatarMenuSignin( 1009 ProfileMetrics::LogProfileNewAvatarMenuSignin(
994 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_SETTINGS); 1010 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_SETTINGS);
995 } else if (sender == tutorial_not_you_link_) { 1011 } else if (sender == tutorial_not_you_link_) {
996 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( 1012 ProfileMetrics::LogProfileNewAvatarMenuUpgrade(
997 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_NOT_YOU); 1013 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_NOT_YOU);
998 ShowView(profiles::BUBBLE_VIEW_MODE_SWITCH_USER, avatar_menu_.get()); 1014 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_SWITCH_USER);
999 } else { 1015 } else {
1000 DCHECK(sender == tutorial_learn_more_link_); 1016 DCHECK(sender == tutorial_learn_more_link_);
1001 signin_ui_util::ShowSigninErrorLearnMorePage(browser_->profile()); 1017 signin_ui_util::ShowSigninErrorLearnMorePage(browser_->profile());
1002 } 1018 }
1003 } 1019 }
1004 1020
1005 void ProfileChooserView::StyledLabelLinkClicked(views::StyledLabel* label, 1021 void ProfileChooserView::StyledLabelLinkClicked(views::StyledLabel* label,
1006 const gfx::Range& range, 1022 const gfx::Range& range,
1007 int event_flags) { 1023 int event_flags) {
1008 chrome::ShowSettings(browser_); 1024 chrome::ShowSettings(browser_);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 signin_ui_util::kUpgradeWelcomeTutorialShowMax + 1); 1162 signin_ui_util::kUpgradeWelcomeTutorialShowMax + 1);
1147 } 1163 }
1148 1164
1149 if (tutorial_mode_ == profiles::TUTORIAL_MODE_RIGHT_CLICK_SWITCHING) { 1165 if (tutorial_mode_ == profiles::TUTORIAL_MODE_RIGHT_CLICK_SWITCHING) {
1150 PrefService* local_state = g_browser_process->local_state(); 1166 PrefService* local_state = g_browser_process->local_state();
1151 local_state->SetBoolean( 1167 local_state->SetBoolean(
1152 prefs::kProfileAvatarRightClickTutorialDismissed, true); 1168 prefs::kProfileAvatarRightClickTutorialDismissed, true);
1153 } 1169 }
1154 1170
1155 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE; 1171 tutorial_mode_ = profiles::TUTORIAL_MODE_NONE;
1156 ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); 1172 ShowViewFromMode(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER);
1157 } 1173 }
1158 1174
1159 views::View* ProfileChooserView::CreateTutorialViewIfNeeded( 1175 views::View* ProfileChooserView::CreateTutorialViewIfNeeded(
1160 const AvatarMenu::Item& item) { 1176 const AvatarMenu::Item& item) {
1161 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) 1177 if (tutorial_mode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN)
1162 return CreateSigninConfirmationView(); 1178 return CreateSigninConfirmationView();
1163 1179
1164 if (tutorial_mode_ == profiles::TUTORIAL_MODE_SHOW_ERROR) 1180 if (tutorial_mode_ == profiles::TUTORIAL_MODE_SHOW_ERROR)
1165 return CreateSigninErrorView(); 1181 return CreateSigninErrorView();
1166 1182
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 email_button->set_notify_enter_exit_on_child(true); 1629 email_button->set_notify_enter_exit_on_child(true);
1614 email_button->AddChildView(delete_button); 1630 email_button->AddChildView(delete_button);
1615 1631
1616 // Save the original email address, as the button text could be elided. 1632 // Save the original email address, as the button text could be elided.
1617 delete_account_button_map_[delete_button] = account_id; 1633 delete_account_button_map_[delete_button] = account_id;
1618 } 1634 }
1619 } 1635 }
1620 1636
1621 views::View* ProfileChooserView::CreateGaiaSigninView( 1637 views::View* ProfileChooserView::CreateGaiaSigninView(
1622 views::View** signin_content_view) { 1638 views::View** signin_content_view) {
1623 GURL url; 1639 views::WebView* web_view = SigninViewController::CreateGaiaWebView(
1640 this, view_mode_, browser_->profile());
1641
1624 int message_id; 1642 int message_id;
1625
1626 switch (view_mode_) { 1643 switch (view_mode_) {
1627 case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN: 1644 case profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN:
1628 url = signin::GetPromoURL(signin_metrics::SOURCE_AVATAR_BUBBLE_SIGN_IN,
1629 false /* auto_close */,
1630 true /* is_constrained */);
1631 message_id = IDS_PROFILES_GAIA_SIGNIN_TITLE; 1645 message_id = IDS_PROFILES_GAIA_SIGNIN_TITLE;
1632 break; 1646 break;
1633 case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT: 1647 case profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT:
1634 url = signin::GetPromoURL(
1635 signin_metrics::SOURCE_AVATAR_BUBBLE_ADD_ACCOUNT,
1636 false /* auto_close */,
1637 true /* is_constrained */);
1638 message_id = IDS_PROFILES_GAIA_ADD_ACCOUNT_TITLE; 1648 message_id = IDS_PROFILES_GAIA_ADD_ACCOUNT_TITLE;
1639 break; 1649 break;
1640 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: { 1650 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: {
1641 DCHECK(HasAuthError(browser_->profile()));
1642 url = signin::GetReauthURL(browser_->profile(),
1643 GetAuthErrorAccountId(browser_->profile()));
1644 message_id = IDS_PROFILES_GAIA_REAUTH_TITLE; 1651 message_id = IDS_PROFILES_GAIA_REAUTH_TITLE;
1645 break; 1652 break;
1646 } 1653 }
1647 default: 1654 default:
1648 NOTREACHED() << "Called with invalid mode=" << view_mode_; 1655 NOTREACHED() << "Called with invalid mode=" << view_mode_;
1649 return NULL; 1656 return NULL;
1650 } 1657 }
1651 1658
1652 // Adds Gaia signin webview.
1653 const gfx::Size pref_size = switches::UsePasswordSeparatedSigninFlow()
1654 ? gfx::Size(kFixedGaiaViewWidth, kFixedGaiaViewHeight)
1655 : gfx::Size(kPasswordCombinedFixedGaiaViewWidth,
1656 kPasswordCombinedFixedGaiaViewHeight);
1657 Profile* profile = browser_->profile();
1658 views::WebView* web_view = new views::WebView(profile);
1659 web_view->LoadInitialURL(url);
1660 web_view->GetWebContents()->SetDelegate(this);
1661 web_view->SetPreferredSize(pref_size);
1662 content::RenderWidgetHostView* rwhv =
1663 web_view->GetWebContents()->GetRenderWidgetHostView();
1664 if (rwhv)
1665 rwhv->SetBackgroundColor(profiles::kAvatarBubbleGaiaBackgroundColor);
1666
1667 if (signin_content_view) 1659 if (signin_content_view)
1668 *signin_content_view = web_view; 1660 *signin_content_view = web_view;
1669 1661
1670 if (switches::UsePasswordSeparatedSigninFlow()) {
1671 gaia_signin_cancel_button_ = CreateBackButton(this);
1672 HostView* host = new HostView();
1673 host->Initialize(gaia_signin_cancel_button_, web_view);
1674 return host;
1675 }
1676
1677 TitleCard* title_card = new TitleCard(l10n_util::GetStringUTF16(message_id), 1662 TitleCard* title_card = new TitleCard(l10n_util::GetStringUTF16(message_id),
1678 this, 1663 this,
1679 &gaia_signin_cancel_button_); 1664 &gaia_signin_cancel_button_);
1680 return TitleCard::AddPaddedTitleCard( 1665 return TitleCard::AddPaddedTitleCard(
1681 web_view, title_card, kPasswordCombinedFixedGaiaViewWidth); 1666 web_view, title_card, kPasswordCombinedFixedGaiaViewWidth);
1682 } 1667 }
1683 1668
1684 views::View* ProfileChooserView::CreateAccountRemovalView() { 1669 views::View* ProfileChooserView::CreateAccountRemovalView() {
1685 views::View* view = new views::View(); 1670 views::View* view = new views::View();
1686 views::GridLayout* layout = CreateSingleColumnLayout( 1671 views::GridLayout* layout = CreateSingleColumnLayout(
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1877 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 1862 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
1878 IncognitoModePrefs::DISABLED; 1863 IncognitoModePrefs::DISABLED;
1879 return incognito_available && !browser_->profile()->IsGuestSession(); 1864 return incognito_available && !browser_->profile()->IsGuestSession();
1880 } 1865 }
1881 1866
1882 void ProfileChooserView::PostActionPerformed( 1867 void ProfileChooserView::PostActionPerformed(
1883 ProfileMetrics::ProfileDesktopMenu action_performed) { 1868 ProfileMetrics::ProfileDesktopMenu action_performed) {
1884 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 1869 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
1885 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 1870 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
1886 } 1871 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/profiles/profile_chooser_view.h ('k') | chrome/browser/ui/views/profiles/signin_view_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698