| 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 23 matching lines...) Expand all Loading... |
| 34 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" | 34 #include "chrome/browser/chromeos/login/signin/oauth2_login_manager_factory.h" |
| 35 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" | 35 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" |
| 36 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" | 36 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" |
| 37 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 37 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 38 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 38 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 39 #include "chrome/browser/chromeos/settings/cros_settings.h" | 39 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 40 #include "chrome/browser/first_run/first_run.h" | 40 #include "chrome/browser/first_run/first_run.h" |
| 41 #include "chrome/browser/google/google_brand_chromeos.h" | 41 #include "chrome/browser/google/google_brand_chromeos.h" |
| 42 #include "chrome/browser/lifetime/application_lifetime.h" | 42 #include "chrome/browser/lifetime/application_lifetime.h" |
| 43 #include "chrome/browser/net/crl_set_fetcher.h" | 43 #include "chrome/browser/net/crl_set_fetcher.h" |
| 44 #include "chrome/browser/net/nss_context.h" | |
| 45 #include "chrome/browser/profiles/profile.h" | 44 #include "chrome/browser/profiles/profile.h" |
| 46 #include "chrome/browser/profiles/profile_manager.h" | 45 #include "chrome/browser/profiles/profile_manager.h" |
| 47 #include "chrome/browser/rlz/rlz.h" | 46 #include "chrome/browser/rlz/rlz.h" |
| 48 #include "chrome/browser/signin/easy_unlock_service.h" | 47 #include "chrome/browser/signin/easy_unlock_service.h" |
| 49 #include "chrome/browser/signin/signin_manager_factory.h" | 48 #include "chrome/browser/signin/signin_manager_factory.h" |
| 50 #include "chrome/common/chrome_switches.h" | 49 #include "chrome/common/chrome_switches.h" |
| 51 #include "chrome/common/logging_chrome.h" | 50 #include "chrome/common/logging_chrome.h" |
| 52 #include "chrome/common/pref_names.h" | 51 #include "chrome/common/pref_names.h" |
| 53 #include "chromeos/cert_loader.h" | |
| 54 #include "chromeos/chromeos_switches.h" | 52 #include "chromeos/chromeos_switches.h" |
| 55 #include "chromeos/cryptohome/cryptohome_util.h" | 53 #include "chromeos/cryptohome/cryptohome_util.h" |
| 56 #include "chromeos/dbus/cryptohome_client.h" | 54 #include "chromeos/dbus/cryptohome_client.h" |
| 57 #include "chromeos/dbus/dbus_thread_manager.h" | 55 #include "chromeos/dbus/dbus_thread_manager.h" |
| 58 #include "chromeos/dbus/session_manager_client.h" | 56 #include "chromeos/dbus/session_manager_client.h" |
| 59 #include "chromeos/ime/input_method_manager.h" | 57 #include "chromeos/ime/input_method_manager.h" |
| 60 #include "chromeos/network/portal_detector/network_portal_detector.h" | 58 #include "chromeos/network/portal_detector/network_portal_detector.h" |
| 61 #include "chromeos/network/portal_detector/network_portal_detector_strategy.h" | 59 #include "chromeos/network/portal_detector/network_portal_detector_strategy.h" |
| 62 #include "chromeos/settings/cros_settings_names.h" | 60 #include "chromeos/settings/cros_settings_names.h" |
| 63 #include "components/component_updater/component_updater_service.h" | 61 #include "components/component_updater/component_updater_service.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 const base::FilePath::CharType kRLZDisabledFlagName[] = | 151 const base::FilePath::CharType kRLZDisabledFlagName[] = |
| 154 FILE_PATH_LITERAL(".rlz_disabled"); | 152 FILE_PATH_LITERAL(".rlz_disabled"); |
| 155 | 153 |
| 156 base::FilePath GetRlzDisabledFlagPath() { | 154 base::FilePath GetRlzDisabledFlagPath() { |
| 157 base::FilePath homedir; | 155 base::FilePath homedir; |
| 158 PathService::Get(base::DIR_HOME, &homedir); | 156 PathService::Get(base::DIR_HOME, &homedir); |
| 159 return homedir.Append(kRLZDisabledFlagName); | 157 return homedir.Append(kRLZDisabledFlagName); |
| 160 } | 158 } |
| 161 #endif | 159 #endif |
| 162 | 160 |
| 163 // Callback to GetNSSCertDatabaseForProfile. It starts CertLoader using the | |
| 164 // provided NSS database. It must be called for primary user only. | |
| 165 void OnGetNSSCertDatabaseForUser(net::NSSCertDatabase* database) { | |
| 166 if (!CertLoader::IsInitialized()) | |
| 167 return; | |
| 168 | |
| 169 CertLoader::Get()->StartWithNSSDB(database); | |
| 170 } | |
| 171 | |
| 172 } // namespace | 161 } // namespace |
| 173 | 162 |
| 174 #if defined(ENABLE_RLZ) | 163 #if defined(ENABLE_RLZ) |
| 175 void UserSessionManagerDelegate::OnRlzInitialized() { | 164 void UserSessionManagerDelegate::OnRlzInitialized() { |
| 176 } | 165 } |
| 177 #endif | 166 #endif |
| 178 | 167 |
| 179 UserSessionManagerDelegate::~UserSessionManagerDelegate() { | 168 UserSessionManagerDelegate::~UserSessionManagerDelegate() { |
| 180 } | 169 } |
| 181 | 170 |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 content::NotificationService::current()->Notify( | 791 content::NotificationService::current()->Notify( |
| 803 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, | 792 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, |
| 804 content::NotificationService::AllSources(), | 793 content::NotificationService::AllSources(), |
| 805 content::Details<Profile>(profile)); | 794 content::Details<Profile>(profile)); |
| 806 | 795 |
| 807 // Initialize various services only for primary user. | 796 // Initialize various services only for primary user. |
| 808 const user_manager::User* user = | 797 const user_manager::User* user = |
| 809 ProfileHelper::Get()->GetUserByProfile(profile); | 798 ProfileHelper::Get()->GetUserByProfile(profile); |
| 810 if (user_manager->GetPrimaryUser() == user) { | 799 if (user_manager->GetPrimaryUser() == user) { |
| 811 InitRlz(profile); | 800 InitRlz(profile); |
| 812 InitializeCerts(profile); | |
| 813 InitializeCRLSetFetcher(user); | 801 InitializeCRLSetFetcher(user); |
| 814 } | 802 } |
| 815 | 803 |
| 816 UpdateEasyUnlockKeys(user_context_); | 804 UpdateEasyUnlockKeys(user_context_); |
| 817 user_context_.ClearSecrets(); | 805 user_context_.ClearSecrets(); |
| 818 | 806 |
| 819 // TODO(nkostylev): This pointer should probably never be NULL, but it looks | 807 // TODO(nkostylev): This pointer should probably never be NULL, but it looks |
| 820 // like LoginUtilsImpl::OnProfileCreated() may be getting called before | 808 // like LoginUtilsImpl::OnProfileCreated() may be getting called before |
| 821 // UserSessionManager::PrepareProfile() has set |delegate_| when Chrome is | 809 // UserSessionManager::PrepareProfile() has set |delegate_| when Chrome is |
| 822 // killed during shutdown in tests -- see http://crosbug.com/18269. Replace | 810 // killed during shutdown in tests -- see http://crosbug.com/18269. Replace |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 913 RLZTracker::InitRlzFromProfileDelayed( | 901 RLZTracker::InitRlzFromProfileDelayed( |
| 914 profile, | 902 profile, |
| 915 user_manager::UserManager::Get()->IsCurrentUserNew(), | 903 user_manager::UserManager::Get()->IsCurrentUserNew(), |
| 916 ping_delay < 0, | 904 ping_delay < 0, |
| 917 base::TimeDelta::FromMilliseconds(abs(ping_delay))); | 905 base::TimeDelta::FromMilliseconds(abs(ping_delay))); |
| 918 if (delegate_) | 906 if (delegate_) |
| 919 delegate_->OnRlzInitialized(); | 907 delegate_->OnRlzInitialized(); |
| 920 #endif | 908 #endif |
| 921 } | 909 } |
| 922 | 910 |
| 923 void UserSessionManager::InitializeCerts(Profile* profile) { | |
| 924 // Now that the user profile has been initialized | |
| 925 // |GetNSSCertDatabaseForProfile| is safe to be used. | |
| 926 if (CertLoader::IsInitialized() && base::SysInfo::IsRunningOnChromeOS()) { | |
| 927 GetNSSCertDatabaseForProfile(profile, | |
| 928 base::Bind(&OnGetNSSCertDatabaseForUser)); | |
| 929 } | |
| 930 } | |
| 931 | |
| 932 void UserSessionManager::InitializeCRLSetFetcher( | 911 void UserSessionManager::InitializeCRLSetFetcher( |
| 933 const user_manager::User* user) { | 912 const user_manager::User* user) { |
| 934 const std::string username_hash = user->username_hash(); | 913 const std::string username_hash = user->username_hash(); |
| 935 if (!username_hash.empty()) { | 914 if (!username_hash.empty()) { |
| 936 base::FilePath path; | 915 base::FilePath path; |
| 937 path = ProfileHelper::GetProfilePathByUserIdHash(username_hash); | 916 path = ProfileHelper::GetProfilePathByUserIdHash(username_hash); |
| 938 component_updater::ComponentUpdateService* cus = | 917 component_updater::ComponentUpdateService* cus = |
| 939 g_browser_process->component_updater(); | 918 g_browser_process->component_updater(); |
| 940 CRLSetFetcher* crl_set = g_browser_process->crl_set_fetcher(); | 919 CRLSetFetcher* crl_set = g_browser_process->crl_set_fetcher(); |
| 941 if (crl_set && cus) | 920 if (crl_set && cus) |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1119 return NULL; | 1098 return NULL; |
| 1120 } | 1099 } |
| 1121 | 1100 |
| 1122 if (!easy_unlock_key_manager_) | 1101 if (!easy_unlock_key_manager_) |
| 1123 easy_unlock_key_manager_.reset(new EasyUnlockKeyManager); | 1102 easy_unlock_key_manager_.reset(new EasyUnlockKeyManager); |
| 1124 | 1103 |
| 1125 return easy_unlock_key_manager_.get(); | 1104 return easy_unlock_key_manager_.get(); |
| 1126 } | 1105 } |
| 1127 | 1106 |
| 1128 } // namespace chromeos | 1107 } // namespace chromeos |
| OLD | NEW |