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 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 BrowserThread::PostTask( | 269 BrowserThread::PostTask( |
270 BrowserThread::IO, | 270 BrowserThread::IO, |
271 FROM_HERE, | 271 FROM_HERE, |
272 base::Bind(&crypto::InitializeTPMForChromeOSUser, | 272 base::Bind(&crypto::InitializeTPMForChromeOSUser, |
273 username_hash, info.token_slot_id)); | 273 username_hash, info.token_slot_id)); |
274 } else { | 274 } else { |
275 NOTREACHED() << "TPMTokenInfoGetter reported invalid token."; | 275 NOTREACHED() << "TPMTokenInfoGetter reported invalid token."; |
276 } | 276 } |
277 } | 277 } |
278 | 278 |
279 void GetTPMInfoForUserOnUIThread(const std::string& username, | 279 void GetTPMInfoForUserOnUIThread(const user_manager::UserID& user_id, |
280 const std::string& username_hash) { | 280 const std::string& username_hash) { |
281 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 281 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
282 DVLOG(1) << "Getting TPM info from cryptohome for " | 282 DVLOG(1) << "Getting TPM info from cryptohome for " |
283 << " " << username << " " << username_hash; | 283 << " " << user_id.GetUserEmail() << " " << username_hash; |
284 scoped_ptr<chromeos::TPMTokenInfoGetter> scoped_token_info_getter = | 284 scoped_ptr<chromeos::TPMTokenInfoGetter> scoped_token_info_getter = |
285 chromeos::TPMTokenInfoGetter::CreateForUserToken( | 285 chromeos::TPMTokenInfoGetter::CreateForUserToken( |
286 username, | 286 user_id, |
287 chromeos::DBusThreadManager::Get()->GetCryptohomeClient(), | 287 chromeos::DBusThreadManager::Get()->GetCryptohomeClient(), |
288 base::ThreadTaskRunnerHandle::Get()); | 288 base::ThreadTaskRunnerHandle::Get()); |
289 chromeos::TPMTokenInfoGetter* token_info_getter = | 289 chromeos::TPMTokenInfoGetter* token_info_getter = |
290 scoped_token_info_getter.get(); | 290 scoped_token_info_getter.get(); |
291 | 291 |
292 // Bind |token_info_getter| to the callback to ensure it does not go away | 292 // Bind |token_info_getter| to the callback to ensure it does not go away |
293 // before TPM token info is fetched. | 293 // before TPM token info is fetched. |
294 // TODO(tbarzic, pneubeck): Handle this in a nicer way when this logic is | 294 // TODO(tbarzic, pneubeck): Handle this in a nicer way when this logic is |
295 // moved to a separate profile service. | 295 // moved to a separate profile service. |
296 token_info_getter->Start( | 296 token_info_getter->Start( |
297 base::Bind(&DidGetTPMInfoForUserOnUIThread, | 297 base::Bind(&DidGetTPMInfoForUserOnUIThread, |
298 base::Passed(&scoped_token_info_getter), | 298 base::Passed(&scoped_token_info_getter), |
299 username_hash)); | 299 username_hash)); |
300 } | 300 } |
301 | 301 |
302 void StartTPMSlotInitializationOnIOThread(const std::string& username, | 302 void StartTPMSlotInitializationOnIOThread(const user_manager::UserID& user_id, |
303 const std::string& username_hash) { | 303 const std::string& username_hash) { |
304 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 304 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
305 | 305 |
306 BrowserThread::PostTask( | 306 BrowserThread::PostTask( |
307 BrowserThread::UI, | 307 BrowserThread::UI, |
308 FROM_HERE, | 308 FROM_HERE, |
309 base::Bind(&GetTPMInfoForUserOnUIThread, username, username_hash)); | 309 base::Bind(&GetTPMInfoForUserOnUIThread, user_id, username_hash)); |
310 } | 310 } |
311 | 311 |
312 void StartNSSInitOnIOThread(const std::string& username, | 312 void StartNSSInitOnIOThread(const user_manager::UserID& user_id, |
313 const std::string& username_hash, | 313 const std::string& username_hash, |
314 const base::FilePath& path) { | 314 const base::FilePath& path) { |
315 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 315 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
316 DVLOG(1) << "Starting NSS init for " << username | 316 DVLOG(1) << "Starting NSS init for " << user_id.GetUserEmail() |
317 << " hash:" << username_hash; | 317 << " hash:" << username_hash; |
318 | 318 |
319 // Make sure NSS is initialized for the user. | 319 // Make sure NSS is initialized for the user. |
320 crypto::InitializeNSSForChromeOSUser(username_hash, path); | 320 crypto::InitializeNSSForChromeOSUser(username_hash, path); |
321 | 321 |
322 // Check if it's OK to initialize TPM for the user before continuing. This | 322 // Check if it's OK to initialize TPM for the user before continuing. This |
323 // may not be the case if the TPM slot initialization was previously | 323 // may not be the case if the TPM slot initialization was previously |
324 // requested for the same user. | 324 // requested for the same user. |
325 if (!crypto::ShouldInitializeTPMForChromeOSUser(username_hash)) | 325 if (!crypto::ShouldInitializeTPMForChromeOSUser(username_hash)) |
326 return; | 326 return; |
327 | 327 |
328 crypto::WillInitializeTPMForChromeOSUser(username_hash); | 328 crypto::WillInitializeTPMForChromeOSUser(username_hash); |
329 | 329 |
330 if (crypto::IsTPMTokenEnabledForNSS()) { | 330 if (crypto::IsTPMTokenEnabledForNSS()) { |
331 if (crypto::IsTPMTokenReady(base::Bind( | 331 if (crypto::IsTPMTokenReady(base::Bind( |
332 &StartTPMSlotInitializationOnIOThread, username, username_hash))) { | 332 &StartTPMSlotInitializationOnIOThread, user_id, username_hash))) { |
333 StartTPMSlotInitializationOnIOThread(username, username_hash); | 333 StartTPMSlotInitializationOnIOThread(user_id, username_hash); |
334 } else { | 334 } else { |
335 DVLOG(1) << "Waiting for tpm ready ..."; | 335 DVLOG(1) << "Waiting for tpm ready ..."; |
336 } | 336 } |
337 } else { | 337 } else { |
338 crypto::InitializePrivateSoftwareSlotForChromeOSUser(username_hash); | 338 crypto::InitializePrivateSoftwareSlotForChromeOSUser(username_hash); |
339 } | 339 } |
340 } | 340 } |
341 #endif // defined(OS_CHROMEOS) | 341 #endif // defined(OS_CHROMEOS) |
342 | 342 |
343 #if defined(USE_NSS_CERTS) | 343 #if defined(USE_NSS_CERTS) |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
423 // No need to initialize NSS for users with empty username hash: | 423 // No need to initialize NSS for users with empty username hash: |
424 // Getters for a user's NSS slots always return NULL slot if the user's | 424 // Getters for a user's NSS slots always return NULL slot if the user's |
425 // username hash is empty, even when the NSS is not initialized for the | 425 // username hash is empty, even when the NSS is not initialized for the |
426 // user. | 426 // user. |
427 if (user && !user->username_hash().empty()) { | 427 if (user && !user->username_hash().empty()) { |
428 params->username_hash = user->username_hash(); | 428 params->username_hash = user->username_hash(); |
429 DCHECK(!params->username_hash.empty()); | 429 DCHECK(!params->username_hash.empty()); |
430 BrowserThread::PostTask(BrowserThread::IO, | 430 BrowserThread::PostTask(BrowserThread::IO, |
431 FROM_HERE, | 431 FROM_HERE, |
432 base::Bind(&StartNSSInitOnIOThread, | 432 base::Bind(&StartNSSInitOnIOThread, |
433 user->email(), | 433 user->GetUserID(), |
434 user->username_hash(), | 434 user->username_hash(), |
435 profile->GetPath())); | 435 profile->GetPath())); |
436 | 436 |
437 // Use the device-wide system key slot only if the user is of the same | 437 // Use the device-wide system key slot only if the user is of the same |
438 // domain as the device is registered to. | 438 // domain as the device is registered to. |
439 policy::BrowserPolicyConnectorChromeOS* connector = | 439 policy::BrowserPolicyConnectorChromeOS* connector = |
440 g_browser_process->platform_part() | 440 g_browser_process->platform_part() |
441 ->browser_policy_connector_chromeos(); | 441 ->browser_policy_connector_chromeos(); |
442 params->use_system_key_slot = | 442 params->use_system_key_slot = |
443 connector->GetUserAffiliation(user->email()) == | 443 connector->GetUserAffiliation(user->GetUserID()) == |
444 policy::USER_AFFILIATION_MANAGED; | 444 policy::USER_AFFILIATION_MANAGED; |
445 } | 445 } |
446 } | 446 } |
447 #endif | 447 #endif |
448 | 448 |
449 params->profile = profile; | 449 params->profile = profile; |
450 profile_params_.reset(params.release()); | 450 profile_params_.reset(params.release()); |
451 | 451 |
452 ChromeNetworkDelegate::InitializePrefsOnUIThread( | 452 ChromeNetworkDelegate::InitializePrefsOnUIThread( |
453 &enable_referrers_, | 453 &enable_referrers_, |
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1287 new DevToolsNetworkTransactionFactory( | 1287 new DevToolsNetworkTransactionFactory( |
1288 network_controller_.get(), shared_session), | 1288 network_controller_.get(), shared_session), |
1289 shared_session->net_log(), backend)); | 1289 shared_session->net_log(), backend)); |
1290 } | 1290 } |
1291 | 1291 |
1292 void ProfileIOData::SetCookieSettingsForTesting( | 1292 void ProfileIOData::SetCookieSettingsForTesting( |
1293 CookieSettings* cookie_settings) { | 1293 CookieSettings* cookie_settings) { |
1294 DCHECK(!cookie_settings_.get()); | 1294 DCHECK(!cookie_settings_.get()); |
1295 cookie_settings_ = cookie_settings; | 1295 cookie_settings_ = cookie_settings; |
1296 } | 1296 } |
OLD | NEW |