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 16 matching lines...) Expand all Loading... | |
27 #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h" | 27 #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h" |
28 #include "chrome/browser/chromeos/login/profile_auth_data.h" | 28 #include "chrome/browser/chromeos/login/profile_auth_data.h" |
29 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h" | 29 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter.h" |
30 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter_factory .h" | 30 #include "chrome/browser/chromeos/login/saml/saml_offline_signin_limiter_factory .h" |
31 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" | 31 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager.h" |
32 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" | 32 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" |
33 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" | 33 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" |
34 #include "chrome/browser/chromeos/login/users/user_manager.h" | 34 #include "chrome/browser/chromeos/login/users/user_manager.h" |
35 #include "chrome/browser/chromeos/ownership/owner_settings_service_factory.h" | 35 #include "chrome/browser/chromeos/ownership/owner_settings_service_factory.h" |
36 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 36 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
37 #include "chrome/browser/component_updater/component_updater_service.h" | |
37 #include "chrome/browser/first_run/first_run.h" | 38 #include "chrome/browser/first_run/first_run.h" |
38 #include "chrome/browser/google/google_brand_chromeos.h" | 39 #include "chrome/browser/google/google_brand_chromeos.h" |
39 #include "chrome/browser/lifetime/application_lifetime.h" | 40 #include "chrome/browser/lifetime/application_lifetime.h" |
41 #include "chrome/browser/net/crl_set_fetcher.h" | |
40 #include "chrome/browser/net/nss_context.h" | 42 #include "chrome/browser/net/nss_context.h" |
41 #include "chrome/browser/profiles/profile.h" | 43 #include "chrome/browser/profiles/profile.h" |
42 #include "chrome/browser/profiles/profile_manager.h" | 44 #include "chrome/browser/profiles/profile_manager.h" |
43 #include "chrome/browser/rlz/rlz.h" | 45 #include "chrome/browser/rlz/rlz.h" |
44 #include "chrome/browser/signin/signin_manager_factory.h" | 46 #include "chrome/browser/signin/signin_manager_factory.h" |
45 #include "chrome/common/chrome_switches.h" | 47 #include "chrome/common/chrome_switches.h" |
46 #include "chrome/common/logging_chrome.h" | 48 #include "chrome/common/logging_chrome.h" |
47 #include "chrome/common/pref_names.h" | 49 #include "chrome/common/pref_names.h" |
48 #include "chromeos/cert_loader.h" | 50 #include "chromeos/cert_loader.h" |
49 #include "chromeos/chromeos_switches.h" | 51 #include "chromeos/chromeos_switches.h" |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 return; | 279 return; |
278 } | 280 } |
279 base::PostTaskAndReplyWithResult( | 281 base::PostTaskAndReplyWithResult( |
280 base::WorkerPool::GetTaskRunner(false), | 282 base::WorkerPool::GetTaskRunner(false), |
281 FROM_HERE, | 283 FROM_HERE, |
282 base::Bind(&base::PathExists, GetRlzDisabledFlagPath()), | 284 base::Bind(&base::PathExists, GetRlzDisabledFlagPath()), |
283 base::Bind(&UserSessionManager::InitRlzImpl, AsWeakPtr(), profile)); | 285 base::Bind(&UserSessionManager::InitRlzImpl, AsWeakPtr(), profile)); |
284 #endif | 286 #endif |
285 } | 287 } |
286 | 288 |
287 bool UserSessionManager::HasBrowserRestarted() const { | |
288 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
289 return base::SysInfo::IsRunningOnChromeOS() && | |
290 command_line->HasSwitch(switches::kLoginUser); | |
291 } | |
292 | |
293 OAuth2LoginManager::SessionRestoreStrategy | 289 OAuth2LoginManager::SessionRestoreStrategy |
294 UserSessionManager::GetSigninSessionRestoreStrategy() { | 290 UserSessionManager::GetSigninSessionRestoreStrategy() { |
295 return session_restore_strategy_; | 291 return session_restore_strategy_; |
296 } | 292 } |
297 | 293 |
298 // static | 294 // static |
299 void UserSessionManager::SetFirstLoginPrefs(PrefService* prefs) { | 295 void UserSessionManager::SetFirstLoginPrefs(PrefService* prefs) { |
300 VLOG(1) << "Setting first login prefs"; | 296 VLOG(1) << "Setting first login prefs"; |
301 InitLocaleAndInputMethodsForNewUser(prefs); | 297 InitLocaleAndInputMethodsForNewUser(prefs); |
302 } | 298 } |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
703 content::Details<Profile>(profile)); | 699 content::Details<Profile>(profile)); |
704 | 700 |
705 InitializeCertsForPrimaryUser(profile); | 701 InitializeCertsForPrimaryUser(profile); |
706 | 702 |
707 // Initialize RLZ only for primary user. | 703 // Initialize RLZ only for primary user. |
708 const user_manager::User* user = | 704 const user_manager::User* user = |
709 ProfileHelper::Get()->GetUserByProfile(profile); | 705 ProfileHelper::Get()->GetUserByProfile(profile); |
710 if (user_manager->GetPrimaryUser() == user) | 706 if (user_manager->GetPrimaryUser() == user) |
711 InitRlz(profile); | 707 InitRlz(profile); |
712 | 708 |
713 // TODO(altimofeev): This pointer should probably never be NULL, but it looks | 709 InitializeCRLSetFetcherForPrimaryUser(user); |
Dmitry Polukhin
2014/07/28 09:32:38
Optional. I would make it InitializeCRLSetFetcher
Nikita (slow)
2014/07/29 09:27:27
Done.
| |
710 | |
711 // TODO(nkostylev): This pointer should probably never be NULL, but it looks | |
714 // like LoginUtilsImpl::OnProfileCreated() may be getting called before | 712 // like LoginUtilsImpl::OnProfileCreated() may be getting called before |
715 // UserSessionManager::PrepareProfile() has set |delegate_| when Chrome is | 713 // UserSessionManager::PrepareProfile() has set |delegate_| when Chrome is |
716 // killed during shutdown in tests -- see http://crosbug.com/18269. Replace | 714 // killed during shutdown in tests -- see http://crosbug.com/18269. Replace |
717 // this 'if' statement with a CHECK(delegate_) once the underlying issue is | 715 // this 'if' statement with a CHECK(delegate_) once the underlying issue is |
718 // resolved. | 716 // resolved. |
719 if (delegate_) | 717 if (delegate_) |
720 delegate_->OnProfilePrepared(profile); | 718 delegate_->OnProfilePrepared(profile); |
721 } | 719 } |
722 | 720 |
723 void UserSessionManager::InitSessionRestoreStrategy() { | 721 void UserSessionManager::InitSessionRestoreStrategy() { |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
820 if (user_manager->IsUserLoggedIn() && | 818 if (user_manager->IsUserLoggedIn() && |
821 primary_user && | 819 primary_user && |
822 profile == ProfileHelper::Get()->GetProfileByUser(primary_user) && | 820 profile == ProfileHelper::Get()->GetProfileByUser(primary_user) && |
823 CertLoader::IsInitialized() && | 821 CertLoader::IsInitialized() && |
824 base::SysInfo::IsRunningOnChromeOS()) { | 822 base::SysInfo::IsRunningOnChromeOS()) { |
825 GetNSSCertDatabaseForProfile(profile, | 823 GetNSSCertDatabaseForProfile(profile, |
826 base::Bind(&OnGetNSSCertDatabaseForUser)); | 824 base::Bind(&OnGetNSSCertDatabaseForUser)); |
827 } | 825 } |
828 } | 826 } |
829 | 827 |
828 void UserSessionManager::InitializeCRLSetFetcherForPrimaryUser( | |
829 const user_manager::User* user) { | |
830 const user_manager::User* primary_user = UserManager::Get()->GetPrimaryUser(); | |
831 if (primary_user != user) | |
832 return; | |
833 | |
834 const std::string username_hash = user->username_hash(); | |
835 if (!username_hash.empty()) { | |
836 base::FilePath path; | |
837 path = ProfileHelper::GetProfilePathByUserIdHash(username_hash); | |
838 component_updater::ComponentUpdateService* cus = | |
839 g_browser_process->component_updater(); | |
840 CRLSetFetcher* crl_set = g_browser_process->crl_set_fetcher(); | |
841 if (crl_set && cus) | |
842 crl_set->StartInitialLoad(cus, path); | |
843 } | |
844 } | |
845 | |
830 void UserSessionManager::OnRestoreActiveSessions( | 846 void UserSessionManager::OnRestoreActiveSessions( |
831 const SessionManagerClient::ActiveSessionsMap& sessions, | 847 const SessionManagerClient::ActiveSessionsMap& sessions, |
832 bool success) { | 848 bool success) { |
833 if (!success) { | 849 if (!success) { |
834 LOG(ERROR) << "Could not get list of active user sessions after crash."; | 850 LOG(ERROR) << "Could not get list of active user sessions after crash."; |
835 // If we could not get list of active user sessions it is safer to just | 851 // If we could not get list of active user sessions it is safer to just |
836 // sign out so that we don't get in the inconsistent state. | 852 // sign out so that we don't get in the inconsistent state. |
837 DBusThreadManager::Get()->GetSessionManagerClient()->StopSession(); | 853 DBusThreadManager::Get()->GetSessionManagerClient()->StopSession(); |
838 return; | 854 return; |
839 } | 855 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
901 | 917 |
902 void UserSessionManager::NotifyPendingUserSessionsRestoreFinished() { | 918 void UserSessionManager::NotifyPendingUserSessionsRestoreFinished() { |
903 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 919 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
904 user_sessions_restored_ = true; | 920 user_sessions_restored_ = true; |
905 FOR_EACH_OBSERVER(UserSessionStateObserver, | 921 FOR_EACH_OBSERVER(UserSessionStateObserver, |
906 session_state_observer_list_, | 922 session_state_observer_list_, |
907 PendingUserSessionsRestoreFinished()); | 923 PendingUserSessionsRestoreFinished()); |
908 } | 924 } |
909 | 925 |
910 } // namespace chromeos | 926 } // namespace chromeos |
OLD | NEW |