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/signin/easy_unlock_service_signin_chromeos.h" | 5 #include "chrome/browser/signin/easy_unlock_service_signin_chromeos.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h" | 14 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h" |
15 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_metrics.h" | 15 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_metrics.h" |
16 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 16 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
17 #include "chromeos/login/auth/user_context.h" | 17 #include "chromeos/login/auth/user_context.h" |
| 18 #include "chromeos/tpm_token_loader.h" |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 // The maximum allowed backoff interval when waiting for cryptohome to start. | 22 // The maximum allowed backoff interval when waiting for cryptohome to start. |
22 uint32 kMaxCryptohomeBackoffIntervalMs = 10000u; | 23 uint32 kMaxCryptohomeBackoffIntervalMs = 10000u; |
23 | 24 |
24 // If the data load fails, the initial interval after which the load will be | 25 // If the data load fails, the initial interval after which the load will be |
25 // retried. Further intervals will exponentially increas by factor 2. | 26 // retried. Further intervals will exponentially increas by factor 2. |
26 uint32 kInitialCryptohomeBackoffIntervalMs = 200u; | 27 uint32 kInitialCryptohomeBackoffIntervalMs = 200u; |
27 | 28 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 ResetScreenlockState(); | 309 ResetScreenlockState(); |
309 ShowInitialUserState(); | 310 ShowInitialUserState(); |
310 | 311 |
311 if (should_update_app_state) { | 312 if (should_update_app_state) { |
312 UpdateAppState(); | 313 UpdateAppState(); |
313 } else { | 314 } else { |
314 NotifyUserUpdated(); | 315 NotifyUserUpdated(); |
315 } | 316 } |
316 | 317 |
317 LoadCurrentUserDataIfNeeded(); | 318 LoadCurrentUserDataIfNeeded(); |
| 319 |
| 320 // Start loading TPM system token. |
| 321 // The system token will be needed to sign a nonce using TPM private key |
| 322 // during the sign-in protocol. |
| 323 EasyUnlockScreenlockStateHandler::HardlockState hardlock_state; |
| 324 if (GetPersistedHardlockState(&hardlock_state) && |
| 325 hardlock_state != EasyUnlockScreenlockStateHandler::NO_PAIRING) { |
| 326 chromeos::TPMTokenLoader::Get()->EnsureStarted(); |
| 327 } |
318 } | 328 } |
319 | 329 |
320 void EasyUnlockServiceSignin::LoggedInStateChanged() { | 330 void EasyUnlockServiceSignin::LoggedInStateChanged() { |
321 if (!chromeos::LoginState::Get()->IsUserLoggedIn()) | 331 if (!chromeos::LoginState::Get()->IsUserLoggedIn()) |
322 return; | 332 return; |
323 UnloadApp(); | 333 UnloadApp(); |
324 } | 334 } |
325 | 335 |
326 void EasyUnlockServiceSignin::LoadCurrentUserDataIfNeeded() { | 336 void EasyUnlockServiceSignin::LoadCurrentUserDataIfNeeded() { |
327 if (user_id_.empty() || !service_active_) | 337 if (user_id_.empty() || !service_active_) |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 return NULL; | 381 return NULL; |
372 | 382 |
373 std::map<std::string, UserData*>::const_iterator it = | 383 std::map<std::string, UserData*>::const_iterator it = |
374 user_data_.find(user_id_); | 384 user_data_.find(user_id_); |
375 if (it == user_data_.end()) | 385 if (it == user_data_.end()) |
376 return NULL; | 386 return NULL; |
377 if (it->second->state != USER_DATA_STATE_LOADED) | 387 if (it->second->state != USER_DATA_STATE_LOADED) |
378 return NULL; | 388 return NULL; |
379 return it->second; | 389 return it->second; |
380 } | 390 } |
OLD | NEW |