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" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
14 #include "base/prefs/pref_member.h" | 14 #include "base/prefs/pref_member.h" |
15 #include "base/prefs/pref_registry_simple.h" | 15 #include "base/prefs/pref_registry_simple.h" |
16 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
17 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
| 18 #include "base/strings/stringprintf.h" |
18 #include "base/sys_info.h" | 19 #include "base/sys_info.h" |
19 #include "base/task_runner_util.h" | 20 #include "base/task_runner_util.h" |
20 #include "base/threading/worker_pool.h" | 21 #include "base/threading/worker_pool.h" |
21 #include "chrome/browser/about_flags.h" | 22 #include "chrome/browser/about_flags.h" |
22 #include "chrome/browser/app_mode/app_mode_utils.h" | 23 #include "chrome/browser/app_mode/app_mode_utils.h" |
23 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
24 #include "chrome/browser/browser_process_platform_part_chromeos.h" | 25 #include "chrome/browser/browser_process_platform_part_chromeos.h" |
25 #include "chrome/browser/chrome_notification_types.h" | 26 #include "chrome/browser/chrome_notification_types.h" |
| 27 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
26 #include "chrome/browser/chromeos/base/locale_util.h" | 28 #include "chrome/browser/chromeos/base/locale_util.h" |
27 #include "chrome/browser/chromeos/boot_times_loader.h" | 29 #include "chrome/browser/chromeos/boot_times_loader.h" |
| 30 #include "chrome/browser/chromeos/first_run/first_run.h" |
28 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 31 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
29 #include "chrome/browser/chromeos/login/chrome_restart_request.h" | 32 #include "chrome/browser/chromeos/login/chrome_restart_request.h" |
30 #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h" | 33 #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h" |
31 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h" | 34 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h" |
32 #include "chrome/browser/chromeos/login/profile_auth_data.h" | 35 #include "chrome/browser/chromeos/login/profile_auth_data.h" |
33 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h" | 36 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h" |
34 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter_factory
.h" | 37 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter_factory
.h" |
35 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" | 38 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" |
36 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" | 39 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" |
37 #include "chrome/browser/chromeos/login/startup_utils.h" | 40 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 41 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 42 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 43 #include "chrome/browser/chromeos/login/user_flow.h" |
38 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 44 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
39 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" | 45 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" |
| 46 #include "chrome/browser/chromeos/login/wizard_controller.h" |
40 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 47 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
41 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 48 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
42 #include "chrome/browser/chromeos/settings/cros_settings.h" | 49 #include "chrome/browser/chromeos/settings/cros_settings.h" |
43 #include "chrome/browser/first_run/first_run.h" | 50 #include "chrome/browser/first_run/first_run.h" |
44 #include "chrome/browser/google/google_brand_chromeos.h" | 51 #include "chrome/browser/google/google_brand_chromeos.h" |
45 #include "chrome/browser/lifetime/application_lifetime.h" | 52 #include "chrome/browser/lifetime/application_lifetime.h" |
46 #include "chrome/browser/net/crl_set_fetcher.h" | 53 #include "chrome/browser/net/crl_set_fetcher.h" |
47 #include "chrome/browser/net/nss_context.h" | 54 #include "chrome/browser/net/nss_context.h" |
| 55 #include "chrome/browser/prefs/session_startup_pref.h" |
48 #include "chrome/browser/profiles/profile.h" | 56 #include "chrome/browser/profiles/profile.h" |
49 #include "chrome/browser/profiles/profile_manager.h" | 57 #include "chrome/browser/profiles/profile_manager.h" |
50 #include "chrome/browser/rlz/rlz.h" | 58 #include "chrome/browser/rlz/rlz.h" |
51 #include "chrome/browser/signin/easy_unlock_service.h" | 59 #include "chrome/browser/signin/easy_unlock_service.h" |
52 #include "chrome/browser/signin/signin_manager_factory.h" | 60 #include "chrome/browser/signin/signin_manager_factory.h" |
53 #include "chrome/common/chrome_switches.h" | 61 #include "chrome/common/chrome_switches.h" |
54 #include "chrome/common/logging_chrome.h" | 62 #include "chrome/common/logging_chrome.h" |
55 #include "chrome/common/pref_names.h" | 63 #include "chrome/common/pref_names.h" |
56 #include "chromeos/cert_loader.h" | 64 #include "chromeos/cert_loader.h" |
57 #include "chromeos/chromeos_switches.h" | 65 #include "chromeos/chromeos_switches.h" |
(...skipping 14 matching lines...) Expand all Loading... |
72 #include "components/user_manager/user_manager.h" | 80 #include "components/user_manager/user_manager.h" |
73 #include "components/user_manager/user_type.h" | 81 #include "components/user_manager/user_type.h" |
74 #include "content/public/browser/browser_thread.h" | 82 #include "content/public/browser/browser_thread.h" |
75 #include "content/public/browser/notification_service.h" | 83 #include "content/public/browser/notification_service.h" |
76 #include "url/gurl.h" | 84 #include "url/gurl.h" |
77 | 85 |
78 namespace chromeos { | 86 namespace chromeos { |
79 | 87 |
80 namespace { | 88 namespace { |
81 | 89 |
| 90 // ChromeVox tutorial URL (used in place of "getting started" url when |
| 91 // accessibility is enabled). |
| 92 const char kChromeVoxTutorialURLPattern[] = |
| 93 "http://www.chromevox.com/tutorial/index.html?lang=%s"; |
| 94 |
82 void InitLocaleAndInputMethodsForNewUser( | 95 void InitLocaleAndInputMethodsForNewUser( |
83 UserSessionManager* session_manager, | 96 UserSessionManager* session_manager, |
84 Profile* profile, | 97 Profile* profile, |
85 const std::string& public_session_locale, | 98 const std::string& public_session_locale, |
86 const std::string& public_session_input_method) { | 99 const std::string& public_session_input_method) { |
87 PrefService* prefs = profile->GetPrefs(); | 100 PrefService* prefs = profile->GetPrefs(); |
88 std::string locale; | 101 std::string locale; |
89 if (!public_session_locale.empty()) { | 102 if (!public_session_locale.empty()) { |
90 // If this is a public session and the user chose a |public_session_locale|, | 103 // If this is a public session and the user chose a |public_session_locale|, |
91 // write it to |prefs| so that the UI switches to it. | 104 // write it to |prefs| so that the UI switches to it. |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser( | 284 DBusThreadManager::Get()->GetSessionManagerClient()->SetFlagsForUser( |
272 chromeos::login::kGuestUserName, | 285 chromeos::login::kGuestUserName, |
273 CommandLine::StringVector()); | 286 CommandLine::StringVector()); |
274 } | 287 } |
275 | 288 |
276 RestartChrome(cmd_line_str); | 289 RestartChrome(cmd_line_str); |
277 } | 290 } |
278 | 291 |
279 void UserSessionManager::StartSession( | 292 void UserSessionManager::StartSession( |
280 const UserContext& user_context, | 293 const UserContext& user_context, |
| 294 StartSessionType start_session_type, |
281 scoped_refptr<Authenticator> authenticator, | 295 scoped_refptr<Authenticator> authenticator, |
282 bool has_auth_cookies, | 296 bool has_auth_cookies, |
283 bool has_active_session, | 297 bool has_active_session, |
284 UserSessionManagerDelegate* delegate) { | 298 UserSessionManagerDelegate* delegate) { |
285 authenticator_ = authenticator; | 299 authenticator_ = authenticator; |
286 delegate_ = delegate; | 300 delegate_ = delegate; |
| 301 start_session_type_ = start_session_type; |
287 | 302 |
288 VLOG(1) << "Starting session for " << user_context.GetUserID(); | 303 VLOG(1) << "Starting session for " << user_context.GetUserID(); |
289 | 304 |
290 PreStartSession(); | 305 PreStartSession(); |
291 CreateUserSession(user_context, has_auth_cookies); | 306 CreateUserSession(user_context, has_auth_cookies); |
292 | 307 |
293 if (!has_active_session) | 308 if (!has_active_session) |
294 StartCrosSession(); | 309 StartCrosSession(); |
295 | 310 |
296 // TODO(nkostylev): Notify UserLoggedIn() after profile is actually | 311 // TODO(nkostylev): Notify UserLoggedIn() after profile is actually |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 // If we come online for the first time after successful offline login, | 623 // If we come online for the first time after successful offline login, |
609 // we need to kick off OAuth token verification process again. | 624 // we need to kick off OAuth token verification process again. |
610 login_manager->ContinueSessionRestore(); | 625 login_manager->ContinueSessionRestore(); |
611 } else if (should_restore_session) { | 626 } else if (should_restore_session) { |
612 pending_signin_restore_sessions_.erase((*it)->email()); | 627 pending_signin_restore_sessions_.erase((*it)->email()); |
613 RestoreAuthSessionImpl(user_profile, false /* has_auth_cookies */); | 628 RestoreAuthSessionImpl(user_profile, false /* has_auth_cookies */); |
614 } | 629 } |
615 } | 630 } |
616 } | 631 } |
617 | 632 |
618 void UserSessionManager::OnProfilePrepared(Profile* profile) { | 633 void UserSessionManager::OnProfilePrepared(Profile* profile, |
619 LoginUtils::Get()->DoBrowserLaunch(profile, NULL); // host_, not needed here | 634 bool browser_launched) { |
620 | |
621 if (!CommandLine::ForCurrentProcess()->HasSwitch(::switches::kTestName)) { | 635 if (!CommandLine::ForCurrentProcess()->HasSwitch(::switches::kTestName)) { |
622 // Did not log in (we crashed or are debugging), need to restore Sync. | 636 // Did not log in (we crashed or are debugging), need to restore Sync. |
623 // TODO(nkostylev): Make sure that OAuth state is restored correctly for all | 637 // TODO(nkostylev): Make sure that OAuth state is restored correctly for all |
624 // users once it is fully multi-profile aware. http://crbug.com/238987 | 638 // users once it is fully multi-profile aware. http://crbug.com/238987 |
625 // For now if we have other user pending sessions they'll override OAuth | 639 // For now if we have other user pending sessions they'll override OAuth |
626 // session restore for previous users. | 640 // session restore for previous users. |
627 UserSessionManager::GetInstance()->RestoreAuthenticationSession(profile); | 641 UserSessionManager::GetInstance()->RestoreAuthenticationSession(profile); |
628 } | 642 } |
629 | 643 |
630 // Restore other user sessions if any. | 644 // Restore other user sessions if any. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 // profiles that might not have it set yet). | 750 // profiles that might not have it set yet). |
737 SigninManagerBase* signin_manager = | 751 SigninManagerBase* signin_manager = |
738 SigninManagerFactory::GetForProfile(profile); | 752 SigninManagerFactory::GetForProfile(profile); |
739 signin_manager->SetAuthenticatedUsername(user_context.GetUserID()); | 753 signin_manager->SetAuthenticatedUsername(user_context.GetUserID()); |
740 } | 754 } |
741 } | 755 } |
742 | 756 |
743 void UserSessionManager::UserProfileInitialized(Profile* profile, | 757 void UserSessionManager::UserProfileInitialized(Profile* profile, |
744 bool is_incognito_profile, | 758 bool is_incognito_profile, |
745 const std::string& user_id) { | 759 const std::string& user_id) { |
| 760 // Demo user signed in. |
746 if (is_incognito_profile) { | 761 if (is_incognito_profile) { |
747 profile->OnLogin(); | 762 profile->OnLogin(); |
| 763 |
748 // Send the notification before creating the browser so additional objects | 764 // Send the notification before creating the browser so additional objects |
749 // that need the profile (e.g. the launcher) can be created first. | 765 // that need the profile (e.g. the launcher) can be created first. |
750 content::NotificationService::current()->Notify( | 766 content::NotificationService::current()->Notify( |
751 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 767 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
752 content::NotificationService::AllSources(), | 768 content::NotificationService::AllSources(), |
753 content::Details<Profile>(profile)); | 769 content::Details<Profile>(profile)); |
754 | 770 |
755 if (delegate_) | 771 if (delegate_) |
756 delegate_->OnProfilePrepared(profile); | 772 delegate_->OnProfilePrepared(profile, false); |
757 | 773 |
758 return; | 774 return; |
759 } | 775 } |
760 | 776 |
761 BootTimesLoader* btl = BootTimesLoader::Get(); | 777 BootTimesLoader* btl = BootTimesLoader::Get(); |
762 btl->AddLoginTimeMarker("UserProfileGotten", false); | 778 btl->AddLoginTimeMarker("UserProfileGotten", false); |
763 | 779 |
764 if (user_context_.IsUsingOAuth()) { | 780 if (user_context_.IsUsingOAuth()) { |
765 // Retrieve the policy that indicates whether to continue copying | 781 // Retrieve the policy that indicates whether to continue copying |
766 // authentication cookies set by a SAML IdP on subsequent logins after the | 782 // authentication cookies set by a SAML IdP on subsequent logins after the |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 ProfileHelper::Get()->GetUserByProfile(profile); | 861 ProfileHelper::Get()->GetUserByProfile(profile); |
846 if (user_manager->GetPrimaryUser() == user) { | 862 if (user_manager->GetPrimaryUser() == user) { |
847 InitRlz(profile); | 863 InitRlz(profile); |
848 InitializeCerts(profile); | 864 InitializeCerts(profile); |
849 InitializeCRLSetFetcher(user); | 865 InitializeCRLSetFetcher(user); |
850 } | 866 } |
851 | 867 |
852 UpdateEasyUnlockKeys(user_context_); | 868 UpdateEasyUnlockKeys(user_context_); |
853 user_context_.ClearSecrets(); | 869 user_context_.ClearSecrets(); |
854 | 870 |
| 871 // Now that profile is ready, proceed to either alternative login flows or |
| 872 // launch browser. |
| 873 bool browser_launched = InitializeUserSession(profile); |
| 874 |
855 // TODO(nkostylev): This pointer should probably never be NULL, but it looks | 875 // TODO(nkostylev): This pointer should probably never be NULL, but it looks |
856 // like LoginUtilsImpl::OnProfileCreated() may be getting called before | 876 // like LoginUtilsImpl::OnProfileCreated() may be getting called before |
857 // UserSessionManager::PrepareProfile() has set |delegate_| when Chrome is | 877 // UserSessionManager::PrepareProfile() has set |delegate_| when Chrome is |
858 // killed during shutdown in tests -- see http://crosbug.com/18269. Replace | 878 // killed during shutdown in tests -- see http://crosbug.com/18269. Replace |
859 // this 'if' statement with a CHECK(delegate_) once the underlying issue is | 879 // this 'if' statement with a CHECK(delegate_) once the underlying issue is |
860 // resolved. | 880 // resolved. |
861 if (delegate_) | 881 if (delegate_) |
862 delegate_->OnProfilePrepared(profile); | 882 delegate_->OnProfilePrepared(profile, browser_launched); |
| 883 } |
| 884 |
| 885 void UserSessionManager::ActivateWizard(const std::string& screen_name) { |
| 886 LoginDisplayHost* host = LoginDisplayHostImpl::default_host(); |
| 887 DCHECK(host); |
| 888 if (host) { |
| 889 scoped_ptr<base::DictionaryValue> params; |
| 890 host->StartWizard(screen_name, params.Pass()); |
| 891 } |
| 892 } |
| 893 |
| 894 void UserSessionManager::InitializeStartUrls() const { |
| 895 std::vector<std::string> start_urls; |
| 896 |
| 897 const base::ListValue *urls; |
| 898 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
| 899 bool can_show_getstarted_guide = |
| 900 user_manager->GetActiveUser()->GetType() == |
| 901 user_manager::USER_TYPE_REGULAR && |
| 902 !user_manager->IsCurrentUserNonCryptohomeDataEphemeral(); |
| 903 if (user_manager->IsLoggedInAsDemoUser()) { |
| 904 if (CrosSettings::Get()->GetList(kStartUpUrls, &urls)) { |
| 905 // The retail mode user will get start URLs from a special policy if it is |
| 906 // set. |
| 907 for (base::ListValue::const_iterator it = urls->begin(); |
| 908 it != urls->end(); ++it) { |
| 909 std::string url; |
| 910 if ((*it)->GetAsString(&url)) |
| 911 start_urls.push_back(url); |
| 912 } |
| 913 } |
| 914 can_show_getstarted_guide = false; |
| 915 // Skip the default first-run behavior for public accounts. |
| 916 } else if (!user_manager->IsLoggedInAsPublicAccount()) { |
| 917 if (AccessibilityManager::Get()->IsSpokenFeedbackEnabled()) { |
| 918 const char* url = kChromeVoxTutorialURLPattern; |
| 919 PrefService* prefs = g_browser_process->local_state(); |
| 920 const std::string current_locale = |
| 921 base::StringToLowerASCII(prefs->GetString(prefs::kApplicationLocale)); |
| 922 std::string vox_url = base::StringPrintf(url, current_locale.c_str()); |
| 923 start_urls.push_back(vox_url); |
| 924 can_show_getstarted_guide = false; |
| 925 } |
| 926 } |
| 927 |
| 928 // Only show getting started guide for a new user. |
| 929 const bool should_show_getstarted_guide = user_manager->IsCurrentUserNew(); |
| 930 |
| 931 if (can_show_getstarted_guide && should_show_getstarted_guide) { |
| 932 // Don't open default Chrome window if we're going to launch the first-run |
| 933 // app. Because we dont' want the first-run app to be hidden in the |
| 934 // background. |
| 935 CommandLine::ForCurrentProcess()->AppendSwitch(::switches::kSilentLaunch); |
| 936 first_run::MaybeLaunchDialogAfterSessionStart(); |
| 937 } else { |
| 938 for (size_t i = 0; i < start_urls.size(); ++i) { |
| 939 CommandLine::ForCurrentProcess()->AppendArg(start_urls[i]); |
| 940 } |
| 941 } |
| 942 } |
| 943 |
| 944 bool UserSessionManager::InitializeUserSession(Profile* profile) { |
| 945 user_manager::UserManager* user_manager = user_manager::UserManager::Get(); |
| 946 |
| 947 // Kiosk apps has their own session initialization pipeline. |
| 948 if (user_manager->IsLoggedInAsKioskApp()) |
| 949 return false; |
| 950 |
| 951 if (start_session_type_ == PRIMARY_USER_SESSION) { |
| 952 UserFlow* user_flow = ChromeUserManager::Get()->GetCurrentUserFlow(); |
| 953 WizardController* oobe_controller = WizardController::default_controller(); |
| 954 base::CommandLine* cmdline = CommandLine::ForCurrentProcess(); |
| 955 bool skip_post_login_screens = |
| 956 user_flow->ShouldSkipPostLoginScreens() || |
| 957 (oobe_controller && oobe_controller->skip_post_login_screens()) || |
| 958 cmdline->HasSwitch(chromeos::switches::kOobeSkipPostLogin); |
| 959 |
| 960 if (user_manager->IsCurrentUserNew() && !skip_post_login_screens) { |
| 961 // Don't specify start URLs if the administrator has configured the start |
| 962 // URLs via policy. |
| 963 if (!SessionStartupPref::TypeIsManaged(profile->GetPrefs())) |
| 964 InitializeStartUrls(); |
| 965 |
| 966 // Mark the device as registered., i.e. the second part of OOBE as |
| 967 // completed. |
| 968 if (!StartupUtils::IsDeviceRegistered()) |
| 969 StartupUtils::MarkDeviceRegistered(base::Closure()); |
| 970 |
| 971 ActivateWizard(WizardController::kTermsOfServiceScreenName); |
| 972 return false; |
| 973 } |
| 974 } |
| 975 |
| 976 LoginUtils::Get()->DoBrowserLaunch(profile, |
| 977 LoginDisplayHostImpl::default_host()); |
| 978 return true; |
863 } | 979 } |
864 | 980 |
865 void UserSessionManager::InitSessionRestoreStrategy() { | 981 void UserSessionManager::InitSessionRestoreStrategy() { |
866 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 982 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
867 bool in_app_mode = chrome::IsRunningInForcedAppMode(); | 983 bool in_app_mode = chrome::IsRunningInForcedAppMode(); |
868 | 984 |
869 // Are we in kiosk app mode? | 985 // Are we in kiosk app mode? |
870 if (in_app_mode) { | 986 if (in_app_mode) { |
871 if (command_line->HasSwitch(::switches::kAppModeOAuth2Token)) { | 987 if (command_line->HasSwitch(::switches::kAppModeOAuth2Token)) { |
872 oauth2_refresh_token_ = command_line->GetSwitchValueASCII( | 988 oauth2_refresh_token_ = command_line->GetSwitchValueASCII( |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
937 // Empty brand code means an organic install (no RLZ pings are sent). | 1053 // Empty brand code means an organic install (no RLZ pings are sent). |
938 google_brand::chromeos::ClearBrandForCurrentSession(); | 1054 google_brand::chromeos::ClearBrandForCurrentSession(); |
939 } | 1055 } |
940 if (disabled != local_state->GetBoolean(prefs::kRLZDisabled)) { | 1056 if (disabled != local_state->GetBoolean(prefs::kRLZDisabled)) { |
941 // When switching to RLZ enabled/disabled state, clear all recorded events. | 1057 // When switching to RLZ enabled/disabled state, clear all recorded events. |
942 RLZTracker::ClearRlzState(); | 1058 RLZTracker::ClearRlzState(); |
943 local_state->SetBoolean(prefs::kRLZDisabled, disabled); | 1059 local_state->SetBoolean(prefs::kRLZDisabled, disabled); |
944 } | 1060 } |
945 // Init the RLZ library. | 1061 // Init the RLZ library. |
946 int ping_delay = profile->GetPrefs()->GetInteger( | 1062 int ping_delay = profile->GetPrefs()->GetInteger( |
947 first_run::GetPingDelayPrefName().c_str()); | 1063 ::first_run::GetPingDelayPrefName().c_str()); |
948 // Negative ping delay means to send ping immediately after a first search is | 1064 // Negative ping delay means to send ping immediately after a first search is |
949 // recorded. | 1065 // recorded. |
950 RLZTracker::InitRlzFromProfileDelayed( | 1066 RLZTracker::InitRlzFromProfileDelayed( |
951 profile, | 1067 profile, |
952 user_manager::UserManager::Get()->IsCurrentUserNew(), | 1068 user_manager::UserManager::Get()->IsCurrentUserNew(), |
953 ping_delay < 0, | 1069 ping_delay < 0, |
954 base::TimeDelta::FromMilliseconds(abs(ping_delay))); | 1070 base::TimeDelta::FromMilliseconds(abs(ping_delay))); |
955 if (delegate_) | 1071 if (delegate_) |
956 delegate_->OnRlzInitialized(); | 1072 delegate_->OnRlzInitialized(); |
957 #endif | 1073 #endif |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1036 } | 1152 } |
1037 } | 1153 } |
1038 DCHECK(!user_already_logged_in); | 1154 DCHECK(!user_already_logged_in); |
1039 | 1155 |
1040 if (!user_already_logged_in) { | 1156 if (!user_already_logged_in) { |
1041 UserContext user_context(user_id); | 1157 UserContext user_context(user_id); |
1042 user_context.SetUserIDHash(user_id_hash); | 1158 user_context.SetUserIDHash(user_id_hash); |
1043 user_context.SetIsUsingOAuth(false); | 1159 user_context.SetIsUsingOAuth(false); |
1044 | 1160 |
1045 // Will call OnProfilePrepared() once profile has been loaded. | 1161 // Will call OnProfilePrepared() once profile has been loaded. |
| 1162 // Only handling secondary users here since primary user profile |
| 1163 // (and session) has been loaded on Chrome startup. |
1046 StartSession(user_context, | 1164 StartSession(user_context, |
| 1165 SECONDARY_USER_SESSION_AFTER_CRASH, |
1047 NULL, // authenticator | 1166 NULL, // authenticator |
1048 false, // has_auth_cookies | 1167 false, // has_auth_cookies |
1049 true, // has_active_session | 1168 true, // has_active_session, this is restart after crash |
1050 this); | 1169 this); |
1051 } else { | 1170 } else { |
1052 RestorePendingUserSessions(); | 1171 RestorePendingUserSessions(); |
1053 } | 1172 } |
1054 } | 1173 } |
1055 | 1174 |
1056 void UserSessionManager::NotifyPendingUserSessionsRestoreFinished() { | 1175 void UserSessionManager::NotifyPendingUserSessionsRestoreFinished() { |
1057 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 1176 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
1058 user_sessions_restored_ = true; | 1177 user_sessions_restored_ = true; |
1059 user_sessions_restore_in_progress_ = false; | 1178 user_sessions_restore_in_progress_ = false; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 } | 1268 } |
1150 | 1269 |
1151 EasyUnlockKeyManager* UserSessionManager::GetEasyUnlockKeyManager() { | 1270 EasyUnlockKeyManager* UserSessionManager::GetEasyUnlockKeyManager() { |
1152 if (!easy_unlock_key_manager_) | 1271 if (!easy_unlock_key_manager_) |
1153 easy_unlock_key_manager_.reset(new EasyUnlockKeyManager); | 1272 easy_unlock_key_manager_.reset(new EasyUnlockKeyManager); |
1154 | 1273 |
1155 return easy_unlock_key_manager_.get(); | 1274 return easy_unlock_key_manager_.get(); |
1156 } | 1275 } |
1157 | 1276 |
1158 } // namespace chromeos | 1277 } // namespace chromeos |
OLD | NEW |