Chromium Code Reviews| 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/chromeos/login/session/user_session_manager.h" | 5 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 #include "chrome/browser/net/crl_set_fetcher.h" | 58 #include "chrome/browser/net/crl_set_fetcher.h" |
| 59 #include "chrome/browser/net/nss_context.h" | 59 #include "chrome/browser/net/nss_context.h" |
| 60 #include "chrome/browser/pref_service_flags_storage.h" | 60 #include "chrome/browser/pref_service_flags_storage.h" |
| 61 #include "chrome/browser/prefs/session_startup_pref.h" | 61 #include "chrome/browser/prefs/session_startup_pref.h" |
| 62 #include "chrome/browser/profiles/profile.h" | 62 #include "chrome/browser/profiles/profile.h" |
| 63 #include "chrome/browser/profiles/profile_manager.h" | 63 #include "chrome/browser/profiles/profile_manager.h" |
| 64 #include "chrome/browser/rlz/rlz.h" | 64 #include "chrome/browser/rlz/rlz.h" |
| 65 #include "chrome/browser/signin/account_tracker_service_factory.h" | 65 #include "chrome/browser/signin/account_tracker_service_factory.h" |
| 66 #include "chrome/browser/signin/easy_unlock_service.h" | 66 #include "chrome/browser/signin/easy_unlock_service.h" |
| 67 #include "chrome/browser/signin/signin_manager_factory.h" | 67 #include "chrome/browser/signin/signin_manager_factory.h" |
| 68 #include "chrome/browser/supervised_user/child_accounts/child_account_service.h" | |
| 69 #include "chrome/browser/supervised_user/child_accounts/child_account_service_fa ctory.h" | |
| 68 #include "chrome/browser/ui/app_list/start_page_service.h" | 70 #include "chrome/browser/ui/app_list/start_page_service.h" |
| 69 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 71 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 70 #include "chrome/common/chrome_switches.h" | 72 #include "chrome/common/chrome_switches.h" |
| 71 #include "chrome/common/logging_chrome.h" | 73 #include "chrome/common/logging_chrome.h" |
| 72 #include "chrome/common/pref_names.h" | 74 #include "chrome/common/pref_names.h" |
| 73 #include "chrome/common/url_constants.h" | 75 #include "chrome/common/url_constants.h" |
| 74 #include "chromeos/cert_loader.h" | 76 #include "chromeos/cert_loader.h" |
| 75 #include "chromeos/chromeos_switches.h" | 77 #include "chromeos/chromeos_switches.h" |
| 76 #include "chromeos/cryptohome/cryptohome_util.h" | 78 #include "chromeos/cryptohome/cryptohome_util.h" |
| 77 #include "chromeos/dbus/cryptohome_client.h" | 79 #include "chromeos/dbus/cryptohome_client.h" |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 318 UserSessionManager::UserSessionManager() | 320 UserSessionManager::UserSessionManager() |
| 319 : delegate_(nullptr), | 321 : delegate_(nullptr), |
| 320 authenticator_(nullptr), | 322 authenticator_(nullptr), |
| 321 has_auth_cookies_(false), | 323 has_auth_cookies_(false), |
| 322 user_sessions_restored_(false), | 324 user_sessions_restored_(false), |
| 323 user_sessions_restore_in_progress_(false), | 325 user_sessions_restore_in_progress_(false), |
| 324 exit_after_session_restore_(false), | 326 exit_after_session_restore_(false), |
| 325 session_restore_strategy_( | 327 session_restore_strategy_( |
| 326 OAuth2LoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN), | 328 OAuth2LoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN), |
| 327 running_easy_unlock_key_ops_(false), | 329 running_easy_unlock_key_ops_(false), |
| 328 should_launch_browser_(true) { | 330 should_launch_browser_(true), |
| 331 flags_fetching_ended_(false), | |
| 332 requesting_start_urls_(false), | |
| 333 profile_fetching_flags_(nullptr), | |
| 334 weak_factory_(this) { | |
| 329 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); | 335 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); |
| 330 user_manager::UserManager::Get()->AddSessionStateObserver(this); | 336 user_manager::UserManager::Get()->AddSessionStateObserver(this); |
| 331 } | 337 } |
| 332 | 338 |
| 333 UserSessionManager::~UserSessionManager() { | 339 UserSessionManager::~UserSessionManager() { |
| 334 // UserManager is destroyed before singletons, so we need to check if it | 340 // UserManager is destroyed before singletons, so we need to check if it |
| 335 // still exists. | 341 // still exists. |
| 336 // TODO(nkostylev): fix order of destruction of UserManager | 342 // TODO(nkostylev): fix order of destruction of UserManager |
| 337 // / UserSessionManager objects. | 343 // / UserSessionManager objects. |
| 338 if (user_manager::UserManager::IsInitialized()) | 344 if (user_manager::UserManager::IsInitialized()) |
| 339 user_manager::UserManager::Get()->RemoveSessionStateObserver(this); | 345 user_manager::UserManager::Get()->RemoveSessionStateObserver(this); |
| 340 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); | 346 net::NetworkChangeNotifier::RemoveConnectionTypeObserver(this); |
| 341 } | 347 } |
| 342 | 348 |
| 349 // static | |
| 350 const int UserSessionManager::kFlagsFetchingLoginTimeoutMs = 1000; | |
| 351 | |
| 343 void UserSessionManager::CompleteGuestSessionLogin(const GURL& start_url) { | 352 void UserSessionManager::CompleteGuestSessionLogin(const GURL& start_url) { |
| 344 VLOG(1) << "Completing guest session login"; | 353 VLOG(1) << "Completing guest session login"; |
| 345 | 354 |
| 346 // For guest session we ask session_manager to restart Chrome with --bwsi | 355 // For guest session we ask session_manager to restart Chrome with --bwsi |
| 347 // flag. We keep only some of the arguments of this process. | 356 // flag. We keep only some of the arguments of this process. |
| 348 const base::CommandLine& browser_command_line = | 357 const base::CommandLine& browser_command_line = |
| 349 *base::CommandLine::ForCurrentProcess(); | 358 *base::CommandLine::ForCurrentProcess(); |
| 350 base::CommandLine command_line(browser_command_line.GetProgram()); | 359 base::CommandLine command_line(browser_command_line.GetProgram()); |
| 351 std::string cmd_line_str = | 360 std::string cmd_line_str = |
| 352 GetOffTheRecordCommandLine(start_url, | 361 GetOffTheRecordCommandLine(start_url, |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 772 // users once it is fully multi-profile aware. http://crbug.com/238987 | 781 // users once it is fully multi-profile aware. http://crbug.com/238987 |
| 773 // For now if we have other user pending sessions they'll override OAuth | 782 // For now if we have other user pending sessions they'll override OAuth |
| 774 // session restore for previous users. | 783 // session restore for previous users. |
| 775 RestoreAuthenticationSession(profile); | 784 RestoreAuthenticationSession(profile); |
| 776 } | 785 } |
| 777 | 786 |
| 778 // Restore other user sessions if any. | 787 // Restore other user sessions if any. |
| 779 RestorePendingUserSessions(); | 788 RestorePendingUserSessions(); |
| 780 } | 789 } |
| 781 | 790 |
| 791 void UserSessionManager::OnFlagsFetchingError() { | |
| 792 FlagsFetchingStopped(); | |
| 793 } | |
| 794 | |
| 795 void UserSessionManager::OnFlagsFetchingCancelled() { | |
| 796 FlagsFetchingStopped(); | |
| 797 } | |
| 798 | |
| 799 void UserSessionManager::OnFlagsFetchingCompleted(bool is_child_account) { | |
| 800 FlagsFetchingStopped(); | |
| 801 } | |
| 802 | |
| 803 void UserSessionManager::FlagsFetchingStopped() { | |
| 804 flags_fetching_ended_ = true; | |
| 805 if (requesting_start_urls_) { | |
| 806 InitializeStartUrls(); | |
| 807 requesting_start_urls_ = false; | |
| 808 } | |
| 809 ChildAccountServiceFactory::GetForProfile(profile_fetching_flags_)-> | |
| 810 RemoveFlagFetchingObserver(this); | |
| 811 profile_fetching_flags_ = nullptr; | |
| 812 } | |
| 813 | |
| 782 void UserSessionManager::CreateUserSession(const UserContext& user_context, | 814 void UserSessionManager::CreateUserSession(const UserContext& user_context, |
| 783 bool has_auth_cookies) { | 815 bool has_auth_cookies) { |
| 784 user_context_ = user_context; | 816 user_context_ = user_context; |
| 785 has_auth_cookies_ = has_auth_cookies; | 817 has_auth_cookies_ = has_auth_cookies; |
| 786 InitSessionRestoreStrategy(); | 818 InitSessionRestoreStrategy(); |
| 787 } | 819 } |
| 788 | 820 |
| 789 void UserSessionManager::PreStartSession() { | 821 void UserSessionManager::PreStartSession() { |
| 790 // Switch log file as soon as possible. | 822 // Switch log file as soon as possible. |
| 791 if (base::SysInfo::IsRunningOnChromeOS()) | 823 if (base::SysInfo::IsRunningOnChromeOS()) |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1038 void UserSessionManager::ActivateWizard(const std::string& screen_name) { | 1070 void UserSessionManager::ActivateWizard(const std::string& screen_name) { |
| 1039 LoginDisplayHost* host = LoginDisplayHostImpl::default_host(); | 1071 LoginDisplayHost* host = LoginDisplayHostImpl::default_host(); |
| 1040 CHECK(host); | 1072 CHECK(host); |
| 1041 host->StartWizard(screen_name); | 1073 host->StartWizard(screen_name); |
| 1042 } | 1074 } |
| 1043 | 1075 |
| 1044 void UserSessionManager::InitializeStartUrls() const { | 1076 void UserSessionManager::InitializeStartUrls() const { |
| 1045 std::vector<std::string> start_urls; | 1077 std::vector<std::string> start_urls; |
| 1046 | 1078 |
| 1047 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 1079 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
| 1080 | |
| 1048 bool can_show_getstarted_guide = | 1081 bool can_show_getstarted_guide = |
| 1049 user_manager->GetActiveUser()->GetType() == | 1082 user_manager->GetActiveUser()->GetType() == |
| 1050 user_manager::USER_TYPE_REGULAR && | 1083 user_manager::USER_TYPE_REGULAR && |
| 1051 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); | 1084 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); |
| 1085 | |
| 1052 // Skip the default first-run behavior for public accounts. | 1086 // Skip the default first-run behavior for public accounts. |
| 1053 if (!user_manager->IsLoggedInAsPublicAccount()) { | 1087 if (!user_manager->IsLoggedInAsPublicAccount()) { |
| 1054 if (AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) { | 1088 if (AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) { |
| 1055 const char* url = kChromeVoxTutorialURLPattern; | 1089 const char* url = kChromeVoxTutorialURLPattern; |
| 1056 PrefService* prefs = g_browser_process->local_state(); | 1090 PrefService* prefs = g_browser_process->local_state(); |
| 1057 const std::string current_locale = | 1091 const std::string current_locale = |
| 1058 base::StringToLowerASCII(prefs->GetString(prefs::kApplicationLocale)); | 1092 base::StringToLowerASCII(prefs->GetString(prefs::kApplicationLocale)); |
| 1059 std::string vox_url = base::StringPrintf(url, current_locale.c_str()); | 1093 std::string vox_url = base::StringPrintf(url, current_locale.c_str()); |
| 1060 start_urls.push_back(vox_url); | 1094 start_urls.push_back(vox_url); |
| 1061 can_show_getstarted_guide = false; | 1095 can_show_getstarted_guide = false; |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 1073 ::switches::kSilentLaunch); | 1107 ::switches::kSilentLaunch); |
| 1074 first_run::MaybeLaunchDialogAfterSessionStart(); | 1108 first_run::MaybeLaunchDialogAfterSessionStart(); |
| 1075 } else { | 1109 } else { |
| 1076 for (size_t i = 0; i < start_urls.size(); ++i) { | 1110 for (size_t i = 0; i < start_urls.size(); ++i) { |
| 1077 base::CommandLine::ForCurrentProcess()->AppendArg(start_urls[i]); | 1111 base::CommandLine::ForCurrentProcess()->AppendArg(start_urls[i]); |
| 1078 } | 1112 } |
| 1079 } | 1113 } |
| 1080 } | 1114 } |
| 1081 | 1115 |
| 1082 bool UserSessionManager::InitializeUserSession(Profile* profile) { | 1116 bool UserSessionManager::InitializeUserSession(Profile* profile) { |
| 1117 ChildAccountServiceFactory::GetForProfile(profile)-> | |
| 1118 AddFlagFetchingObserver(this); | |
|
Marc Treib
2015/03/04 09:59:15
Could the "is child account" status already be kno
merkulova
2015/03/04 10:06:27
Yes, it might be already know. Then we wait for th
Marc Treib
2015/03/04 10:17:53
Then I'd add an "IsChildAccountStatusKnown" method
merkulova
2015/03/04 14:55:11
Done.
| |
| 1119 base::MessageLoopProxy::current()->PostDelayedTask( | |
| 1120 FROM_HERE, | |
| 1121 base::Bind(&UserSessionManager::OnFlagsFetchingCancelled, | |
| 1122 weak_factory_.GetWeakPtr()), | |
| 1123 base::TimeDelta::FromMilliseconds(kFlagsFetchingLoginTimeoutMs)); | |
| 1124 profile_fetching_flags_ = profile; | |
| 1125 | |
| 1083 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 1126 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
| 1084 | 1127 |
| 1085 // Kiosk apps has their own session initialization pipeline. | 1128 // Kiosk apps has their own session initialization pipeline. |
| 1086 if (user_manager->IsLoggedInAsKioskApp()) | 1129 if (user_manager->IsLoggedInAsKioskApp()) |
| 1087 return false; | 1130 return false; |
| 1088 | 1131 |
| 1089 if (start_session_type_ == PRIMARY_USER_SESSION) { | 1132 if (start_session_type_ == PRIMARY_USER_SESSION) { |
| 1090 UserFlow* user_flow = ChromeUserManager::Get()->GetCurrentUserFlow(); | 1133 UserFlow* user_flow = ChromeUserManager::Get()->GetCurrentUserFlow(); |
| 1091 WizardController* oobe_controller = WizardController::default_controller(); | 1134 WizardController* oobe_controller = WizardController::default_controller(); |
| 1092 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); | 1135 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
| 1093 bool skip_post_login_screens = | 1136 bool skip_post_login_screens = |
| 1094 user_flow->ShouldSkipPostLoginScreens() || | 1137 user_flow->ShouldSkipPostLoginScreens() || |
| 1095 (oobe_controller && oobe_controller->skip_post_login_screens()) || | 1138 (oobe_controller && oobe_controller->skip_post_login_screens()) || |
| 1096 cmdline->HasSwitch(chromeos::switches::kOobeSkipPostLogin); | 1139 cmdline->HasSwitch(chromeos::switches::kOobeSkipPostLogin); |
| 1097 | 1140 |
| 1098 if (user_manager->IsCurrentUserNew() && !skip_post_login_screens) { | 1141 if (user_manager->IsCurrentUserNew() && !skip_post_login_screens) { |
| 1099 // Don't specify start URLs if the administrator has configured the start | 1142 // Don't specify start URLs if the administrator has configured the start |
| 1100 // URLs via policy. | 1143 // URLs via policy. |
| 1101 if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs())) | 1144 if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs())) { |
| 1102 InitializeStartUrls(); | 1145 if (flags_fetching_ended_) |
| 1146 InitializeStartUrls(); | |
| 1147 else | |
| 1148 requesting_start_urls_ = true; | |
| 1149 } | |
| 1103 | 1150 |
| 1104 // Mark the device as registered., i.e. the second part of OOBE as | 1151 // Mark the device as registered., i.e. the second part of OOBE as |
| 1105 // completed. | 1152 // completed. |
| 1106 if (!StartupUtils::IsDeviceRegistered()) | 1153 if (!StartupUtils::IsDeviceRegistered()) |
| 1107 StartupUtils::MarkDeviceRegistered(base::Closure()); | 1154 StartupUtils::MarkDeviceRegistered(base::Closure()); |
| 1108 | 1155 |
| 1109 ActivateWizard(WizardController::kTermsOfServiceScreenName); | 1156 ActivateWizard(WizardController::kTermsOfServiceScreenName); |
| 1110 return false; | 1157 return false; |
| 1111 } | 1158 } |
| 1112 } | 1159 } |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1542 default_ime_states_.erase(profile); | 1589 default_ime_states_.erase(profile); |
| 1543 } | 1590 } |
| 1544 | 1591 |
| 1545 void UserSessionManager::InjectStubUserContext( | 1592 void UserSessionManager::InjectStubUserContext( |
| 1546 const UserContext& user_context) { | 1593 const UserContext& user_context) { |
| 1547 injected_user_context_.reset(new UserContext(user_context)); | 1594 injected_user_context_.reset(new UserContext(user_context)); |
| 1548 authenticator_ = NULL; | 1595 authenticator_ = NULL; |
| 1549 } | 1596 } |
| 1550 | 1597 |
| 1551 } // namespace chromeos | 1598 } // namespace chromeos |
| OLD | NEW |