| Index: chrome/browser/chromeos/ownership/owner_settings_service.cc | 
| diff --git a/chrome/browser/chromeos/ownership/owner_settings_service.cc b/chrome/browser/chromeos/ownership/owner_settings_service.cc | 
| index cf08b95a1d39f0b2c8d165874f4c3e87216ac83b..81724dfb887ed1dcf76482b5f17df6cd3b9f366d 100644 | 
| --- a/chrome/browser/chromeos/ownership/owner_settings_service.cc | 
| +++ b/chrome/browser/chromeos/ownership/owner_settings_service.cc | 
| @@ -7,6 +7,7 @@ | 
| #include <string> | 
|  | 
| #include "base/bind.h" | 
| +#include "base/bind_helpers.h" | 
| #include "chrome/browser/chrome_notification_types.h" | 
| #include "chrome/browser/chromeos/login/users/user.h" | 
| #include "chrome/browser/chromeos/login/users/user_manager.h" | 
| @@ -102,7 +103,7 @@ void LoadPrivateKey( | 
| } | 
| } | 
|  | 
| -bool IsPrivateKeyExistAsyncHelper( | 
| +bool DoesPrivateKeyExistAsyncHelper( | 
| const scoped_refptr<OwnerKeyUtil>& owner_key_util) { | 
| std::vector<uint8> public_key; | 
| if (!owner_key_util->ImportPublicKey(&public_key)) | 
| @@ -113,6 +114,26 @@ bool IsPrivateKeyExistAsyncHelper( | 
| return is_owner; | 
| } | 
|  | 
| +// Checks whether NSS slots with private key are mounted or | 
| +// not. Responds via |callback|. | 
| +void DoesPrivateKeyExistAsync( | 
| +    const OwnerSettingsService::IsOwnerCallback& callback) { | 
| +  scoped_refptr<OwnerKeyUtil> owner_key_util; | 
| +  if (g_owner_key_util_for_testing) | 
| +    owner_key_util = *g_owner_key_util_for_testing; | 
| +  else | 
| +    owner_key_util = OwnerKeyUtil::Create(); | 
| +  scoped_refptr<base::TaskRunner> task_runner = | 
| +      content::BrowserThread::GetBlockingPool() | 
| +          ->GetTaskRunnerWithShutdownBehavior( | 
| +              base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); | 
| +  base::PostTaskAndReplyWithResult( | 
| +      task_runner.get(), | 
| +      FROM_HERE, | 
| +      base::Bind(&DoesPrivateKeyExistAsyncHelper, owner_key_util), | 
| +      callback); | 
| +} | 
| + | 
| }  // namespace | 
|  | 
| OwnerSettingsService::OwnerSettingsService(Profile* profile) | 
| @@ -197,22 +218,22 @@ void OwnerSettingsService::OnTPMTokenReady() { | 
| } | 
|  | 
| // static | 
| -void OwnerSettingsService::IsPrivateKeyExistAsync( | 
| +void OwnerSettingsService::IsOwnerForSafeModeAsync( | 
| +    const std::string& user_id, | 
| +    const std::string& user_hash, | 
| const IsOwnerCallback& callback) { | 
| -  scoped_refptr<OwnerKeyUtil> owner_key_util; | 
| -  if (g_owner_key_util_for_testing) | 
| -    owner_key_util = *g_owner_key_util_for_testing; | 
| -  else | 
| -    owner_key_util = OwnerKeyUtil::Create(); | 
| -  scoped_refptr<base::TaskRunner> task_runner = | 
| -      content::BrowserThread::GetBlockingPool() | 
| -          ->GetTaskRunnerWithShutdownBehavior( | 
| -              base::SequencedWorkerPool::SKIP_ON_SHUTDOWN); | 
| -  base::PostTaskAndReplyWithResult( | 
| -      task_runner.get(), | 
| +  CHECK(chromeos::LoginState::Get()->IsInSafeMode()); | 
| + | 
| +  // Make sure NSS is initialized and NSS DB is loaded for the user before | 
| +  // searching for the owner key. | 
| +  BrowserThread::PostTaskAndReply( | 
| +      BrowserThread::IO, | 
| FROM_HERE, | 
| -      base::Bind(&IsPrivateKeyExistAsyncHelper, owner_key_util), | 
| -      callback); | 
| +      base::Bind(base::IgnoreResult(&crypto::InitializeNSSForChromeOSUser), | 
| +                 user_id, | 
| +                 user_hash, | 
| +                 ProfileHelper::GetProfilePathByUserIdHash(user_hash)), | 
| +      base::Bind(&DoesPrivateKeyExistAsync, callback)); | 
| } | 
|  | 
| // static | 
|  |