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