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 the child |
| 106 // account 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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 UserSessionManager::UserSessionManager() | 324 UserSessionManager::UserSessionManager() |
319 : delegate_(nullptr), | 325 : delegate_(nullptr), |
320 authenticator_(nullptr), | 326 authenticator_(nullptr), |
321 has_auth_cookies_(false), | 327 has_auth_cookies_(false), |
322 user_sessions_restored_(false), | 328 user_sessions_restored_(false), |
323 user_sessions_restore_in_progress_(false), | 329 user_sessions_restore_in_progress_(false), |
324 exit_after_session_restore_(false), | 330 exit_after_session_restore_(false), |
325 session_restore_strategy_( | 331 session_restore_strategy_( |
326 OAuth2LoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN), | 332 OAuth2LoginManager::RESTORE_FROM_SAVED_OAUTH2_REFRESH_TOKEN), |
327 running_easy_unlock_key_ops_(false), | 333 running_easy_unlock_key_ops_(false), |
328 should_launch_browser_(true) { | 334 should_launch_browser_(true), |
| 335 init_start_urls_was_postponed_(false), |
| 336 flag_fetching_profile_(nullptr), |
| 337 weak_factory_(this) { |
329 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); | 338 net::NetworkChangeNotifier::AddConnectionTypeObserver(this); |
330 user_manager::UserManager::Get()->AddSessionStateObserver(this); | 339 user_manager::UserManager::Get()->AddSessionStateObserver(this); |
331 } | 340 } |
332 | 341 |
333 UserSessionManager::~UserSessionManager() { | 342 UserSessionManager::~UserSessionManager() { |
334 // UserManager is destroyed before singletons, so we need to check if it | 343 // UserManager is destroyed before singletons, so we need to check if it |
335 // still exists. | 344 // still exists. |
336 // TODO(nkostylev): fix order of destruction of UserManager | 345 // TODO(nkostylev): fix order of destruction of UserManager |
337 // / UserSessionManager objects. | 346 // / UserSessionManager objects. |
338 if (user_manager::UserManager::IsInitialized()) | 347 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 | 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::ChildAccountStatusReceivedCallback() { |
| 792 StopStatusObserving(); |
| 793 } |
| 794 |
| 795 void UserSessionManager::StopStatusObserving() { |
| 796 if (!flag_fetching_profile_) |
| 797 return; |
| 798 flag_fetching_profile_ = nullptr; |
| 799 |
| 800 if (init_start_urls_was_postponed_) { |
| 801 InitializeStartUrls(); |
| 802 init_start_urls_was_postponed_ = false; |
| 803 } |
| 804 } |
| 805 |
782 void UserSessionManager::CreateUserSession(const UserContext& user_context, | 806 void UserSessionManager::CreateUserSession(const UserContext& user_context, |
783 bool has_auth_cookies) { | 807 bool has_auth_cookies) { |
784 user_context_ = user_context; | 808 user_context_ = user_context; |
785 has_auth_cookies_ = has_auth_cookies; | 809 has_auth_cookies_ = has_auth_cookies; |
786 InitSessionRestoreStrategy(); | 810 InitSessionRestoreStrategy(); |
787 } | 811 } |
788 | 812 |
789 void UserSessionManager::PreStartSession() { | 813 void UserSessionManager::PreStartSession() { |
790 // Switch log file as soon as possible. | 814 // Switch log file as soon as possible. |
791 if (base::SysInfo::IsRunningOnChromeOS()) | 815 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) { | 1062 void UserSessionManager::ActivateWizard(const std::string& screen_name) { |
1039 LoginDisplayHost* host = LoginDisplayHostImpl::default_host(); | 1063 LoginDisplayHost* host = LoginDisplayHostImpl::default_host(); |
1040 CHECK(host); | 1064 CHECK(host); |
1041 host->StartWizard(screen_name); | 1065 host->StartWizard(screen_name); |
1042 } | 1066 } |
1043 | 1067 |
1044 void UserSessionManager::InitializeStartUrls() const { | 1068 void UserSessionManager::InitializeStartUrls() const { |
1045 std::vector<std::string> start_urls; | 1069 std::vector<std::string> start_urls; |
1046 | 1070 |
1047 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 1071 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
| 1072 |
1048 bool can_show_getstarted_guide = | 1073 bool can_show_getstarted_guide = |
1049 user_manager->GetActiveUser()->GetType() == | 1074 user_manager->GetActiveUser()->GetType() == |
1050 user_manager::USER_TYPE_REGULAR && | 1075 user_manager::USER_TYPE_REGULAR && |
1051 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); | 1076 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); |
| 1077 |
1052 // Skip the default first-run behavior for public accounts. | 1078 // Skip the default first-run behavior for public accounts. |
1053 if (!user_manager->IsLoggedInAsPublicAccount()) { | 1079 if (!user_manager->IsLoggedInAsPublicAccount()) { |
1054 if (AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) { | 1080 if (AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) { |
1055 const char* url = kChromeVoxTutorialURLPattern; | 1081 const char* url = kChromeVoxTutorialURLPattern; |
1056 PrefService* prefs = g_browser_process->local_state(); | 1082 PrefService* prefs = g_browser_process->local_state(); |
1057 const std::string current_locale = | 1083 const std::string current_locale = |
1058 base::StringToLowerASCII(prefs->GetString(prefs::kApplicationLocale)); | 1084 base::StringToLowerASCII(prefs->GetString(prefs::kApplicationLocale)); |
1059 std::string vox_url = base::StringPrintf(url, current_locale.c_str()); | 1085 std::string vox_url = base::StringPrintf(url, current_locale.c_str()); |
1060 start_urls.push_back(vox_url); | 1086 start_urls.push_back(vox_url); |
1061 can_show_getstarted_guide = false; | 1087 can_show_getstarted_guide = false; |
(...skipping 11 matching lines...) Expand all Loading... |
1073 ::switches::kSilentLaunch); | 1099 ::switches::kSilentLaunch); |
1074 first_run::MaybeLaunchDialogAfterSessionStart(); | 1100 first_run::MaybeLaunchDialogAfterSessionStart(); |
1075 } else { | 1101 } else { |
1076 for (size_t i = 0; i < start_urls.size(); ++i) { | 1102 for (size_t i = 0; i < start_urls.size(); ++i) { |
1077 base::CommandLine::ForCurrentProcess()->AppendArg(start_urls[i]); | 1103 base::CommandLine::ForCurrentProcess()->AppendArg(start_urls[i]); |
1078 } | 1104 } |
1079 } | 1105 } |
1080 } | 1106 } |
1081 | 1107 |
1082 bool UserSessionManager::InitializeUserSession(Profile* profile) { | 1108 bool UserSessionManager::InitializeUserSession(Profile* profile) { |
| 1109 ChildAccountService* child_service = |
| 1110 ChildAccountServiceFactory::GetForProfile(profile); |
| 1111 child_service->AddChildStatusReceivedCallback(base::Bind( |
| 1112 &UserSessionManager::ChildAccountStatusReceivedCallback, |
| 1113 weak_factory_.GetWeakPtr())); |
| 1114 base::MessageLoopProxy::current()->PostDelayedTask( |
| 1115 FROM_HERE, |
| 1116 base::Bind(&UserSessionManager::StopStatusObserving, |
| 1117 weak_factory_.GetWeakPtr()), |
| 1118 base::TimeDelta::FromMilliseconds(kFlagsFetchingLoginTimeoutMs)); |
| 1119 flag_fetching_profile_ = profile; |
| 1120 |
1083 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); | 1121 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
1084 | 1122 |
1085 // Kiosk apps has their own session initialization pipeline. | 1123 // Kiosk apps has their own session initialization pipeline. |
1086 if (user_manager->IsLoggedInAsKioskApp()) | 1124 if (user_manager->IsLoggedInAsKioskApp()) |
1087 return false; | 1125 return false; |
1088 | 1126 |
1089 if (start_session_type_ == PRIMARY_USER_SESSION) { | 1127 if (start_session_type_ == PRIMARY_USER_SESSION) { |
1090 UserFlow* user_flow = ChromeUserManager::Get()->GetCurrentUserFlow(); | 1128 UserFlow* user_flow = ChromeUserManager::Get()->GetCurrentUserFlow(); |
1091 WizardController* oobe_controller = WizardController::default_controller(); | 1129 WizardController* oobe_controller = WizardController::default_controller(); |
1092 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); | 1130 base::CommandLine* cmdline = base::CommandLine::ForCurrentProcess(); |
1093 bool skip_post_login_screens = | 1131 bool skip_post_login_screens = |
1094 user_flow->ShouldSkipPostLoginScreens() || | 1132 user_flow->ShouldSkipPostLoginScreens() || |
1095 (oobe_controller && oobe_controller->skip_post_login_screens()) || | 1133 (oobe_controller && oobe_controller->skip_post_login_screens()) || |
1096 cmdline->HasSwitch(chromeos::switches::kOobeSkipPostLogin); | 1134 cmdline->HasSwitch(chromeos::switches::kOobeSkipPostLogin); |
1097 | 1135 |
1098 if (user_manager->IsCurrentUserNew() && !skip_post_login_screens) { | 1136 if (user_manager->IsCurrentUserNew() && !skip_post_login_screens) { |
1099 // Don't specify start URLs if the administrator has configured the start | 1137 // Don't specify start URLs if the administrator has configured the start |
1100 // URLs via policy. | 1138 // URLs via policy. |
1101 if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs())) | 1139 if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs())) { |
1102 InitializeStartUrls(); | 1140 if (child_service->IsChildAccountStatusKnown()) |
| 1141 InitializeStartUrls(); |
| 1142 else |
| 1143 init_start_urls_was_postponed_ = true; |
| 1144 } |
1103 | 1145 |
1104 // Mark the device as registered., i.e. the second part of OOBE as | 1146 // Mark the device as registered., i.e. the second part of OOBE as |
1105 // completed. | 1147 // completed. |
1106 if (!StartupUtils::IsDeviceRegistered()) | 1148 if (!StartupUtils::IsDeviceRegistered()) |
1107 StartupUtils::MarkDeviceRegistered(base::Closure()); | 1149 StartupUtils::MarkDeviceRegistered(base::Closure()); |
1108 | 1150 |
1109 ActivateWizard(WizardController::kTermsOfServiceScreenName); | 1151 ActivateWizard(WizardController::kTermsOfServiceScreenName); |
1110 return false; | 1152 return false; |
1111 } | 1153 } |
1112 } | 1154 } |
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1535 default_ime_states_.erase(profile); | 1577 default_ime_states_.erase(profile); |
1536 } | 1578 } |
1537 | 1579 |
1538 void UserSessionManager::InjectStubUserContext( | 1580 void UserSessionManager::InjectStubUserContext( |
1539 const UserContext& user_context) { | 1581 const UserContext& user_context) { |
1540 injected_user_context_.reset(new UserContext(user_context)); | 1582 injected_user_context_.reset(new UserContext(user_context)); |
1541 authenticator_ = NULL; | 1583 authenticator_ = NULL; |
1542 } | 1584 } |
1543 | 1585 |
1544 } // namespace chromeos | 1586 } // namespace chromeos |
OLD | NEW |