| 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::ShouldInitializeTPMForChromeOSUser(username_hash)) |
| 303 return; | 303 return; |
| 304 } | 304 |
| 305 crypto::WillInitializeTPMForChromeOSUser(username_hash); |
| 305 | 306 |
| 306 if (crypto::IsTPMTokenEnabledForNSS()) { | 307 if (crypto::IsTPMTokenEnabledForNSS()) { |
| 307 if (crypto::IsTPMTokenReady(base::Bind( | 308 if (crypto::IsTPMTokenReady(base::Bind( |
| 308 &StartTPMSlotInitializationOnIOThread, username, username_hash))) { | 309 &StartTPMSlotInitializationOnIOThread, username, username_hash))) { |
| 309 StartTPMSlotInitializationOnIOThread(username, username_hash); | 310 StartTPMSlotInitializationOnIOThread(username, username_hash); |
| 310 } else { | 311 } else { |
| 311 DVLOG(1) << "Waiting for tpm ready ..."; | 312 DVLOG(1) << "Waiting for tpm ready ..."; |
| 312 } | 313 } |
| 313 } else { | 314 } else { |
| 314 crypto::InitializePrivateSoftwareSlotForChromeOSUser(username_hash); | 315 crypto::InitializePrivateSoftwareSlotForChromeOSUser(username_hash); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 SupervisedUserService* supervised_user_service = | 354 SupervisedUserService* supervised_user_service = |
| 354 SupervisedUserServiceFactory::GetForProfile(profile); | 355 SupervisedUserServiceFactory::GetForProfile(profile); |
| 355 params->supervised_user_url_filter = | 356 params->supervised_user_url_filter = |
| 356 supervised_user_service->GetURLFilterForIOThread(); | 357 supervised_user_service->GetURLFilterForIOThread(); |
| 357 #endif | 358 #endif |
| 358 #if defined(OS_CHROMEOS) | 359 #if defined(OS_CHROMEOS) |
| 359 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); | 360 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); |
| 360 if (user_manager) { | 361 if (user_manager) { |
| 361 chromeos::User* user = | 362 chromeos::User* user = |
| 362 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); | 363 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); |
| 363 if (user) { | 364 // No need to initialize NSS for users with empty username hash: |
| 365 // Getters for a user's NSS slots always return NULL slot if the user's |
| 366 // username hash is empty, even when the NSS is not initialized for the |
| 367 // user. |
| 368 if (user && !user->username_hash().empty()) { |
| 364 params->username_hash = user->username_hash(); | 369 params->username_hash = user->username_hash(); |
| 365 bool is_primary_user = (user_manager->GetPrimaryUser() == user); | |
| 366 BrowserThread::PostTask(BrowserThread::IO, | 370 BrowserThread::PostTask(BrowserThread::IO, |
| 367 FROM_HERE, | 371 FROM_HERE, |
| 368 base::Bind(&StartNSSInitOnIOThread, | 372 base::Bind(&StartNSSInitOnIOThread, |
| 369 user->email(), | 373 user->email(), |
| 370 user->username_hash(), | 374 user->username_hash(), |
| 371 profile->GetPath(), | 375 profile->GetPath())); |
| 372 is_primary_user)); | |
| 373 } | 376 } |
| 374 } | 377 } |
| 375 if (params->username_hash.empty()) | 378 if (params->username_hash.empty()) |
| 376 LOG(WARNING) << "no username_hash"; | 379 LOG(WARNING) << "No username_hash; skipped NSS initialization."; |
| 377 #endif | 380 #endif |
| 378 | 381 |
| 379 params->profile = profile; | 382 params->profile = profile; |
| 380 params->prerender_tracker = g_browser_process->prerender_tracker(); | 383 params->prerender_tracker = g_browser_process->prerender_tracker(); |
| 381 profile_params_.reset(params.release()); | 384 profile_params_.reset(params.release()); |
| 382 | 385 |
| 383 ChromeNetworkDelegate::InitializePrefsOnUIThread( | 386 ChromeNetworkDelegate::InitializePrefsOnUIThread( |
| 384 &enable_referrers_, | 387 &enable_referrers_, |
| 385 &enable_do_not_track_, | 388 &enable_do_not_track_, |
| 386 &force_safesearch_, | 389 &force_safesearch_, |
| (...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1248 void ProfileIOData::SetCookieSettingsForTesting( | 1251 void ProfileIOData::SetCookieSettingsForTesting( |
| 1249 CookieSettings* cookie_settings) { | 1252 CookieSettings* cookie_settings) { |
| 1250 DCHECK(!cookie_settings_.get()); | 1253 DCHECK(!cookie_settings_.get()); |
| 1251 cookie_settings_ = cookie_settings; | 1254 cookie_settings_ = cookie_settings; |
| 1252 } | 1255 } |
| 1253 | 1256 |
| 1254 void ProfileIOData::set_signin_names_for_testing( | 1257 void ProfileIOData::set_signin_names_for_testing( |
| 1255 SigninNamesOnIOThread* signin_names) { | 1258 SigninNamesOnIOThread* signin_names) { |
| 1256 signin_names_.reset(signin_names); | 1259 signin_names_.reset(signin_names); |
| 1257 } | 1260 } |
| OLD | NEW |