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 <stddef.h> | 7 #include <stddef.h> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 BrowserThread::PostTask( | 288 BrowserThread::PostTask( |
289 BrowserThread::IO, | 289 BrowserThread::IO, |
290 FROM_HERE, | 290 FROM_HERE, |
291 base::Bind(&crypto::InitializeTPMForChromeOSUser, | 291 base::Bind(&crypto::InitializeTPMForChromeOSUser, |
292 username_hash, info.token_slot_id)); | 292 username_hash, info.token_slot_id)); |
293 } else { | 293 } else { |
294 NOTREACHED() << "TPMTokenInfoGetter reported invalid token."; | 294 NOTREACHED() << "TPMTokenInfoGetter reported invalid token."; |
295 } | 295 } |
296 } | 296 } |
297 | 297 |
298 void GetTPMInfoForUserOnUIThread(const std::string& username, | 298 void GetTPMInfoForUserOnUIThread(const AccountId& account_id, |
299 const std::string& username_hash) { | 299 const std::string& username_hash) { |
300 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 300 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
301 DVLOG(1) << "Getting TPM info from cryptohome for " | 301 DVLOG(1) << "Getting TPM info from cryptohome for " |
302 << " " << username << " " << username_hash; | 302 << " " << account_id.Serialize() << " " << username_hash; |
303 scoped_ptr<chromeos::TPMTokenInfoGetter> scoped_token_info_getter = | 303 scoped_ptr<chromeos::TPMTokenInfoGetter> scoped_token_info_getter = |
304 chromeos::TPMTokenInfoGetter::CreateForUserToken( | 304 chromeos::TPMTokenInfoGetter::CreateForUserToken( |
305 username, | 305 account_id, chromeos::DBusThreadManager::Get()->GetCryptohomeClient(), |
306 chromeos::DBusThreadManager::Get()->GetCryptohomeClient(), | |
307 base::ThreadTaskRunnerHandle::Get()); | 306 base::ThreadTaskRunnerHandle::Get()); |
308 chromeos::TPMTokenInfoGetter* token_info_getter = | 307 chromeos::TPMTokenInfoGetter* token_info_getter = |
309 scoped_token_info_getter.get(); | 308 scoped_token_info_getter.get(); |
310 | 309 |
311 // Bind |token_info_getter| to the callback to ensure it does not go away | 310 // Bind |token_info_getter| to the callback to ensure it does not go away |
312 // before TPM token info is fetched. | 311 // before TPM token info is fetched. |
313 // TODO(tbarzic, pneubeck): Handle this in a nicer way when this logic is | 312 // TODO(tbarzic, pneubeck): Handle this in a nicer way when this logic is |
314 // moved to a separate profile service. | 313 // moved to a separate profile service. |
315 token_info_getter->Start( | 314 token_info_getter->Start( |
316 base::Bind(&DidGetTPMInfoForUserOnUIThread, | 315 base::Bind(&DidGetTPMInfoForUserOnUIThread, |
317 base::Passed(&scoped_token_info_getter), | 316 base::Passed(&scoped_token_info_getter), |
318 username_hash)); | 317 username_hash)); |
319 } | 318 } |
320 | 319 |
321 void StartTPMSlotInitializationOnIOThread(const std::string& username, | 320 void StartTPMSlotInitializationOnIOThread(const AccountId& account_id, |
322 const std::string& username_hash) { | 321 const std::string& username_hash) { |
323 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 322 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
324 | 323 |
325 BrowserThread::PostTask( | 324 BrowserThread::PostTask( |
326 BrowserThread::UI, | 325 BrowserThread::UI, FROM_HERE, |
327 FROM_HERE, | 326 base::Bind(&GetTPMInfoForUserOnUIThread, account_id, username_hash)); |
328 base::Bind(&GetTPMInfoForUserOnUIThread, username, username_hash)); | |
329 } | 327 } |
330 | 328 |
331 void StartNSSInitOnIOThread(const std::string& username, | 329 void StartNSSInitOnIOThread(const AccountId& account_id, |
332 const std::string& username_hash, | 330 const std::string& username_hash, |
333 const base::FilePath& path) { | 331 const base::FilePath& path) { |
334 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 332 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
335 DVLOG(1) << "Starting NSS init for " << username | 333 DVLOG(1) << "Starting NSS init for " << account_id.Serialize() |
336 << " hash:" << username_hash; | 334 << " hash:" << username_hash; |
337 | 335 |
338 // Make sure NSS is initialized for the user. | 336 // Make sure NSS is initialized for the user. |
339 crypto::InitializeNSSForChromeOSUser(username_hash, path); | 337 crypto::InitializeNSSForChromeOSUser(username_hash, path); |
340 | 338 |
341 // Check if it's OK to initialize TPM for the user before continuing. This | 339 // Check if it's OK to initialize TPM for the user before continuing. This |
342 // may not be the case if the TPM slot initialization was previously | 340 // may not be the case if the TPM slot initialization was previously |
343 // requested for the same user. | 341 // requested for the same user. |
344 if (!crypto::ShouldInitializeTPMForChromeOSUser(username_hash)) | 342 if (!crypto::ShouldInitializeTPMForChromeOSUser(username_hash)) |
345 return; | 343 return; |
346 | 344 |
347 crypto::WillInitializeTPMForChromeOSUser(username_hash); | 345 crypto::WillInitializeTPMForChromeOSUser(username_hash); |
348 | 346 |
349 if (crypto::IsTPMTokenEnabledForNSS()) { | 347 if (crypto::IsTPMTokenEnabledForNSS()) { |
350 if (crypto::IsTPMTokenReady(base::Bind( | 348 if (crypto::IsTPMTokenReady( |
351 &StartTPMSlotInitializationOnIOThread, username, username_hash))) { | 349 base::Bind(&StartTPMSlotInitializationOnIOThread, account_id, |
352 StartTPMSlotInitializationOnIOThread(username, username_hash); | 350 username_hash))) { |
| 351 StartTPMSlotInitializationOnIOThread(account_id, username_hash); |
353 } else { | 352 } else { |
354 DVLOG(1) << "Waiting for tpm ready ..."; | 353 DVLOG(1) << "Waiting for tpm ready ..."; |
355 } | 354 } |
356 } else { | 355 } else { |
357 crypto::InitializePrivateSoftwareSlotForChromeOSUser(username_hash); | 356 crypto::InitializePrivateSoftwareSlotForChromeOSUser(username_hash); |
358 } | 357 } |
359 } | 358 } |
360 #endif // defined(OS_CHROMEOS) | 359 #endif // defined(OS_CHROMEOS) |
361 | 360 |
362 #if defined(USE_NSS_CERTS) | 361 #if defined(USE_NSS_CERTS) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 if (user_manager) { | 438 if (user_manager) { |
440 const user_manager::User* user = | 439 const user_manager::User* user = |
441 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); | 440 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); |
442 // No need to initialize NSS for users with empty username hash: | 441 // No need to initialize NSS for users with empty username hash: |
443 // Getters for a user's NSS slots always return NULL slot if the user's | 442 // Getters for a user's NSS slots always return NULL slot if the user's |
444 // username hash is empty, even when the NSS is not initialized for the | 443 // username hash is empty, even when the NSS is not initialized for the |
445 // user. | 444 // user. |
446 if (user && !user->username_hash().empty()) { | 445 if (user && !user->username_hash().empty()) { |
447 params->username_hash = user->username_hash(); | 446 params->username_hash = user->username_hash(); |
448 DCHECK(!params->username_hash.empty()); | 447 DCHECK(!params->username_hash.empty()); |
449 BrowserThread::PostTask(BrowserThread::IO, | 448 BrowserThread::PostTask( |
450 FROM_HERE, | 449 BrowserThread::IO, FROM_HERE, |
451 base::Bind(&StartNSSInitOnIOThread, | 450 base::Bind(&StartNSSInitOnIOThread, user->GetAccountId(), |
452 user->email(), | 451 user->username_hash(), profile->GetPath())); |
453 user->username_hash(), | |
454 profile->GetPath())); | |
455 | 452 |
456 // Use the device-wide system key slot only if the user is affiliated on | 453 // Use the device-wide system key slot only if the user is affiliated on |
457 // the device. | 454 // the device. |
458 params->use_system_key_slot = user->is_affiliated(); | 455 params->use_system_key_slot = user->is_affiliated(); |
459 } | 456 } |
460 } | 457 } |
461 | 458 |
462 chromeos::CertificateProviderService* cert_provider_service = | 459 chromeos::CertificateProviderService* cert_provider_service = |
463 chromeos::CertificateProviderServiceFactory::GetForBrowserContext( | 460 chromeos::CertificateProviderServiceFactory::GetForBrowserContext( |
464 profile); | 461 profile); |
(...skipping 857 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1322 make_scoped_ptr(new DevToolsNetworkTransactionFactory( | 1319 make_scoped_ptr(new DevToolsNetworkTransactionFactory( |
1323 network_controller_handle_.GetController(), shared_session)), | 1320 network_controller_handle_.GetController(), shared_session)), |
1324 std::move(backend), true /* set_up_quic_server_info */)); | 1321 std::move(backend), true /* set_up_quic_server_info */)); |
1325 } | 1322 } |
1326 | 1323 |
1327 void ProfileIOData::SetCookieSettingsForTesting( | 1324 void ProfileIOData::SetCookieSettingsForTesting( |
1328 content_settings::CookieSettings* cookie_settings) { | 1325 content_settings::CookieSettings* cookie_settings) { |
1329 DCHECK(!cookie_settings_.get()); | 1326 DCHECK(!cookie_settings_.get()); |
1330 cookie_settings_ = cookie_settings; | 1327 cookie_settings_ = cookie_settings; |
1331 } | 1328 } |
OLD | NEW |