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/local_auth.h" | 18 #include "chrome/browser/signin/local_auth.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_header_helper.h" | 20 #include "chrome/browser/signin/signin_header_helper.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/views/profiles/user_manager_view.h" | 30 #include "chrome/browser/ui/views/profiles/user_manager_view.h" |
30 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 31 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
31 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 32 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
32 #include "chrome/common/pref_names.h" | 33 #include "chrome/common/pref_names.h" |
33 #include "chrome/common/url_constants.h" | 34 #include "chrome/common/url_constants.h" |
34 #include "chrome/grit/chromium_strings.h" | 35 #include "chrome/grit/chromium_strings.h" |
35 #include "chrome/grit/generated_resources.h" | 36 #include "chrome/grit/generated_resources.h" |
36 #include "components/signin/core/browser/mutable_profile_oauth2_token_service.h" | 37 #include "components/signin/core/browser/mutable_profile_oauth2_token_service.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" |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 void ProfileChooserView::ButtonPressed(views::Button* sender, | 701 void ProfileChooserView::ButtonPressed(views::Button* sender, |
701 const ui::Event& event) { | 702 const ui::Event& event) { |
702 // Disable button after clicking so that it doesn't get clicked twice and | 703 // Disable button after clicking so that it doesn't get clicked twice and |
703 // start a second action... which can crash Chrome. But don't disable if it | 704 // start a second action... which can crash Chrome. But don't disable if it |
704 // has no parent (like in tests) because that will also crash. | 705 // has no parent (like in tests) because that will also crash. |
705 if (sender->parent()) | 706 if (sender->parent()) |
706 sender->SetEnabled(false); | 707 sender->SetEnabled(false); |
707 | 708 |
708 if (sender == users_button_) { | 709 if (sender == users_button_) { |
709 // If this is a guest session, close all the guest browser windows. | 710 // If this is a guest session, close all the guest browser windows. |
710 if (browser_->profile()->IsGuestSession()) | 711 if (browser_->profile()->IsGuestSession()) { |
711 profiles::CloseGuestProfileWindows(); | 712 profiles::CloseGuestProfileWindows(); |
712 else | 713 } else { |
713 chrome::ShowUserManager(base::FilePath()); | 714 UserManager::Show(base::FilePath(), |
| 715 profiles::USER_MANAGER_NO_TUTORIAL, |
| 716 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
| 717 } |
714 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER); | 718 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER); |
715 } else if (sender == go_incognito_button_) { | 719 } else if (sender == go_incognito_button_) { |
716 DCHECK(ShouldShowGoIncognito()); | 720 DCHECK(ShouldShowGoIncognito()); |
717 chrome::NewIncognitoWindow(browser_); | 721 chrome::NewIncognitoWindow(browser_); |
718 } else if (sender == lock_button_) { | 722 } else if (sender == lock_button_) { |
719 profiles::LockProfile(browser_->profile()); | 723 profiles::LockProfile(browser_->profile()); |
720 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK); | 724 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK); |
721 } else if (sender == auth_error_email_button_) { | 725 } else if (sender == auth_error_email_button_) { |
722 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH, avatar_menu_.get()); | 726 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH, avatar_menu_.get()); |
723 } else if (sender == tutorial_sync_settings_ok_button_) { | 727 } else if (sender == tutorial_sync_settings_ok_button_) { |
724 LoginUIServiceFactory::GetForProfile(browser_->profile())-> | 728 LoginUIServiceFactory::GetForProfile(browser_->profile())-> |
725 SyncConfirmationUIClosed(false /* configure_sync_first */); | 729 SyncConfirmationUIClosed(false /* configure_sync_first */); |
726 DismissTutorial(); | 730 DismissTutorial(); |
727 ProfileMetrics::LogProfileNewAvatarMenuSignin( | 731 ProfileMetrics::LogProfileNewAvatarMenuSignin( |
728 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_OK); | 732 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_OK); |
729 } else if (sender == tutorial_close_button_) { | 733 } else if (sender == tutorial_close_button_) { |
730 DCHECK(tutorial_mode_ != profiles::TUTORIAL_MODE_NONE && | 734 DCHECK(tutorial_mode_ != profiles::TUTORIAL_MODE_NONE && |
731 tutorial_mode_ != profiles::TUTORIAL_MODE_CONFIRM_SIGNIN); | 735 tutorial_mode_ != profiles::TUTORIAL_MODE_CONFIRM_SIGNIN); |
732 DismissTutorial(); | 736 DismissTutorial(); |
733 } else if (sender == tutorial_see_whats_new_button_) { | 737 } else if (sender == tutorial_see_whats_new_button_) { |
734 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( | 738 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( |
735 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_WHATS_NEW); | 739 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_WHATS_NEW); |
736 chrome::ShowUserManagerWithTutorial( | 740 UserManager::Show(base::FilePath(), |
737 profiles::USER_MANAGER_TUTORIAL_OVERVIEW); | 741 profiles::USER_MANAGER_TUTORIAL_OVERVIEW, |
| 742 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
738 } else if (sender == remove_account_button_) { | 743 } else if (sender == remove_account_button_) { |
739 RemoveAccount(); | 744 RemoveAccount(); |
740 } else if (sender == account_removal_cancel_button_) { | 745 } else if (sender == account_removal_cancel_button_) { |
741 account_id_to_remove_.clear(); | 746 account_id_to_remove_.clear(); |
742 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); | 747 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); |
743 } else if (sender == gaia_signin_cancel_button_) { | 748 } else if (sender == gaia_signin_cancel_button_) { |
744 // The account management view is only available with the | 749 // The account management view is only available with the |
745 // --enable-account-consistency flag. | 750 // --enable-account-consistency flag. |
746 bool account_management_available = | 751 bool account_management_available = |
747 SigninManagerFactory::GetForProfile(browser_->profile())-> | 752 SigninManagerFactory::GetForProfile(browser_->profile())-> |
748 IsAuthenticated() && | 753 IsAuthenticated() && |
749 switches::IsEnableAccountConsistency(); | 754 switches::IsEnableAccountConsistency(); |
750 ShowView(account_management_available ? | 755 ShowView(account_management_available ? |
751 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : | 756 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : |
752 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); | 757 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); |
753 } else if (sender == current_profile_photo_) { | 758 } else if (sender == current_profile_photo_) { |
754 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); | 759 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); |
755 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); | 760 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); |
756 } else if (sender == signin_current_profile_link_) { | 761 } else if (sender == signin_current_profile_link_) { |
757 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get()); | 762 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get()); |
758 } else if (sender == add_person_button_) { | 763 } else if (sender == add_person_button_) { |
759 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 764 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
760 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON); | 765 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON); |
761 chrome::ShowUserManager(base::FilePath()); | 766 UserManager::Show(base::FilePath(), |
| 767 profiles::USER_MANAGER_NO_TUTORIAL, |
| 768 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
762 } else if (sender == disconnect_button_) { | 769 } else if (sender == disconnect_button_) { |
763 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 770 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
764 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT); | 771 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT); |
765 chrome::ShowSettings(browser_); | 772 chrome::ShowSettings(browser_); |
766 } else if (sender == switch_user_cancel_button_) { | 773 } else if (sender == switch_user_cancel_button_) { |
767 ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); | 774 ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); |
768 ProfileMetrics::LogProfileNewAvatarMenuNotYou( | 775 ProfileMetrics::LogProfileNewAvatarMenuNotYou( |
769 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_BACK); | 776 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_BACK); |
770 } else { | 777 } else { |
771 // Either one of the "other profiles", or one of the profile accounts | 778 // Either one of the "other profiles", or one of the profile accounts |
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1638 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1645 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1639 IncognitoModePrefs::DISABLED; | 1646 IncognitoModePrefs::DISABLED; |
1640 return incognito_available && !browser_->profile()->IsGuestSession(); | 1647 return incognito_available && !browser_->profile()->IsGuestSession(); |
1641 } | 1648 } |
1642 | 1649 |
1643 void ProfileChooserView::PostActionPerformed( | 1650 void ProfileChooserView::PostActionPerformed( |
1644 ProfileMetrics::ProfileDesktopMenu action_performed) { | 1651 ProfileMetrics::ProfileDesktopMenu action_performed) { |
1645 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); | 1652 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); |
1646 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; | 1653 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; |
1647 } | 1654 } |
OLD | NEW |