OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/profiles/profile_io_data.h" | 5 #include "chrome/browser/profiles/profile_io_data.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 281 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
282 | 282 |
283 BrowserThread::PostTask( | 283 BrowserThread::PostTask( |
284 BrowserThread::UI, | 284 BrowserThread::UI, |
285 FROM_HERE, | 285 FROM_HERE, |
286 base::Bind(&GetTPMInfoForUserOnUIThread, username, username_hash)); | 286 base::Bind(&GetTPMInfoForUserOnUIThread, username, username_hash)); |
287 } | 287 } |
288 | 288 |
289 void StartNSSInitOnIOThread(const std::string& username, | 289 void StartNSSInitOnIOThread(const std::string& username, |
290 const std::string& username_hash, | 290 const std::string& username_hash, |
291 const base::FilePath& path, | 291 const base::FilePath& path) { |
292 bool is_primary_user) { | |
293 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 292 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
294 DVLOG(1) << "Starting NSS init for " << username | 293 DVLOG(1) << "Starting NSS init for " << username |
295 << " hash:" << username_hash | 294 << " hash:" << username_hash; |
296 << " is_primary_user:" << is_primary_user; | |
297 | 295 |
298 if (!crypto::InitializeNSSForChromeOSUser( | 296 // Make sure NSS is initialized for the user. |
299 username, username_hash, is_primary_user, path)) { | 297 crypto::InitializeNSSForChromeOSUser(username, username_hash, path); |
300 // If the user already exists in nss_util's map, it is already initialized | 298 |
301 // or in the process of being initialized. In either case, there's no need | 299 // Check if it's OK to initialize TPM for the user before continuing. This |
302 // to do anything. | 300 // may not be the case if the TPM slot initialization was previously |
| 301 // requested for the same user. |
| 302 if (!crypto::GetAndSetStartedInitializeTPMForChromeOSUser(username_hash)) |
303 return; | 303 return; |
304 } | |
305 | 304 |
306 if (crypto::IsTPMTokenEnabledForNSS()) { | 305 if (crypto::IsTPMTokenEnabledForNSS()) { |
307 if (crypto::IsTPMTokenReady(base::Bind( | 306 if (crypto::IsTPMTokenReady(base::Bind( |
308 &StartTPMSlotInitializationOnIOThread, username, username_hash))) { | 307 &StartTPMSlotInitializationOnIOThread, username, username_hash))) { |
309 StartTPMSlotInitializationOnIOThread(username, username_hash); | 308 StartTPMSlotInitializationOnIOThread(username, username_hash); |
310 } else { | 309 } else { |
311 DVLOG(1) << "Waiting for tpm ready ..."; | 310 DVLOG(1) << "Waiting for tpm ready ..."; |
312 } | 311 } |
313 } else { | 312 } else { |
314 crypto::InitializePrivateSoftwareSlotForChromeOSUser(username_hash); | 313 crypto::InitializePrivateSoftwareSlotForChromeOSUser(username_hash); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 SupervisedUserService* supervised_user_service = | 352 SupervisedUserService* supervised_user_service = |
354 SupervisedUserServiceFactory::GetForProfile(profile); | 353 SupervisedUserServiceFactory::GetForProfile(profile); |
355 params->supervised_user_url_filter = | 354 params->supervised_user_url_filter = |
356 supervised_user_service->GetURLFilterForIOThread(); | 355 supervised_user_service->GetURLFilterForIOThread(); |
357 #endif | 356 #endif |
358 #if defined(OS_CHROMEOS) | 357 #if defined(OS_CHROMEOS) |
359 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); | 358 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); |
360 if (user_manager) { | 359 if (user_manager) { |
361 chromeos::User* user = | 360 chromeos::User* user = |
362 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); | 361 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); |
363 if (user) { | 362 // No need to initialize NSS for users with empty username hash: |
| 363 // Getters for a user's NSS slots always return NULL slot if the user's |
| 364 // username hash is empty, even when the NSS is not initialized for the |
| 365 // user. |
| 366 if (user && !user->username_hash().empty()) { |
364 params->username_hash = user->username_hash(); | 367 params->username_hash = user->username_hash(); |
365 bool is_primary_user = (user_manager->GetPrimaryUser() == user); | |
366 BrowserThread::PostTask(BrowserThread::IO, | 368 BrowserThread::PostTask(BrowserThread::IO, |
367 FROM_HERE, | 369 FROM_HERE, |
368 base::Bind(&StartNSSInitOnIOThread, | 370 base::Bind(&StartNSSInitOnIOThread, |
369 user->email(), | 371 user->email(), |
370 user->username_hash(), | 372 user->username_hash(), |
371 profile->GetPath(), | 373 profile->GetPath())); |
372 is_primary_user)); | |
373 } | 374 } |
374 } | 375 } |
375 if (params->username_hash.empty()) | 376 if (params->username_hash.empty()) |
376 LOG(WARNING) << "no username_hash"; | 377 LOG(WARNING) << "No username_hash; skipped NSS initialization."; |
377 #endif | 378 #endif |
378 | 379 |
379 params->profile = profile; | 380 params->profile = profile; |
380 params->prerender_tracker = g_browser_process->prerender_tracker(); | 381 params->prerender_tracker = g_browser_process->prerender_tracker(); |
381 profile_params_.reset(params.release()); | 382 profile_params_.reset(params.release()); |
382 | 383 |
383 ChromeNetworkDelegate::InitializePrefsOnUIThread( | 384 ChromeNetworkDelegate::InitializePrefsOnUIThread( |
384 &enable_referrers_, | 385 &enable_referrers_, |
385 &enable_do_not_track_, | 386 &enable_do_not_track_, |
386 &force_safesearch_, | 387 &force_safesearch_, |
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 void ProfileIOData::SetCookieSettingsForTesting( | 1247 void ProfileIOData::SetCookieSettingsForTesting( |
1247 CookieSettings* cookie_settings) { | 1248 CookieSettings* cookie_settings) { |
1248 DCHECK(!cookie_settings_.get()); | 1249 DCHECK(!cookie_settings_.get()); |
1249 cookie_settings_ = cookie_settings; | 1250 cookie_settings_ = cookie_settings; |
1250 } | 1251 } |
1251 | 1252 |
1252 void ProfileIOData::set_signin_names_for_testing( | 1253 void ProfileIOData::set_signin_names_for_testing( |
1253 SigninNamesOnIOThread* signin_names) { | 1254 SigninNamesOnIOThread* signin_names) { |
1254 signin_names_.reset(signin_names); | 1255 signin_names_.reset(signin_names); |
1255 } | 1256 } |
OLD | NEW |