OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chromeos/ownership/owner_settings_service.h" | 5 #include "chrome/browser/chromeos/ownership/owner_settings_service.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | |
10 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
11 #include "chrome/browser/chromeos/login/users/user.h" | 12 #include "chrome/browser/chromeos/login/users/user.h" |
12 #include "chrome/browser/chromeos/login/users/user_manager.h" | 13 #include "chrome/browser/chromeos/login/users/user_manager.h" |
13 #include "chrome/browser/chromeos/ownership/owner_settings_service_factory.h" | 14 #include "chrome/browser/chromeos/ownership/owner_settings_service_factory.h" |
14 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 15 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
17 #include "content/public/browser/notification_details.h" | 18 #include "content/public/browser/notification_details.h" |
18 #include "content/public/browser/notification_source.h" | 19 #include "content/public/browser/notification_source.h" |
19 #include "crypto/nss_util.h" | 20 #include "crypto/nss_util.h" |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
190 void OwnerSettingsService::OnTPMTokenReady() { | 191 void OwnerSettingsService::OnTPMTokenReady() { |
191 DCHECK(thread_checker_.CalledOnValidThread()); | 192 DCHECK(thread_checker_.CalledOnValidThread()); |
192 waiting_for_tpm_token_ = false; | 193 waiting_for_tpm_token_ = false; |
193 | 194 |
194 // TPMTokenLoader initializes the TPM and NSS database which is necessary to | 195 // TPMTokenLoader initializes the TPM and NSS database which is necessary to |
195 // determine ownership. Force a reload once we know these are initialized. | 196 // determine ownership. Force a reload once we know these are initialized. |
196 ReloadPrivateKey(); | 197 ReloadPrivateKey(); |
197 } | 198 } |
198 | 199 |
199 // static | 200 // static |
201 void OwnerSettingsService::IsOwnerForSafeModeAsync( | |
202 const std::string& user_id, | |
203 const std::string& user_hash, | |
204 const IsOwnerCallback& callback) { | |
205 CHECK(chromeos::LoginState::Get()->IsInSafeMode()); | |
206 | |
207 // Make sure NSS is initialzied and NSS DB is loaded for the user before | |
pneubeck (no reviews)
2014/07/01 14:37:17
typo: initialzied -> initialized
tbarzic
2014/07/01 23:55:03
Done.
| |
208 // serching for the owner key. | |
pneubeck (no reviews)
2014/07/01 14:37:17
typo: serching -> searching
tbarzic
2014/07/01 23:55:03
Done.
| |
209 BrowserThread::PostTaskAndReply( | |
210 BrowserThread::IO, | |
211 FROM_HERE, | |
212 base::Bind(base::IgnoreResult(&crypto::InitializeNSSForChromeOSUser), | |
213 user_id, | |
214 user_hash, | |
215 ProfileHelper::GetProfilePathByUserIdHash(user_hash), | |
216 true /* provisional */), | |
pneubeck (no reviews)
2014/07/01 14:37:17
How about always initializing NSS in the parallel
tbarzic
2014/07/01 16:33:07
The NSS is actually initialized in profile_io_data
| |
217 base::Bind(&OwnerSettingsService::IsPrivateKeyExistAsync, | |
218 callback)); | |
219 } | |
220 | |
221 // static | |
200 void OwnerSettingsService::IsPrivateKeyExistAsync( | 222 void OwnerSettingsService::IsPrivateKeyExistAsync( |
201 const IsOwnerCallback& callback) { | 223 const IsOwnerCallback& callback) { |
202 scoped_refptr<OwnerKeyUtil> owner_key_util; | 224 scoped_refptr<OwnerKeyUtil> owner_key_util; |
203 if (g_owner_key_util_for_testing) | 225 if (g_owner_key_util_for_testing) |
204 owner_key_util = *g_owner_key_util_for_testing; | 226 owner_key_util = *g_owner_key_util_for_testing; |
205 else | 227 else |
206 owner_key_util = OwnerKeyUtil::Create(); | 228 owner_key_util = OwnerKeyUtil::Create(); |
207 scoped_refptr<base::TaskRunner> task_runner = | 229 scoped_refptr<base::TaskRunner> task_runner = |
208 content::BrowserThread::GetBlockingPool() | 230 content::BrowserThread::GetBlockingPool() |
209 ->GetTaskRunnerWithShutdownBehavior( | 231 ->GetTaskRunnerWithShutdownBehavior( |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 DeviceSettingsService* OwnerSettingsService::GetDeviceSettingsService() { | 304 DeviceSettingsService* OwnerSettingsService::GetDeviceSettingsService() { |
283 DCHECK(thread_checker_.CalledOnValidThread()); | 305 DCHECK(thread_checker_.CalledOnValidThread()); |
284 if (g_device_settings_service_for_testing) | 306 if (g_device_settings_service_for_testing) |
285 return g_device_settings_service_for_testing; | 307 return g_device_settings_service_for_testing; |
286 if (DeviceSettingsService::IsInitialized()) | 308 if (DeviceSettingsService::IsInitialized()) |
287 return DeviceSettingsService::Get(); | 309 return DeviceSettingsService::Get(); |
288 return NULL; | 310 return NULL; |
289 } | 311 } |
290 | 312 |
291 } // namespace chromeos | 313 } // namespace chromeos |
OLD | NEW |