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

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

Issue 564453003: Access to Chrome via the System Tray should go through the User Manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase continued Created 6 years, 3 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/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 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 void ProfileChooserView::ButtonPressed(views::Button* sender, 715 void ProfileChooserView::ButtonPressed(views::Button* sender,
715 const ui::Event& event) { 716 const ui::Event& event) {
716 // Disable button after clicking so that it doesn't get clicked twice and 717 // Disable button after clicking so that it doesn't get clicked twice and
717 // start a second action... which can crash Chrome. But don't disable if it 718 // start a second action... which can crash Chrome. But don't disable if it
718 // has no parent (like in tests) because that will also crash. 719 // has no parent (like in tests) because that will also crash.
719 if (sender->parent()) 720 if (sender->parent())
720 sender->SetEnabled(false); 721 sender->SetEnabled(false);
721 722
722 if (sender == users_button_) { 723 if (sender == users_button_) {
723 // If this is a guest session, close all the guest browser windows. 724 // If this is a guest session, close all the guest browser windows.
724 if (browser_->profile()->IsGuestSession()) 725 if (browser_->profile()->IsGuestSession()) {
725 profiles::CloseGuestProfileWindows(); 726 profiles::CloseGuestProfileWindows();
726 else 727 } else {
727 chrome::ShowUserManager(base::FilePath()); 728 UserManager::Show(base::FilePath(),
729 profiles::USER_MANAGER_NO_TUTORIAL,
730 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
731 }
728 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER); 732 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_OPEN_USER_MANAGER);
729 } else if (sender == go_incognito_button_) { 733 } else if (sender == go_incognito_button_) {
730 DCHECK(ShouldShowGoIncognito()); 734 DCHECK(ShouldShowGoIncognito());
731 chrome::NewIncognitoWindow(browser_); 735 chrome::NewIncognitoWindow(browser_);
732 } else if (sender == lock_button_) { 736 } else if (sender == lock_button_) {
733 profiles::LockProfile(browser_->profile()); 737 profiles::LockProfile(browser_->profile());
734 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK); 738 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK);
735 } else if (sender == auth_error_email_button_) { 739 } else if (sender == auth_error_email_button_) {
736 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH, avatar_menu_.get()); 740 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH, avatar_menu_.get());
737 } else if (sender == tutorial_sync_settings_ok_button_) { 741 } else if (sender == tutorial_sync_settings_ok_button_) {
738 LoginUIServiceFactory::GetForProfile(browser_->profile())-> 742 LoginUIServiceFactory::GetForProfile(browser_->profile())->
739 SyncConfirmationUIClosed(false /* configure_sync_first */); 743 SyncConfirmationUIClosed(false /* configure_sync_first */);
740 DismissTutorial(); 744 DismissTutorial();
741 ProfileMetrics::LogProfileNewAvatarMenuSignin( 745 ProfileMetrics::LogProfileNewAvatarMenuSignin(
742 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_OK); 746 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_OK);
743 } else if (sender == tutorial_close_button_) { 747 } else if (sender == tutorial_close_button_) {
744 DCHECK(tutorial_mode_ != profiles::TUTORIAL_MODE_NONE && 748 DCHECK(tutorial_mode_ != profiles::TUTORIAL_MODE_NONE &&
745 tutorial_mode_ != profiles::TUTORIAL_MODE_CONFIRM_SIGNIN); 749 tutorial_mode_ != profiles::TUTORIAL_MODE_CONFIRM_SIGNIN);
746 DismissTutorial(); 750 DismissTutorial();
747 } else if (sender == tutorial_see_whats_new_button_) { 751 } else if (sender == tutorial_see_whats_new_button_) {
748 ProfileMetrics::LogProfileNewAvatarMenuUpgrade( 752 ProfileMetrics::LogProfileNewAvatarMenuUpgrade(
749 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_WHATS_NEW); 753 ProfileMetrics::PROFILE_AVATAR_MENU_UPGRADE_WHATS_NEW);
750 chrome::ShowUserManagerWithTutorial( 754 UserManager::Show(base::FilePath(),
751 profiles::USER_MANAGER_TUTORIAL_OVERVIEW); 755 profiles::USER_MANAGER_TUTORIAL_OVERVIEW,
756 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
752 } else if (sender == remove_account_button_) { 757 } else if (sender == remove_account_button_) {
753 RemoveAccount(); 758 RemoveAccount();
754 } else if (sender == account_removal_cancel_button_) { 759 } else if (sender == account_removal_cancel_button_) {
755 account_id_to_remove_.clear(); 760 account_id_to_remove_.clear();
756 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get()); 761 ShowView(profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT, avatar_menu_.get());
757 } else if (sender == gaia_signin_cancel_button_) { 762 } else if (sender == gaia_signin_cancel_button_) {
758 // The account management view is only available with the 763 // The account management view is only available with the
759 // --enable-account-consistency flag. 764 // --enable-account-consistency flag.
760 bool account_management_available = 765 bool account_management_available =
761 SigninManagerFactory::GetForProfile(browser_->profile())-> 766 SigninManagerFactory::GetForProfile(browser_->profile())->
762 IsAuthenticated() && 767 IsAuthenticated() &&
763 switches::IsEnableAccountConsistency(); 768 switches::IsEnableAccountConsistency();
764 ShowView(account_management_available ? 769 ShowView(account_management_available ?
765 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT : 770 profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT :
766 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); 771 profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get());
767 } else if (sender == current_profile_photo_) { 772 } else if (sender == current_profile_photo_) {
768 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex()); 773 avatar_menu_->EditProfile(avatar_menu_->GetActiveProfileIndex());
769 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE); 774 PostActionPerformed(ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_IMAGE);
770 } else if (sender == signin_current_profile_link_) { 775 } else if (sender == signin_current_profile_link_) {
771 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get()); 776 ShowView(profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN, avatar_menu_.get());
772 } else if (sender == add_person_button_) { 777 } else if (sender == add_person_button_) {
773 ProfileMetrics::LogProfileNewAvatarMenuNotYou( 778 ProfileMetrics::LogProfileNewAvatarMenuNotYou(
774 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON); 779 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_ADD_PERSON);
775 chrome::ShowUserManager(base::FilePath()); 780 UserManager::Show(base::FilePath(),
781 profiles::USER_MANAGER_NO_TUTORIAL,
782 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
776 } else if (sender == disconnect_button_) { 783 } else if (sender == disconnect_button_) {
777 ProfileMetrics::LogProfileNewAvatarMenuNotYou( 784 ProfileMetrics::LogProfileNewAvatarMenuNotYou(
778 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT); 785 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_DISCONNECT);
779 chrome::ShowSettings(browser_); 786 chrome::ShowSettings(browser_);
780 } else if (sender == switch_user_cancel_button_) { 787 } else if (sender == switch_user_cancel_button_) {
781 ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get()); 788 ShowView(profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER, avatar_menu_.get());
782 ProfileMetrics::LogProfileNewAvatarMenuNotYou( 789 ProfileMetrics::LogProfileNewAvatarMenuNotYou(
783 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_BACK); 790 ProfileMetrics::PROFILE_AVATAR_MENU_NOT_YOU_BACK);
784 } else { 791 } else {
785 // Either one of the "other profiles", or one of the profile accounts 792 // Either one of the "other profiles", or one of the profile accounts
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
1652 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 1659 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
1653 IncognitoModePrefs::DISABLED; 1660 IncognitoModePrefs::DISABLED;
1654 return incognito_available && !browser_->profile()->IsGuestSession(); 1661 return incognito_available && !browser_->profile()->IsGuestSession();
1655 } 1662 }
1656 1663
1657 void ProfileChooserView::PostActionPerformed( 1664 void ProfileChooserView::PostActionPerformed(
1658 ProfileMetrics::ProfileDesktopMenu action_performed) { 1665 ProfileMetrics::ProfileDesktopMenu action_performed) {
1659 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 1666 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
1660 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 1667 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
1661 } 1668 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698