| 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 15 matching lines...) Expand all Loading... |
| 93 #include "content/public/browser/browser_thread.h" | 95 #include "content/public/browser/browser_thread.h" |
| 94 #include "content/public/browser/notification_service.h" | 96 #include "content/public/browser/notification_service.h" |
| 95 #include "content/public/browser/storage_partition.h" | 97 #include "content/public/browser/storage_partition.h" |
| 96 #include "ui/base/ime/chromeos/input_method_manager.h" | 98 #include "ui/base/ime/chromeos/input_method_manager.h" |
| 97 #include "url/gurl.h" | 99 #include "url/gurl.h" |
| 98 | 100 |
| 99 namespace chromeos { | 101 namespace chromeos { |
| 100 | 102 |
| 101 namespace { | 103 namespace { |
| 102 | 104 |
| 105 // Milliseconds until we timeout our attempt to fetch flags from Child Account |
| 106 // Service. |
| 107 static const int kFlagsFetchingLoginTimeoutMs = 1000; |
| 108 |
| 103 // ChromeVox tutorial URL (used in place of "getting started" url when | 109 // ChromeVox tutorial URL (used in place of "getting started" url when |
| 104 // accessibility is enabled). | 110 // accessibility is enabled). |
| 105 const char kChromeVoxTutorialURLPattern[] = | 111 const char kChromeVoxTutorialURLPattern[] = |
| 106 "http://www.chromevox.com/tutorial/index.html?lang=%s"; | 112 "http://www.chromevox.com/tutorial/index.html?lang=%s"; |
| 107 | 113 |
| 108 void InitLocaleAndInputMethodsForNewUser( | 114 void InitLocaleAndInputMethodsForNewUser( |
| 109 UserSessionManager* session_manager, | 115 UserSessionManager* session_manager, |
| 110 Profile* profile, | 116 Profile* profile, |
| 111 const std::string& public_session_locale, | 117 const std::string& public_session_locale, |
| 112 const std::string& public_session_input_method) { | 118 const std::string& public_session_input_method) { |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 true /* path is absolute */, | 312 true /* path is absolute */, |
| 307 false /* don't create */); | 313 false /* don't create */); |
| 308 } | 314 } |
| 309 } | 315 } |
| 310 } | 316 } |
| 311 | 317 |
| 312 // static | 318 // static |
| 313 void UserSessionManager::RegisterPrefs(PrefRegistrySimple* registry) { | 319 void UserSessionManager::RegisterPrefs(PrefRegistrySimple* registry) { |
| 314 registry->RegisterStringPref(prefs::kRLZBrand, std::string()); | 320 registry->RegisterStringPref(prefs::kRLZBrand, std::string()); |
| 315 registry->RegisterBooleanPref(prefs::kRLZDisabled, false); | 321 registry->RegisterBooleanPref(prefs::kRLZDisabled, false); |
| 322 registry->RegisterBooleanPref(prefs::kChildAccountStatusKnown, false); |
| 316 } | 323 } |
| 317 | 324 |
| 318 UserSessionManager::UserSessionManager() | 325 UserSessionManager::UserSessionManager() |
| 319 : delegate_(nullptr), | 326 : delegate_(nullptr), |
| 320 authenticator_(nullptr), | 327 authenticator_(nullptr), |
| 321 has_auth_cookies_(false), | 328 has_auth_cookies_(false), |
| 322 user_sessions_restored_(false), | 329 user_sessions_restored_(false), |
| 323 user_sessions_restore_in_progress_(false), | 330 user_sessions_restore_in_progress_(false), |
| 324 exit_after_session_restore_(false), | 331 exit_after_session_restore_(false), |
| 325 session_restore_strategy_( | 332 session_restore_strategy_( |
| 326 OAuth2LoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN), | 333 OAuth2LoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN), |
| 327 running_easy_unlock_key_ops_(false), | 334 running_easy_unlock_key_ops_(false), |
| 328 should_launch_browser_(true) { | 335 should_launch_browser_(true), |
| 336 init_start_urls_was_postponed_(false), |
| 337 profile_fetching_flags_(nullptr), |
| 338 weak_factory_(this) { |
| 329 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); | 339 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); |
| 330 user_manager::UserManager::Get()->AddSessionStateObserver(this); | 340 user_manager::UserManager::Get()->AddSessionStateObserver(this); |
| 331 } | 341 } |
| 332 | 342 |
| 333 UserSessionManager::~UserSessionManager() { | 343 UserSessionManager::~UserSessionManager() { |
| 334 // UserManager is destroyed before singletons, so we need to check if it | 344 // UserManager is destroyed before singletons, so we need to check if it |
| 335 // still exists. | 345 // still exists. |
| 336 // TODO(nkostylev): fix order of destruction of UserManager | 346 // TODO(nkostylev): fix order of destruction of UserManager |
| 337 // / UserSessionManager objects. | 347 // / UserSessionManager objects. |
| 338 if (user_manager::UserManager::IsInitialized()) | 348 if (user_manager::UserManager::IsInitialized()) |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 // users once it is fully multi-profile aware. http://crbug.com/238987 | 782 // 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 | 783 // For now if we have other user pending sessions they'll override OAuth |
| 774 // session restore for previous users. | 784 // session restore for previous users. |
| 775 RestoreAuthenticationSession(profile); | 785 RestoreAuthenticationSession(profile); |
| 776 } | 786 } |
| 777 | 787 |
| 778 // Restore other user sessions if any. | 788 // Restore other user sessions if any. |
| 779 RestorePendingUserSessions(); | 789 RestorePendingUserSessions(); |
| 780 } | 790 } |
| 781 | 791 |
| 792 void UserSessionManager::OnChildAccountStatusChanged() { |
| 793 StopStatusObserving(); |
| 794 } |
| 795 |
| 796 void UserSessionManager::StopStatusObserving() { |
| 797 if (!profile_fetching_flags_) |
| 798 return; |
| 799 ChildAccountService* child_service = |
| 800 ChildAccountServiceFactory::GetForProfile(profile_fetching_flags_); |
| 801 if (child_service) |
| 802 child_service->RemoveStatusObserver(this); |
| 803 profile_fetching_flags_ = nullptr; |
| 804 |
| 805 if (init_start_urls_was_postponed_) { |
| 806 InitializeStartUrls(); |
| 807 init_start_urls_was_postponed_ = false; |
| 808 } |
| 809 } |
| 810 |
| 782 void UserSessionManager::CreateUserSession(const UserContext& user_context, | 811 void UserSessionManager::CreateUserSession(const UserContext& user_context, |
| 783 bool has_auth_cookies) { | 812 bool has_auth_cookies) { |
| 784 user_context_ = user_context; | 813 user_context_ = user_context; |
| 785 has_auth_cookies_ = has_auth_cookies; | 814 has_auth_cookies_ = has_auth_cookies; |
| 786 InitSessionRestoreStrategy(); | 815 InitSessionRestoreStrategy(); |
| 787 } | 816 } |
| 788 | 817 |
| 789 void UserSessionManager::PreStartSession() { | 818 void UserSessionManager::PreStartSession() { |
| 790 // Switch log file as soon as possible. | 819 // Switch log file as soon as possible. |
| 791 if (base::SysInfo::IsRunningOnChromeOS()) | 820 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) { | 1067 void UserSessionManager::ActivateWizard(const std::string& screen_name) { |
| 1039 LoginDisplayHost* host = LoginDisplayHostImpl::default_host(); | 1068 LoginDisplayHost* host = LoginDisplayHostImpl::default_host(); |
| 1040 CHECK(host); | 1069 CHECK(host); |
| 1041 host->StartWizard(screen_name); | 1070 host->StartWizard(screen_name); |
| 1042 } | 1071 } |
| 1043 | 1072 |
| 1044 void UserSessionManager::InitializeStartUrls() const { | 1073 void UserSessionManager::InitializeStartUrls() const { |
| 1045 std::vector<std::string> start_urls; | 1074 std::vector<std::string> start_urls; |
| 1046 | 1075 |
| 1047 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 1076 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
| 1077 |
| 1048 bool can_show_getstarted_guide = | 1078 bool can_show_getstarted_guide = |
| 1049 user_manager->GetActiveUser()->GetType() == | 1079 user_manager->GetActiveUser()->GetType() == |
| 1050 user_manager::USER_TYPE_REGULAR && | 1080 user_manager::USER_TYPE_REGULAR && |
| 1051 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); | 1081 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); |
| 1082 |
| 1052 // Skip the default first-run behavior for public accounts. | 1083 // Skip the default first-run behavior for public accounts. |
| 1053 if (!user_manager->IsLoggedInAsPublicAccount()) { | 1084 if (!user_manager->IsLoggedInAsPublicAccount()) { |
| 1054 if (AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) { | 1085 if (AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) { |
| 1055 const char* url = kChromeVoxTutorialURLPattern; | 1086 const char* url = kChromeVoxTutorialURLPattern; |
| 1056 PrefService* prefs = g_browser_process->local_state(); | 1087 PrefService* prefs = g_browser_process->local_state(); |
| 1057 const std::string current_locale = | 1088 const std::string current_locale = |
| 1058 base::StringToLowerASCII(prefs->GetString(prefs::kApplicationLocale)); | 1089 base::StringToLowerASCII(prefs->GetString(prefs::kApplicationLocale)); |
| 1059 std::string vox_url = base::StringPrintf(url, current_locale.c_str()); | 1090 std::string vox_url = base::StringPrintf(url, current_locale.c_str()); |
| 1060 start_urls.push_back(vox_url); | 1091 start_urls.push_back(vox_url); |
| 1061 can_show_getstarted_guide = false; | 1092 can_show_getstarted_guide = false; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1073 ::switches::kSilentLaunch); | 1104 ::switches::kSilentLaunch); |
| 1074 first_run::MaybeLaunchDialogAfterSessionStart(); | 1105 first_run::MaybeLaunchDialogAfterSessionStart(); |
| 1075 } else { | 1106 } else { |
| 1076 for (size_t i = 0; i < start_urls.size(); ++i) { | 1107 for (size_t i = 0; i < start_urls.size(); ++i) { |
| 1077 base::CommandLine::ForCurrentProcess()->AppendArg(start_urls[i]); | 1108 base::CommandLine::ForCurrentProcess()->AppendArg(start_urls[i]); |
| 1078 } | 1109 } |
| 1079 } | 1110 } |
| 1080 } | 1111 } |
| 1081 | 1112 |
| 1082 bool UserSessionManager::InitializeUserSession(Profile* profile) { | 1113 bool UserSessionManager::InitializeUserSession(Profile* profile) { |
| 1114 ChildAccountService* child_service = |
| 1115 ChildAccountServiceFactory::GetForProfile(profile); |
| 1116 if (child_service) |
| 1117 child_service->AddStatusObserver(this); |
| 1118 base::MessageLoopProxy::current()->PostDelayedTask( |
| 1119 FROM_HERE, |
| 1120 base::Bind(&UserSessionManager::StopStatusObserving, |
| 1121 weak_factory_.GetWeakPtr()), |
| 1122 base::TimeDelta::FromMilliseconds(kFlagsFetchingLoginTimeoutMs)); |
| 1123 profile_fetching_flags_ = profile; |
| 1124 |
| 1083 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 1125 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
| 1084 | 1126 |
| 1085 // Kiosk apps has their own session initialization pipeline. | 1127 // Kiosk apps has their own session initialization pipeline. |
| 1086 if (user_manager->IsLoggedInAsKioskApp()) | 1128 if (user_manager->IsLoggedInAsKioskApp()) |
| 1087 return false; | 1129 return false; |
| 1088 | 1130 |
| 1089 if (start_session_type_ == PRIMARY_USER_SESSION) { | 1131 if (start_session_type_ == PRIMARY_USER_SESSION) { |
| 1090 UserFlow* user_flow = ChromeUserManager::Get()->GetCurrentUserFlow(); | 1132 UserFlow* user_flow = ChromeUserManager::Get()->GetCurrentUserFlow(); |
| 1091 WizardController* oobe_controller = WizardController::default_controller(); | 1133 WizardController* oobe_controller = WizardController::default_controller(); |
| 1092 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); | 1134 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
| 1093 bool skip_post_login_screens = | 1135 bool skip_post_login_screens = |
| 1094 user_flow->ShouldSkipPostLoginScreens() || | 1136 user_flow->ShouldSkipPostLoginScreens() || |
| 1095 (oobe_controller && oobe_controller->skip_post_login_screens()) || | 1137 (oobe_controller && oobe_controller->skip_post_login_screens()) || |
| 1096 cmdline->HasSwitch(chromeos::switches::kOobeSkipPostLogin); | 1138 cmdline->HasSwitch(chromeos::switches::kOobeSkipPostLogin); |
| 1097 | 1139 |
| 1098 if (user_manager->IsCurrentUserNew() && !skip_post_login_screens) { | 1140 if (user_manager->IsCurrentUserNew() && !skip_post_login_screens) { |
| 1099 // Don't specify start URLs if the administrator has configured the start | 1141 // Don't specify start URLs if the administrator has configured the start |
| 1100 // URLs via policy. | 1142 // URLs via policy. |
| 1101 if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs())) | 1143 if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs())) { |
| 1102 InitializeStartUrls(); | 1144 if (child_service && child_service->IsChildAccountStatusKnown()) |
| 1145 InitializeStartUrls(); |
| 1146 else |
| 1147 init_start_urls_was_postponed_ = true; |
| 1148 } |
| 1103 | 1149 |
| 1104 // Mark the device as registered., i.e. the second part of OOBE as | 1150 // Mark the device as registered., i.e. the second part of OOBE as |
| 1105 // completed. | 1151 // completed. |
| 1106 if (!StartupUtils::IsDeviceRegistered()) | 1152 if (!StartupUtils::IsDeviceRegistered()) |
| 1107 StartupUtils::MarkDeviceRegistered(base::Closure()); | 1153 StartupUtils::MarkDeviceRegistered(base::Closure()); |
| 1108 | 1154 |
| 1109 ActivateWizard(WizardController::kTermsOfServiceScreenName); | 1155 ActivateWizard(WizardController::kTermsOfServiceScreenName); |
| 1110 return false; | 1156 return false; |
| 1111 } | 1157 } |
| 1112 } | 1158 } |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1542 default_ime_states_.erase(profile); | 1588 default_ime_states_.erase(profile); |
| 1543 } | 1589 } |
| 1544 | 1590 |
| 1545 void UserSessionManager::InjectStubUserContext( | 1591 void UserSessionManager::InjectStubUserContext( |
| 1546 const UserContext& user_context) { | 1592 const UserContext& user_context) { |
| 1547 injected_user_context_.reset(new UserContext(user_context)); | 1593 injected_user_context_.reset(new UserContext(user_context)); |
| 1548 authenticator_ = NULL; | 1594 authenticator_ = NULL; |
| 1549 } | 1595 } |
| 1550 | 1596 |
| 1551 } // namespace chromeos | 1597 } // namespace chromeos |
| OLD | NEW |