OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/chromeos/login/login_utils.h" | 5 #include "chrome/browser/chromeos/login/login_utils.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 30 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
31 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 31 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
32 #include "chrome/browser/chromeos/login/background_view.h" | 32 #include "chrome/browser/chromeos/login/background_view.h" |
33 #include "chrome/browser/chromeos/login/cookie_fetcher.h" | 33 #include "chrome/browser/chromeos/login/cookie_fetcher.h" |
34 #include "chrome/browser/chromeos/login/language_switch_menu.h" | 34 #include "chrome/browser/chromeos/login/language_switch_menu.h" |
35 #include "chrome/browser/chromeos/login/login_display_host.h" | 35 #include "chrome/browser/chromeos/login/login_display_host.h" |
36 #include "chrome/browser/chromeos/login/ownership_service.h" | 36 #include "chrome/browser/chromeos/login/ownership_service.h" |
37 #include "chrome/browser/chromeos/login/parallel_authenticator.h" | 37 #include "chrome/browser/chromeos/login/parallel_authenticator.h" |
38 #include "chrome/browser/chromeos/login/screen_locker.h" | 38 #include "chrome/browser/chromeos/login/screen_locker.h" |
39 #include "chrome/browser/chromeos/login/user_manager.h" | 39 #include "chrome/browser/chromeos/login/user_manager.h" |
40 #include "chrome/browser/chromeos/system/runtime_environment.h" | |
41 #include "chrome/browser/extensions/extension_service.h" | 40 #include "chrome/browser/extensions/extension_service.h" |
42 #include "chrome/browser/first_run/first_run.h" | 41 #include "chrome/browser/first_run/first_run.h" |
43 #include "chrome/browser/net/chrome_url_request_context.h" | 42 #include "chrome/browser/net/chrome_url_request_context.h" |
44 #include "chrome/browser/net/gaia/gaia_oauth_consumer.h" | 43 #include "chrome/browser/net/gaia/gaia_oauth_consumer.h" |
45 #include "chrome/browser/net/gaia/gaia_oauth_fetcher.h" | 44 #include "chrome/browser/net/gaia/gaia_oauth_fetcher.h" |
46 #include "chrome/browser/net/gaia/token_service.h" | 45 #include "chrome/browser/net/gaia/token_service.h" |
47 #include "chrome/browser/net/preconnect.h" | 46 #include "chrome/browser/net/preconnect.h" |
48 #include "chrome/browser/policy/browser_policy_connector.h" | 47 #include "chrome/browser/policy/browser_policy_connector.h" |
49 #include "chrome/browser/prefs/pref_member.h" | 48 #include "chrome/browser/prefs/pref_member.h" |
50 #include "chrome/browser/profiles/profile.h" | 49 #include "chrome/browser/profiles/profile.h" |
(...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 const std::string& password, | 633 const std::string& password, |
635 const GaiaAuthConsumer::ClientLoginResult& credentials, | 634 const GaiaAuthConsumer::ClientLoginResult& credentials, |
636 bool pending_requests, | 635 bool pending_requests, |
637 bool using_oauth, | 636 bool using_oauth, |
638 bool has_cookies, | 637 bool has_cookies, |
639 LoginUtils::Delegate* delegate) { | 638 LoginUtils::Delegate* delegate) { |
640 BootTimesLoader* btl = BootTimesLoader::Get(); | 639 BootTimesLoader* btl = BootTimesLoader::Get(); |
641 | 640 |
642 VLOG(1) << "Completing login for " << username; | 641 VLOG(1) << "Completing login for " << username; |
643 | 642 |
644 if (system::runtime_environment::IsRunningOnChromeOS()) { | 643 btl->AddLoginTimeMarker("StartSession-Start", false); |
645 btl->AddLoginTimeMarker("StartSession-Start", false); | 644 DBusThreadManager::Get()->GetSessionManagerClient()->StartSession( |
646 DBusThreadManager::Get()->GetSessionManagerClient()->StartSession( | 645 username); |
647 username); | 646 btl->AddLoginTimeMarker("StartSession-End", false); |
648 btl->AddLoginTimeMarker("StartSession-End", false); | |
649 } | |
650 | 647 |
651 btl->AddLoginTimeMarker("UserLoggedIn-Start", false); | 648 btl->AddLoginTimeMarker("UserLoggedIn-Start", false); |
652 UserManager::Get()->UserLoggedIn(username); | 649 UserManager::Get()->UserLoggedIn(username); |
653 btl->AddLoginTimeMarker("UserLoggedIn-End", false); | 650 btl->AddLoginTimeMarker("UserLoggedIn-End", false); |
654 | 651 |
655 // Switch log file as soon as possible. | 652 // Switch log file as soon as possible. |
656 logging::RedirectChromeLogging(*(CommandLine::ForCurrentProcess())); | 653 logging::RedirectChromeLogging(*(CommandLine::ForCurrentProcess())); |
657 | 654 |
658 username_ = username; | 655 username_ = username; |
659 password_ = password; | 656 password_ = password; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 // Supply credentials for sync and others to use. Load tokens from disk. | 796 // Supply credentials for sync and others to use. Load tokens from disk. |
800 if (!using_oauth_) { | 797 if (!using_oauth_) { |
801 // For existing users there's usually a pending online auth request. | 798 // For existing users there's usually a pending online auth request. |
802 // Tokens will be fetched after it's is succeeded. | 799 // Tokens will be fetched after it's is succeeded. |
803 if (!pending_requests_) | 800 if (!pending_requests_) |
804 StartSync(user_profile, credentials_); | 801 StartSync(user_profile, credentials_); |
805 } | 802 } |
806 | 803 |
807 // Own TPM device if, for any reason, it has not been done in EULA | 804 // Own TPM device if, for any reason, it has not been done in EULA |
808 // wizard screen. | 805 // wizard screen. |
809 if (system::runtime_environment::IsRunningOnChromeOS()) { | 806 CryptohomeLibrary* cryptohome = CrosLibrary::Get()->GetCryptohomeLibrary(); |
810 CryptohomeLibrary* cryptohome = CrosLibrary::Get()->GetCryptohomeLibrary(); | 807 btl->AddLoginTimeMarker("TPMOwn-Start", false); |
811 btl->AddLoginTimeMarker("TPMOwn-Start", false); | 808 if (cryptohome->TpmIsEnabled() && !cryptohome->TpmIsBeingOwned()) { |
812 if (cryptohome->TpmIsEnabled() && !cryptohome->TpmIsBeingOwned()) { | 809 if (cryptohome->TpmIsOwned()) { |
813 if (cryptohome->TpmIsOwned()) { | 810 cryptohome->TpmClearStoredPassword(); |
814 cryptohome->TpmClearStoredPassword(); | 811 } else { |
815 } else { | 812 cryptohome->TpmCanAttemptOwnership(); |
816 cryptohome->TpmCanAttemptOwnership(); | |
817 } | |
818 } | 813 } |
819 btl->AddLoginTimeMarker("TPMOwn-End", false); | |
820 } | 814 } |
| 815 btl->AddLoginTimeMarker("TPMOwn-End", false); |
821 | 816 |
822 user_profile->OnLogin(); | 817 user_profile->OnLogin(); |
823 | 818 |
824 // TODO(altimofeev): This pointer should probably never be NULL, but it looks | 819 // TODO(altimofeev): This pointer should probably never be NULL, but it looks |
825 // like LoginUtilsImpl::OnProfileCreated() may be getting called before | 820 // like LoginUtilsImpl::OnProfileCreated() may be getting called before |
826 // LoginUtilsImpl::PrepareProfile() has set |delegate_| when Chrome is killed | 821 // LoginUtilsImpl::PrepareProfile() has set |delegate_| when Chrome is killed |
827 // during shutdown in tests -- see http://crosbug.com/18269. Replace this | 822 // during shutdown in tests -- see http://crosbug.com/18269. Replace this |
828 // 'if' statement with a CHECK(delegate_) once the underlying issue is | 823 // 'if' statement with a CHECK(delegate_) once the underlying issue is |
829 // resolved. | 824 // resolved. |
830 if (delegate_) | 825 if (delegate_) |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
917 // that input method preferences are synced, so users can use their | 912 // that input method preferences are synced, so users can use their |
918 // farovite input methods as soon as the preferences are synced. | 913 // farovite input methods as soon as the preferences are synced. |
919 LanguageSwitchMenu::SwitchLanguage(pref_locale); | 914 LanguageSwitchMenu::SwitchLanguage(pref_locale); |
920 } | 915 } |
921 | 916 |
922 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) { | 917 void LoginUtilsImpl::CompleteOffTheRecordLogin(const GURL& start_url) { |
923 VLOG(1) << "Completing incognito login"; | 918 VLOG(1) << "Completing incognito login"; |
924 | 919 |
925 UserManager::Get()->GuestUserLoggedIn(); | 920 UserManager::Get()->GuestUserLoggedIn(); |
926 | 921 |
927 if (system::runtime_environment::IsRunningOnChromeOS()) { | 922 // Session Manager may kill the chrome anytime after this point. |
928 // Session Manager may kill the chrome anytime after this point. | 923 // Write exit_cleanly and other stuff to the disk here. |
929 // Write exit_cleanly and other stuff to the disk here. | 924 g_browser_process->EndSession(); |
930 g_browser_process->EndSession(); | |
931 | 925 |
932 // For guest session we ask session manager to restart Chrome with --bwsi | 926 // For guest session we ask session manager to restart Chrome with --bwsi |
933 // flag. We keep only some of the arguments of this process. | 927 // flag. We keep only some of the arguments of this process. |
934 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); | 928 const CommandLine& browser_command_line = *CommandLine::ForCurrentProcess(); |
935 CommandLine command_line(browser_command_line.GetProgram()); | 929 CommandLine command_line(browser_command_line.GetProgram()); |
936 std::string cmd_line_str = | 930 std::string cmd_line_str = |
937 GetOffTheRecordCommandLine(start_url, | 931 GetOffTheRecordCommandLine(start_url, |
938 browser_command_line, | 932 browser_command_line, |
939 &command_line); | 933 &command_line); |
940 | 934 |
941 if (job_restart_request_) { | 935 if (job_restart_request_) { |
942 NOTREACHED(); | 936 NOTREACHED(); |
943 } | |
944 VLOG(1) << "Requesting a restart with PID " << getpid() | |
945 << " and command line: " << cmd_line_str; | |
946 job_restart_request_ = new JobRestartRequest(getpid(), cmd_line_str); | |
947 } | 937 } |
| 938 VLOG(1) << "Requesting a restart with PID " << getpid() |
| 939 << " and command line: " << cmd_line_str; |
| 940 job_restart_request_ = new JobRestartRequest(getpid(), cmd_line_str); |
948 } | 941 } |
949 | 942 |
950 std::string LoginUtilsImpl::GetOffTheRecordCommandLine( | 943 std::string LoginUtilsImpl::GetOffTheRecordCommandLine( |
951 const GURL& start_url, | 944 const GURL& start_url, |
952 const CommandLine& base_command_line, | 945 const CommandLine& base_command_line, |
953 CommandLine* command_line) { | 946 CommandLine* command_line) { |
954 static const char* kForwardSwitches[] = { | 947 static const char* kForwardSwitches[] = { |
955 switches::kEnableLogging, | 948 switches::kEnableLogging, |
956 switches::kDisableAcceleratedPlugins, | 949 switches::kDisableAcceleratedPlugins, |
957 switches::kUseGL, | 950 switches::kUseGL, |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1092 GURL(GaiaUrls::GetInstance()->client_login_url()), | 1085 GURL(GaiaUrls::GetInstance()->client_login_url()), |
1093 chrome_browser_net::UrlInfo::EARLY_LOAD_MOTIVATED, | 1086 chrome_browser_net::UrlInfo::EARLY_LOAD_MOTIVATED, |
1094 kConnectionsNeeded); | 1087 kConnectionsNeeded); |
1095 netlib->RemoveNetworkManagerObserver(this); | 1088 netlib->RemoveNetworkManagerObserver(this); |
1096 delete this; | 1089 delete this; |
1097 } | 1090 } |
1098 } | 1091 } |
1099 }; | 1092 }; |
1100 | 1093 |
1101 void LoginUtilsImpl::PrewarmAuthentication() { | 1094 void LoginUtilsImpl::PrewarmAuthentication() { |
1102 if (system::runtime_environment::IsRunningOnChromeOS()) { | 1095 NetworkLibrary *network = CrosLibrary::Get()->GetNetworkLibrary(); |
1103 NetworkLibrary *network = CrosLibrary::Get()->GetNetworkLibrary(); | 1096 if (network->Connected()) { |
1104 if (network->Connected()) { | 1097 const int kConnectionsNeeded = 1; |
1105 const int kConnectionsNeeded = 1; | 1098 chrome_browser_net::PreconnectOnUIThread( |
1106 chrome_browser_net::PreconnectOnUIThread( | 1099 GURL(GaiaUrls::GetInstance()->client_login_url()), |
1107 GURL(GaiaUrls::GetInstance()->client_login_url()), | 1100 chrome_browser_net::UrlInfo::EARLY_LOAD_MOTIVATED, |
1108 chrome_browser_net::UrlInfo::EARLY_LOAD_MOTIVATED, | 1101 kConnectionsNeeded); |
1109 kConnectionsNeeded); | 1102 } else { |
1110 } else { | 1103 new WarmingObserver(); |
1111 new WarmingObserver(); | |
1112 } | |
1113 } | 1104 } |
1114 } | 1105 } |
1115 | 1106 |
1116 void LoginUtilsImpl::RestoreAuthenticationSession(const std::string& username, | 1107 void LoginUtilsImpl::RestoreAuthenticationSession(const std::string& username, |
1117 Profile* user_profile) { | 1108 Profile* user_profile) { |
1118 username_ = username; | 1109 username_ = username; |
1119 KickStartAuthentication(user_profile); | 1110 KickStartAuthentication(user_profile); |
1120 } | 1111 } |
1121 | 1112 |
1122 void LoginUtilsImpl::KickStartAuthentication(Profile* user_profile) { | 1113 void LoginUtilsImpl::KickStartAuthentication(Profile* user_profile) { |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1315 // Mark login host for deletion after browser starts. This | 1306 // Mark login host for deletion after browser starts. This |
1316 // guarantees that the message loop will be referenced by the | 1307 // guarantees that the message loop will be referenced by the |
1317 // browser before it is dereferenced by the login host. | 1308 // browser before it is dereferenced by the login host. |
1318 if (login_host) { | 1309 if (login_host) { |
1319 login_host->OnSessionStart(); | 1310 login_host->OnSessionStart(); |
1320 login_host = NULL; | 1311 login_host = NULL; |
1321 } | 1312 } |
1322 } | 1313 } |
1323 | 1314 |
1324 } // namespace chromeos | 1315 } // namespace chromeos |
OLD | NEW |