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.h" | 5 #include "chrome/browser/signin/easy_unlock_service.h" |
6 | 6 |
7 #include "apps/app_lifetime_monitor.h" | 7 #include "apps/app_lifetime_monitor.h" |
8 #include "apps/app_lifetime_monitor_factory.h" | 8 #include "apps/app_lifetime_monitor_factory.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/signin/easy_unlock_service_observer.h" | 24 #include "chrome/browser/signin/easy_unlock_service_observer.h" |
25 #include "chrome/browser/signin/proximity_auth_facade.h" | 25 #include "chrome/browser/signin/proximity_auth_facade.h" |
26 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
27 #include "chrome/common/extensions/extension_constants.h" | 27 #include "chrome/common/extensions/extension_constants.h" |
28 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
29 #include "components/pref_registry/pref_registry_syncable.h" | 29 #include "components/pref_registry/pref_registry_syncable.h" |
30 #include "components/proximity_auth/ble/proximity_auth_ble_system.h" | 30 #include "components/proximity_auth/ble/proximity_auth_ble_system.h" |
31 #include "components/proximity_auth/screenlock_bridge.h" | 31 #include "components/proximity_auth/screenlock_bridge.h" |
32 #include "components/proximity_auth/switches.h" | 32 #include "components/proximity_auth/switches.h" |
33 #include "components/user_manager/user.h" | 33 #include "components/user_manager/user.h" |
| 34 #include "components/user_manager/user_id.h" |
34 #include "device/bluetooth/bluetooth_adapter.h" | 35 #include "device/bluetooth/bluetooth_adapter.h" |
35 #include "device/bluetooth/bluetooth_adapter_factory.h" | 36 #include "device/bluetooth/bluetooth_adapter_factory.h" |
36 | 37 |
37 #if defined(OS_CHROMEOS) | 38 #if defined(OS_CHROMEOS) |
38 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h" | 39 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_key_manager.h" |
39 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager.
h" | 40 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager.
h" |
40 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_
factory.h" | 41 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_
factory.h" |
41 #include "chrome/browser/chromeos/login/session/user_session_manager.h" | 42 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
42 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 43 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
43 #include "chromeos/dbus/dbus_thread_manager.h" | 44 #include "chromeos/dbus/dbus_thread_manager.h" |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 void EasyUnlockService::RegisterPrefs(PrefRegistrySimple* registry) { | 279 void EasyUnlockService::RegisterPrefs(PrefRegistrySimple* registry) { |
279 registry->RegisterStringPref(prefs::kEasyUnlockDeviceId, std::string()); | 280 registry->RegisterStringPref(prefs::kEasyUnlockDeviceId, std::string()); |
280 registry->RegisterDictionaryPref(prefs::kEasyUnlockHardlockState); | 281 registry->RegisterDictionaryPref(prefs::kEasyUnlockHardlockState); |
281 registry->RegisterDictionaryPref(prefs::kEasyUnlockLocalStateUserPrefs); | 282 registry->RegisterDictionaryPref(prefs::kEasyUnlockLocalStateUserPrefs); |
282 #if defined(OS_CHROMEOS) | 283 #if defined(OS_CHROMEOS) |
283 EasyUnlockTpmKeyManager::RegisterLocalStatePrefs(registry); | 284 EasyUnlockTpmKeyManager::RegisterLocalStatePrefs(registry); |
284 #endif | 285 #endif |
285 } | 286 } |
286 | 287 |
287 // static | 288 // static |
288 void EasyUnlockService::ResetLocalStateForUser(const std::string& user_id) { | 289 void EasyUnlockService::ResetLocalStateForUser(const user_manager::UserID& user_
id) { |
289 DCHECK(!user_id.empty()); | 290 DCHECK(!user_id.empty()); |
290 | 291 |
291 PrefService* local_state = GetLocalState(); | 292 PrefService* local_state = GetLocalState(); |
292 if (!local_state) | 293 if (!local_state) |
293 return; | 294 return; |
294 | 295 |
295 DictionaryPrefUpdate update(local_state, prefs::kEasyUnlockHardlockState); | 296 DictionaryPrefUpdate update(local_state, prefs::kEasyUnlockHardlockState); |
296 update->RemoveWithoutPathExpansion(user_id, NULL); | 297 update->RemoveWithoutPathExpansion(user_id.GetUserEmail(), NULL); |
297 | 298 |
298 #if defined(OS_CHROMEOS) | 299 #if defined(OS_CHROMEOS) |
299 EasyUnlockTpmKeyManager::ResetLocalStateForUser(user_id); | 300 EasyUnlockTpmKeyManager::ResetLocalStateForUser(user_id); |
300 #endif | 301 #endif |
301 } | 302 } |
302 | 303 |
303 // static | 304 // static |
304 EasyUnlockService::UserSettings EasyUnlockService::GetUserSettings( | 305 EasyUnlockService::UserSettings EasyUnlockService::GetUserSettings( |
305 const std::string& user_id) { | 306 const user_manager::UserID& user_id) { |
306 DCHECK(!user_id.empty()); | 307 DCHECK(!user_id.empty()); |
307 UserSettings user_settings; | 308 UserSettings user_settings; |
308 | 309 |
309 PrefService* local_state = GetLocalState(); | 310 PrefService* local_state = GetLocalState(); |
310 if (!local_state) | 311 if (!local_state) |
311 return user_settings; | 312 return user_settings; |
312 | 313 |
313 const base::DictionaryValue* all_user_prefs_dict = | 314 const base::DictionaryValue* all_user_prefs_dict = |
314 local_state->GetDictionary(prefs::kEasyUnlockLocalStateUserPrefs); | 315 local_state->GetDictionary(prefs::kEasyUnlockLocalStateUserPrefs); |
315 if (!all_user_prefs_dict) | 316 if (!all_user_prefs_dict) |
316 return user_settings; | 317 return user_settings; |
317 | 318 |
318 const base::DictionaryValue* user_prefs_dict; | 319 const base::DictionaryValue* user_prefs_dict; |
319 if (!all_user_prefs_dict->GetDictionaryWithoutPathExpansion(user_id, | 320 if (!all_user_prefs_dict->GetDictionaryWithoutPathExpansion(user_id.GetUserEma
il(), |
320 &user_prefs_dict)) | 321 &user_prefs_dict)) |
321 return user_settings; | 322 return user_settings; |
322 | 323 |
323 user_prefs_dict->GetBooleanWithoutPathExpansion( | 324 user_prefs_dict->GetBooleanWithoutPathExpansion( |
324 prefs::kEasyUnlockProximityRequired, | 325 prefs::kEasyUnlockProximityRequired, |
325 &user_settings.require_close_proximity); | 326 &user_settings.require_close_proximity); |
326 | 327 |
327 return user_settings; | 328 return user_settings; |
328 } | 329 } |
329 | 330 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 const base::ListValue* devices = GetRemoteDevices(); | 378 const base::ListValue* devices = GetRemoteDevices(); |
378 return devices && !devices->empty(); | 379 return devices && !devices->empty(); |
379 } | 380 } |
380 | 381 |
381 void EasyUnlockService::OpenSetupApp() { | 382 void EasyUnlockService::OpenSetupApp() { |
382 app_manager_->LaunchSetup(); | 383 app_manager_->LaunchSetup(); |
383 } | 384 } |
384 | 385 |
385 void EasyUnlockService::SetHardlockState( | 386 void EasyUnlockService::SetHardlockState( |
386 EasyUnlockScreenlockStateHandler::HardlockState state) { | 387 EasyUnlockScreenlockStateHandler::HardlockState state) { |
387 const std::string user_id = GetUserEmail(); | 388 const user_manager::UserID user_id = GetUserID(); |
388 if (user_id.empty()) | 389 if (user_id.empty()) |
389 return; | 390 return; |
390 | 391 |
391 if (state == GetHardlockState()) | 392 if (state == GetHardlockState()) |
392 return; | 393 return; |
393 | 394 |
394 SetHardlockStateForUser(user_id, state); | 395 SetHardlockStateForUser(user_id, state); |
395 } | 396 } |
396 | 397 |
397 EasyUnlockScreenlockStateHandler::HardlockState | 398 EasyUnlockScreenlockStateHandler::HardlockState |
398 EasyUnlockService::GetHardlockState() const { | 399 EasyUnlockService::GetHardlockState() const { |
399 EasyUnlockScreenlockStateHandler::HardlockState state; | 400 EasyUnlockScreenlockStateHandler::HardlockState state; |
400 if (GetPersistedHardlockState(&state)) | 401 if (GetPersistedHardlockState(&state)) |
401 return state; | 402 return state; |
402 | 403 |
403 return EasyUnlockScreenlockStateHandler::NO_HARDLOCK; | 404 return EasyUnlockScreenlockStateHandler::NO_HARDLOCK; |
404 } | 405 } |
405 | 406 |
406 bool EasyUnlockService::GetPersistedHardlockState( | 407 bool EasyUnlockService::GetPersistedHardlockState( |
407 EasyUnlockScreenlockStateHandler::HardlockState* state) const { | 408 EasyUnlockScreenlockStateHandler::HardlockState* state) const { |
408 std::string user_id = GetUserEmail(); | 409 const user_manager::UserID user_id = GetUserID(); |
409 if (user_id.empty()) | 410 if (user_id.empty()) |
410 return false; | 411 return false; |
411 | 412 |
412 PrefService* local_state = GetLocalState(); | 413 PrefService* local_state = GetLocalState(); |
413 if (!local_state) | 414 if (!local_state) |
414 return false; | 415 return false; |
415 | 416 |
416 const base::DictionaryValue* dict = | 417 const base::DictionaryValue* dict = |
417 local_state->GetDictionary(prefs::kEasyUnlockHardlockState); | 418 local_state->GetDictionary(prefs::kEasyUnlockHardlockState); |
418 int state_int; | 419 int state_int; |
419 if (dict && dict->GetIntegerWithoutPathExpansion(user_id, &state_int)) { | 420 if (dict && dict->GetIntegerWithoutPathExpansion(user_id.GetUserEmail(), &stat
e_int)) { |
420 *state = | 421 *state = |
421 static_cast<EasyUnlockScreenlockStateHandler::HardlockState>(state_int); | 422 static_cast<EasyUnlockScreenlockStateHandler::HardlockState>(state_int); |
422 return true; | 423 return true; |
423 } | 424 } |
424 | 425 |
425 return false; | 426 return false; |
426 } | 427 } |
427 | 428 |
428 void EasyUnlockService::ShowInitialUserState() { | 429 void EasyUnlockService::ShowInitialUserState() { |
429 if (!GetScreenlockStateHandler()) | 430 if (!GetScreenlockStateHandler()) |
(...skipping 11 matching lines...) Expand all Loading... |
441 screenlock_state_handler_->MaybeShowHardlockUI(); | 442 screenlock_state_handler_->MaybeShowHardlockUI(); |
442 } | 443 } |
443 } | 444 } |
444 | 445 |
445 EasyUnlockScreenlockStateHandler* | 446 EasyUnlockScreenlockStateHandler* |
446 EasyUnlockService::GetScreenlockStateHandler() { | 447 EasyUnlockService::GetScreenlockStateHandler() { |
447 if (!IsAllowed()) | 448 if (!IsAllowed()) |
448 return NULL; | 449 return NULL; |
449 if (!screenlock_state_handler_) { | 450 if (!screenlock_state_handler_) { |
450 screenlock_state_handler_.reset(new EasyUnlockScreenlockStateHandler( | 451 screenlock_state_handler_.reset(new EasyUnlockScreenlockStateHandler( |
451 GetUserEmail(), GetHardlockState(), GetScreenlockBridgeInstance())); | 452 GetUserID(), GetHardlockState(), GetScreenlockBridgeInstance())); |
452 } | 453 } |
453 return screenlock_state_handler_.get(); | 454 return screenlock_state_handler_.get(); |
454 } | 455 } |
455 | 456 |
456 bool EasyUnlockService::UpdateScreenlockState(ScreenlockState state) { | 457 bool EasyUnlockService::UpdateScreenlockState(ScreenlockState state) { |
457 EasyUnlockScreenlockStateHandler* handler = GetScreenlockStateHandler(); | 458 EasyUnlockScreenlockStateHandler* handler = GetScreenlockStateHandler(); |
458 if (!handler) | 459 if (!handler) |
459 return false; | 460 return false; |
460 | 461 |
461 handler->ChangeState(state); | 462 handler->ChangeState(state); |
462 | 463 |
463 if (state == ScreenlockState::AUTHENTICATED) { | 464 if (state == ScreenlockState::AUTHENTICATED) { |
464 #if defined(OS_CHROMEOS) | 465 #if defined(OS_CHROMEOS) |
465 if (power_monitor_) | 466 if (power_monitor_) |
466 power_monitor_->RecordStartUpTime(); | 467 power_monitor_->RecordStartUpTime(); |
467 #endif | 468 #endif |
468 } else if (auth_attempt_.get()) { | 469 } else if (auth_attempt_.get()) { |
469 // Clean up existing auth attempt if we can no longer authenticate the | 470 // Clean up existing auth attempt if we can no longer authenticate the |
470 // remote device. | 471 // remote device. |
471 auth_attempt_.reset(); | 472 auth_attempt_.reset(); |
472 | 473 |
473 if (!handler->InStateValidOnRemoteAuthFailure()) | 474 if (!handler->InStateValidOnRemoteAuthFailure()) |
474 HandleAuthFailure(GetUserEmail()); | 475 HandleAuthFailure(GetUserID()); |
475 } | 476 } |
476 | 477 |
477 FOR_EACH_OBSERVER( | 478 FOR_EACH_OBSERVER( |
478 EasyUnlockServiceObserver, observers_, OnScreenlockStateChanged(state)); | 479 EasyUnlockServiceObserver, observers_, OnScreenlockStateChanged(state)); |
479 return true; | 480 return true; |
480 } | 481 } |
481 | 482 |
482 ScreenlockState EasyUnlockService::GetScreenlockState() { | 483 ScreenlockState EasyUnlockService::GetScreenlockState() { |
483 EasyUnlockScreenlockStateHandler* handler = GetScreenlockStateHandler(); | 484 EasyUnlockScreenlockStateHandler* handler = GetScreenlockStateHandler(); |
484 if (!handler) | 485 if (!handler) |
485 return ScreenlockState::INACTIVE; | 486 return ScreenlockState::INACTIVE; |
486 | 487 |
487 return handler->state(); | 488 return handler->state(); |
488 } | 489 } |
489 | 490 |
490 void EasyUnlockService::AttemptAuth(const std::string& user_id) { | 491 void EasyUnlockService::AttemptAuth(const user_manager::UserID& user_id) { |
491 AttemptAuth(user_id, AttemptAuthCallback()); | 492 AttemptAuth(user_id, AttemptAuthCallback()); |
492 } | 493 } |
493 | 494 |
494 void EasyUnlockService::AttemptAuth(const std::string& user_id, | 495 void EasyUnlockService::AttemptAuth(const user_manager::UserID& user_id, |
495 const AttemptAuthCallback& callback) { | 496 const AttemptAuthCallback& callback) { |
496 const EasyUnlockAuthAttempt::Type auth_attempt_type = | 497 const EasyUnlockAuthAttempt::Type auth_attempt_type = |
497 GetType() == TYPE_REGULAR ? EasyUnlockAuthAttempt::TYPE_UNLOCK | 498 GetType() == TYPE_REGULAR ? EasyUnlockAuthAttempt::TYPE_UNLOCK |
498 : EasyUnlockAuthAttempt::TYPE_SIGNIN; | 499 : EasyUnlockAuthAttempt::TYPE_SIGNIN; |
499 const std::string user_email = GetUserEmail(); | 500 const user_manager::UserID current_user_id = GetUserID(); |
500 if (user_email.empty()) { | 501 if (current_user_id.empty()) { |
501 LOG(ERROR) << "Empty user email. Refresh token might go bad."; | 502 LOG(ERROR) << "Empty user email. Refresh token might go bad."; |
502 if (!callback.is_null()) { | 503 if (!callback.is_null()) { |
503 const bool kFailure = false; | 504 const bool kFailure = false; |
504 callback.Run(auth_attempt_type, kFailure, user_id, std::string(), | 505 callback.Run(auth_attempt_type, kFailure, user_id, std::string(), |
505 std::string()); | 506 std::string()); |
506 } | 507 } |
507 return; | 508 return; |
508 } | 509 } |
509 | 510 |
510 CHECK_EQ(GetUserEmail(), user_id); | 511 CHECK_EQ(GetUserID(), user_id); |
511 | 512 |
512 auth_attempt_.reset(new EasyUnlockAuthAttempt(app_manager_.get(), user_id, | 513 auth_attempt_.reset(new EasyUnlockAuthAttempt(app_manager_.get(), user_id, |
513 auth_attempt_type, callback)); | 514 auth_attempt_type, callback)); |
514 if (!auth_attempt_->Start()) | 515 if (!auth_attempt_->Start()) |
515 auth_attempt_.reset(); | 516 auth_attempt_.reset(); |
516 } | 517 } |
517 | 518 |
518 void EasyUnlockService::FinalizeUnlock(bool success) { | 519 void EasyUnlockService::FinalizeUnlock(bool success) { |
519 if (!auth_attempt_.get()) | 520 if (!auth_attempt_.get()) |
520 return; | 521 return; |
521 | 522 |
522 this->OnWillFinalizeUnlock(success); | 523 this->OnWillFinalizeUnlock(success); |
523 auth_attempt_->FinalizeUnlock(GetUserEmail(), success); | 524 auth_attempt_->FinalizeUnlock(GetUserID(), success); |
524 auth_attempt_.reset(); | 525 auth_attempt_.reset(); |
525 // TODO(isherman): If observing screen unlock events, is there a race | 526 // TODO(isherman): If observing screen unlock events, is there a race |
526 // condition in terms of reading the service's state vs. the app setting the | 527 // condition in terms of reading the service's state vs. the app setting the |
527 // state? | 528 // state? |
528 | 529 |
529 // Make sure that the lock screen is updated on failure. | 530 // Make sure that the lock screen is updated on failure. |
530 if (!success) { | 531 if (!success) { |
531 RecordEasyUnlockScreenUnlockEvent(EASY_UNLOCK_FAILURE); | 532 RecordEasyUnlockScreenUnlockEvent(EASY_UNLOCK_FAILURE); |
532 HandleAuthFailure(GetUserEmail()); | 533 HandleAuthFailure(GetUserID()); |
533 } | 534 } |
534 } | 535 } |
535 | 536 |
536 void EasyUnlockService::FinalizeSignin(const std::string& key) { | 537 void EasyUnlockService::FinalizeSignin(const std::string& key) { |
537 if (!auth_attempt_.get()) | 538 if (!auth_attempt_.get()) |
538 return; | 539 return; |
539 std::string wrapped_secret = GetWrappedSecret(); | 540 std::string wrapped_secret = GetWrappedSecret(); |
540 if (!wrapped_secret.empty()) | 541 if (!wrapped_secret.empty()) |
541 auth_attempt_->FinalizeSignin(GetUserEmail(), wrapped_secret, key); | 542 auth_attempt_->FinalizeSignin(GetUserID(), wrapped_secret, key); |
542 auth_attempt_.reset(); | 543 auth_attempt_.reset(); |
543 | 544 |
544 // Processing empty key is equivalent to auth cancellation. In this case the | 545 // Processing empty key is equivalent to auth cancellation. In this case the |
545 // signin request will not actually be processed by login stack, so the lock | 546 // signin request will not actually be processed by login stack, so the lock |
546 // screen state should be set from here. | 547 // screen state should be set from here. |
547 if (key.empty()) | 548 if (key.empty()) |
548 HandleAuthFailure(GetUserEmail()); | 549 HandleAuthFailure(GetUserID()); |
549 } | 550 } |
550 | 551 |
551 void EasyUnlockService::HandleAuthFailure(const std::string& user_id) { | 552 void EasyUnlockService::HandleAuthFailure(const user_manager::UserID& user_id) { |
552 if (user_id != GetUserEmail()) | 553 if (user_id != GetUserID()) |
553 return; | 554 return; |
554 | 555 |
555 if (!screenlock_state_handler_.get()) | 556 if (!screenlock_state_handler_.get()) |
556 return; | 557 return; |
557 | 558 |
558 screenlock_state_handler_->SetHardlockState( | 559 screenlock_state_handler_->SetHardlockState( |
559 EasyUnlockScreenlockStateHandler::LOGIN_FAILED); | 560 EasyUnlockScreenlockStateHandler::LOGIN_FAILED); |
560 } | 561 } |
561 | 562 |
562 void EasyUnlockService::CheckCryptohomeKeysAndMaybeHardlock() { | 563 void EasyUnlockService::CheckCryptohomeKeysAndMaybeHardlock() { |
563 #if defined(OS_CHROMEOS) | 564 #if defined(OS_CHROMEOS) |
564 std::string user_id = GetUserEmail(); | 565 const user_manager::UserID user_id = GetUserID(); |
565 if (user_id.empty()) | 566 if (user_id.empty()) |
566 return; | 567 return; |
567 | 568 |
568 const base::ListValue* device_list = GetRemoteDevices(); | 569 const base::ListValue* device_list = GetRemoteDevices(); |
569 std::set<std::string> paired_devices; | 570 std::set<std::string> paired_devices; |
570 if (device_list) { | 571 if (device_list) { |
571 chromeos::EasyUnlockDeviceKeyDataList parsed_paired; | 572 chromeos::EasyUnlockDeviceKeyDataList parsed_paired; |
572 chromeos::EasyUnlockKeyManager::RemoteDeviceListToDeviceDataList( | 573 chromeos::EasyUnlockKeyManager::RemoteDeviceListToDeviceDataList( |
573 *device_list, &parsed_paired); | 574 *device_list, &parsed_paired); |
574 for (const auto& device_key_data : parsed_paired) | 575 for (const auto& device_key_data : parsed_paired) |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 #endif | 682 #endif |
682 } | 683 } |
683 } | 684 } |
684 } | 685 } |
685 | 686 |
686 void EasyUnlockService::DisableAppWithoutResettingScreenlockState() { | 687 void EasyUnlockService::DisableAppWithoutResettingScreenlockState() { |
687 app_manager_->DisableAppIfLoaded(); | 688 app_manager_->DisableAppIfLoaded(); |
688 } | 689 } |
689 | 690 |
690 void EasyUnlockService::NotifyUserUpdated() { | 691 void EasyUnlockService::NotifyUserUpdated() { |
691 std::string user_id = GetUserEmail(); | 692 const user_manager::UserID user_id = GetUserID(); |
692 if (user_id.empty()) | 693 if (user_id.empty()) |
693 return; | 694 return; |
694 | 695 |
695 // Notify the easy unlock app that the user info changed. | 696 // Notify the easy unlock app that the user info changed. |
696 bool logged_in = GetType() == TYPE_REGULAR; | 697 bool logged_in = GetType() == TYPE_REGULAR; |
697 bool data_ready = logged_in || GetRemoteDevices() != NULL; | 698 bool data_ready = logged_in || GetRemoteDevices() != NULL; |
698 app_manager_->SendUserUpdatedEvent(user_id, logged_in, data_ready); | 699 app_manager_->SendUserUpdatedEvent(user_id, logged_in, data_ready); |
699 } | 700 } |
700 | 701 |
701 void EasyUnlockService::NotifyTurnOffOperationStatusChanged() { | 702 void EasyUnlockService::NotifyTurnOffOperationStatusChanged() { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 bttype = BT_NORMAL; | 742 bttype = BT_NORMAL; |
742 } | 743 } |
743 #endif | 744 #endif |
744 } | 745 } |
745 UMA_HISTOGRAM_ENUMERATION( | 746 UMA_HISTOGRAM_ENUMERATION( |
746 "EasyUnlock.BluetoothAvailability", bttype, BT_MAX_TYPE); | 747 "EasyUnlock.BluetoothAvailability", bttype, BT_MAX_TYPE); |
747 } | 748 } |
748 } | 749 } |
749 | 750 |
750 void EasyUnlockService::SetHardlockStateForUser( | 751 void EasyUnlockService::SetHardlockStateForUser( |
751 const std::string& user_id, | 752 const user_manager::UserID& user_id, |
752 EasyUnlockScreenlockStateHandler::HardlockState state) { | 753 EasyUnlockScreenlockStateHandler::HardlockState state) { |
753 DCHECK(!user_id.empty()); | 754 DCHECK(!user_id.empty()); |
754 | 755 |
755 PrefService* local_state = GetLocalState(); | 756 PrefService* local_state = GetLocalState(); |
756 if (!local_state) | 757 if (!local_state) |
757 return; | 758 return; |
758 | 759 |
759 DictionaryPrefUpdate update(local_state, prefs::kEasyUnlockHardlockState); | 760 DictionaryPrefUpdate update(local_state, prefs::kEasyUnlockHardlockState); |
760 update->SetIntegerWithoutPathExpansion(user_id, static_cast<int>(state)); | 761 update->SetIntegerWithoutPathExpansion(user_id.GetUserEmail(), static_cast<int
>(state)); |
761 | 762 |
762 if (GetUserEmail() == user_id) | 763 if (GetUserID() == user_id) |
763 SetScreenlockHardlockedState(state); | 764 SetScreenlockHardlockedState(state); |
764 } | 765 } |
765 | 766 |
766 EasyUnlockAuthEvent EasyUnlockService::GetPasswordAuthEvent() const { | 767 EasyUnlockAuthEvent EasyUnlockService::GetPasswordAuthEvent() const { |
767 DCHECK(IsEnabled()); | 768 DCHECK(IsEnabled()); |
768 | 769 |
769 if (GetHardlockState() != EasyUnlockScreenlockStateHandler::NO_HARDLOCK) { | 770 if (GetHardlockState() != EasyUnlockScreenlockStateHandler::NO_HARDLOCK) { |
770 switch (GetHardlockState()) { | 771 switch (GetHardlockState()) { |
771 case EasyUnlockScreenlockStateHandler::NO_HARDLOCK: | 772 case EasyUnlockScreenlockStateHandler::NO_HARDLOCK: |
772 NOTREACHED(); | 773 NOTREACHED(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
812 return PASSWORD_ENTRY_WITH_AUTHENTICATED_PHONE; | 813 return PASSWORD_ENTRY_WITH_AUTHENTICATED_PHONE; |
813 } | 814 } |
814 } | 815 } |
815 | 816 |
816 NOTREACHED(); | 817 NOTREACHED(); |
817 return EASY_UNLOCK_AUTH_EVENT_COUNT; | 818 return EASY_UNLOCK_AUTH_EVENT_COUNT; |
818 } | 819 } |
819 | 820 |
820 #if defined(OS_CHROMEOS) | 821 #if defined(OS_CHROMEOS) |
821 void EasyUnlockService::OnCryptohomeKeysFetchedForChecking( | 822 void EasyUnlockService::OnCryptohomeKeysFetchedForChecking( |
822 const std::string& user_id, | 823 const user_manager::UserID& user_id, |
823 const std::set<std::string> paired_devices, | 824 const std::set<std::string> paired_devices, |
824 bool success, | 825 bool success, |
825 const chromeos::EasyUnlockDeviceKeyDataList& key_data_list) { | 826 const chromeos::EasyUnlockDeviceKeyDataList& key_data_list) { |
826 DCHECK(!user_id.empty() && !paired_devices.empty()); | 827 DCHECK(!user_id.empty() && !paired_devices.empty()); |
827 | 828 |
828 if (!success) { | 829 if (!success) { |
829 SetHardlockStateForUser(user_id, | 830 SetHardlockStateForUser(user_id, |
830 EasyUnlockScreenlockStateHandler::NO_PAIRING); | 831 EasyUnlockScreenlockStateHandler::NO_PAIRING); |
831 return; | 832 return; |
832 } | 833 } |
(...skipping 13 matching lines...) Expand all Loading... |
846 } | 847 } |
847 #endif | 848 #endif |
848 | 849 |
849 void EasyUnlockService::PrepareForSuspend() { | 850 void EasyUnlockService::PrepareForSuspend() { |
850 app_manager_->DisableAppIfLoaded(); | 851 app_manager_->DisableAppIfLoaded(); |
851 if (screenlock_state_handler_ && screenlock_state_handler_->IsActive()) | 852 if (screenlock_state_handler_ && screenlock_state_handler_->IsActive()) |
852 UpdateScreenlockState(ScreenlockState::BLUETOOTH_CONNECTING); | 853 UpdateScreenlockState(ScreenlockState::BLUETOOTH_CONNECTING); |
853 } | 854 } |
854 | 855 |
855 void EasyUnlockService::EnsureTpmKeyPresentIfNeeded() { | 856 void EasyUnlockService::EnsureTpmKeyPresentIfNeeded() { |
856 if (tpm_key_checked_ || GetType() != TYPE_REGULAR || GetUserEmail().empty() || | 857 if (tpm_key_checked_ || GetType() != TYPE_REGULAR || GetUserID().empty() || |
857 GetHardlockState() == EasyUnlockScreenlockStateHandler::NO_PAIRING) { | 858 GetHardlockState() == EasyUnlockScreenlockStateHandler::NO_PAIRING) { |
858 return; | 859 return; |
859 } | 860 } |
860 | 861 |
861 #if defined(OS_CHROMEOS) | 862 #if defined(OS_CHROMEOS) |
862 // If this is called before the session is started, the chances are Chrome | 863 // If this is called before the session is started, the chances are Chrome |
863 // is restarting in order to apply user flags. Don't check TPM keys in this | 864 // is restarting in order to apply user flags. Don't check TPM keys in this |
864 // case. | 865 // case. |
865 if (!user_manager::UserManager::Get() || | 866 if (!user_manager::UserManager::Get() || |
866 !user_manager::UserManager::Get()->IsSessionStarted()) | 867 !user_manager::UserManager::Get()->IsSessionStarted()) |
867 return; | 868 return; |
868 | 869 |
869 // TODO(tbarzic): Set check_private_key only if previous sign-in attempt | 870 // TODO(tbarzic): Set check_private_key only if previous sign-in attempt |
870 // failed. | 871 // failed. |
871 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile_) | 872 EasyUnlockTpmKeyManagerFactory::GetInstance()->Get(profile_) |
872 ->PrepareTpmKey(true /* check_private_key */, | 873 ->PrepareTpmKey(true /* check_private_key */, |
873 base::Closure()); | 874 base::Closure()); |
874 #endif // defined(OS_CHROMEOS) | 875 #endif // defined(OS_CHROMEOS) |
875 | 876 |
876 tpm_key_checked_ = true; | 877 tpm_key_checked_ = true; |
877 } | 878 } |
OLD | NEW |