Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(418)

Side by Side Diff: chrome/browser/chromeos/login/session/user_session_manager.cc

Issue 419013003: Replace c/b/nss_context by a KeyedService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase, format. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 26 matching lines...) Expand all
37 #include "chrome/browser/chromeos/login/startup_utils.h" 37 #include "chrome/browser/chromeos/login/startup_utils.h"
38 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" 38 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
39 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h" 39 #include "chrome/browser/chromeos/login/users/supervised_user_manager.h"
40 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" 40 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
41 #include "chrome/browser/chromeos/profiles/profile_helper.h" 41 #include "chrome/browser/chromeos/profiles/profile_helper.h"
42 #include "chrome/browser/chromeos/settings/cros_settings.h" 42 #include "chrome/browser/chromeos/settings/cros_settings.h"
43 #include "chrome/browser/first_run/first_run.h" 43 #include "chrome/browser/first_run/first_run.h"
44 #include "chrome/browser/google/google_brand_chromeos.h" 44 #include "chrome/browser/google/google_brand_chromeos.h"
45 #include "chrome/browser/lifetime/application_lifetime.h" 45 #include "chrome/browser/lifetime/application_lifetime.h"
46 #include "chrome/browser/net/crl_set_fetcher.h" 46 #include "chrome/browser/net/crl_set_fetcher.h"
47 #include "chrome/browser/net/nss_context.h"
48 #include "chrome/browser/profiles/profile.h" 47 #include "chrome/browser/profiles/profile.h"
49 #include "chrome/browser/profiles/profile_manager.h" 48 #include "chrome/browser/profiles/profile_manager.h"
50 #include "chrome/browser/rlz/rlz.h" 49 #include "chrome/browser/rlz/rlz.h"
51 #include "chrome/browser/signin/easy_unlock_service.h" 50 #include "chrome/browser/signin/easy_unlock_service.h"
52 #include "chrome/browser/signin/signin_manager_factory.h" 51 #include "chrome/browser/signin/signin_manager_factory.h"
53 #include "chrome/common/chrome_switches.h" 52 #include "chrome/common/chrome_switches.h"
54 #include "chrome/common/logging_chrome.h" 53 #include "chrome/common/logging_chrome.h"
55 #include "chrome/common/pref_names.h" 54 #include "chrome/common/pref_names.h"
56 #include "chromeos/cert_loader.h"
57 #include "chromeos/chromeos_switches.h" 55 #include "chromeos/chromeos_switches.h"
58 #include "chromeos/cryptohome/cryptohome_util.h" 56 #include "chromeos/cryptohome/cryptohome_util.h"
59 #include "chromeos/dbus/cryptohome_client.h" 57 #include "chromeos/dbus/cryptohome_client.h"
60 #include "chromeos/dbus/dbus_thread_manager.h" 58 #include "chromeos/dbus/dbus_thread_manager.h"
61 #include "chromeos/dbus/session_manager_client.h" 59 #include "chromeos/dbus/session_manager_client.h"
62 #include "chromeos/ime/input_method_manager.h" 60 #include "chromeos/ime/input_method_manager.h"
63 #include "chromeos/login/user_names.h" 61 #include "chromeos/login/user_names.h"
64 #include "chromeos/network/portal_detector/network_portal_detector.h" 62 #include "chromeos/network/portal_detector/network_portal_detector.h"
65 #include "chromeos/network/portal_detector/network_portal_detector_strategy.h" 63 #include "chromeos/network/portal_detector/network_portal_detector_strategy.h"
66 #include "chromeos/settings/cros_settings_names.h" 64 #include "chromeos/settings/cros_settings_names.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 const base::FilePath::CharType kRLZDisabledFlagName[] = 156 const base::FilePath::CharType kRLZDisabledFlagName[] =
159 FILE_PATH_LITERAL(".rlz_disabled"); 157 FILE_PATH_LITERAL(".rlz_disabled");
160 158
161 base::FilePath GetRlzDisabledFlagPath() { 159 base::FilePath GetRlzDisabledFlagPath() {
162 base::FilePath homedir; 160 base::FilePath homedir;
163 PathService::Get(base::DIR_HOME, &homedir); 161 PathService::Get(base::DIR_HOME, &homedir);
164 return homedir.Append(kRLZDisabledFlagName); 162 return homedir.Append(kRLZDisabledFlagName);
165 } 163 }
166 #endif 164 #endif
167 165
168 // Callback to GetNSSCertDatabaseForProfile. It starts CertLoader using the
169 // provided NSS database. It must be called for primary user only.
170 void OnGetNSSCertDatabaseForUser(net::NSSCertDatabase* database) {
171 if (!CertLoader::IsInitialized())
172 return;
173
174 CertLoader::Get()->StartWithNSSDB(database);
175 }
176
177 } // namespace 166 } // namespace
178 167
179 #if defined(ENABLE_RLZ) 168 #if defined(ENABLE_RLZ)
180 void UserSessionManagerDelegate::OnRlzInitialized() { 169 void UserSessionManagerDelegate::OnRlzInitialized() {
181 } 170 }
182 #endif 171 #endif
183 172
184 UserSessionManagerDelegate::~UserSessionManagerDelegate() { 173 UserSessionManagerDelegate::~UserSessionManagerDelegate() {
185 } 174 }
186 175
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 content::NotificationService::current()->Notify( 827 content::NotificationService::current()->Notify(
839 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED, 828 chrome::NOTIFICATION_LOGIN_USER_PROFILE_PREPARED,
840 content::NotificationService::AllSources(), 829 content::NotificationService::AllSources(),
841 content::Details<Profile>(profile)); 830 content::Details<Profile>(profile));
842 831
843 // Initialize various services only for primary user. 832 // Initialize various services only for primary user.
844 const user_manager::User* user = 833 const user_manager::User* user =
845 ProfileHelper::Get()->GetUserByProfile(profile); 834 ProfileHelper::Get()->GetUserByProfile(profile);
846 if (user_manager->GetPrimaryUser() == user) { 835 if (user_manager->GetPrimaryUser() == user) {
847 InitRlz(profile); 836 InitRlz(profile);
848 InitializeCerts(profile);
849 InitializeCRLSetFetcher(user); 837 InitializeCRLSetFetcher(user);
850 } 838 }
851 839
852 UpdateEasyUnlockKeys(user_context_); 840 UpdateEasyUnlockKeys(user_context_);
853 user_context_.ClearSecrets(); 841 user_context_.ClearSecrets();
854 842
855 // TODO(nkostylev): This pointer should probably never be NULL, but it looks 843 // TODO(nkostylev): This pointer should probably never be NULL, but it looks
856 // like LoginUtilsImpl::OnProfileCreated() may be getting called before 844 // like LoginUtilsImpl::OnProfileCreated() may be getting called before
857 // UserSessionManager::PrepareProfile() has set |delegate_| when Chrome is 845 // UserSessionManager::PrepareProfile() has set |delegate_| when Chrome is
858 // killed during shutdown in tests -- see http://crosbug.com/18269. Replace 846 // killed during shutdown in tests -- see http://crosbug.com/18269. Replace
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
949 RLZTracker::InitRlzFromProfileDelayed( 937 RLZTracker::InitRlzFromProfileDelayed(
950 profile, 938 profile,
951 user_manager::UserManager::Get()->IsCurrentUserNew(), 939 user_manager::UserManager::Get()->IsCurrentUserNew(),
952 ping_delay < 0, 940 ping_delay < 0,
953 base::TimeDelta::FromMilliseconds(abs(ping_delay))); 941 base::TimeDelta::FromMilliseconds(abs(ping_delay)));
954 if (delegate_) 942 if (delegate_)
955 delegate_->OnRlzInitialized(); 943 delegate_->OnRlzInitialized();
956 #endif 944 #endif
957 } 945 }
958 946
959 void UserSessionManager::InitializeCerts(Profile* profile) {
960 // Now that the user profile has been initialized
961 // |GetNSSCertDatabaseForProfile| is safe to be used.
962 if (CertLoader::IsInitialized() && base::SysInfo::IsRunningOnChromeOS()) {
963 GetNSSCertDatabaseForProfile(profile,
964 base::Bind(&OnGetNSSCertDatabaseForUser));
965 }
966 }
967
968 void UserSessionManager::InitializeCRLSetFetcher( 947 void UserSessionManager::InitializeCRLSetFetcher(
969 const user_manager::User* user) { 948 const user_manager::User* user) {
970 const std::string username_hash = user->username_hash(); 949 const std::string username_hash = user->username_hash();
971 if (!username_hash.empty()) { 950 if (!username_hash.empty()) {
972 base::FilePath path; 951 base::FilePath path;
973 path = ProfileHelper::GetProfilePathByUserIdHash(username_hash); 952 path = ProfileHelper::GetProfilePathByUserIdHash(username_hash);
974 component_updater::ComponentUpdateService* cus = 953 component_updater::ComponentUpdateService* cus =
975 g_browser_process->component_updater(); 954 g_browser_process->component_updater();
976 CRLSetFetcher* crl_set = g_browser_process->crl_set_fetcher(); 955 CRLSetFetcher* crl_set = g_browser_process->crl_set_fetcher();
977 if (crl_set && cus) 956 if (crl_set && cus)
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 } 1127 }
1149 1128
1150 EasyUnlockKeyManager* UserSessionManager::GetEasyUnlockKeyManager() { 1129 EasyUnlockKeyManager* UserSessionManager::GetEasyUnlockKeyManager() {
1151 if (!easy_unlock_key_manager_) 1130 if (!easy_unlock_key_manager_)
1152 easy_unlock_key_manager_.reset(new EasyUnlockKeyManager); 1131 easy_unlock_key_manager_.reset(new EasyUnlockKeyManager);
1153 1132
1154 return easy_unlock_key_manager_.get(); 1133 return easy_unlock_key_manager_.get();
1155 } 1134 }
1156 1135
1157 } // namespace chromeos 1136 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698