Chromium Code Reviews| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 376 if (user_id.empty()) | 376 if (user_id.empty()) |
| 377 return; | 377 return; |
| 378 | 378 |
| 379 const base::ListValue* device_list = GetRemoteDevices(); | 379 const base::ListValue* device_list = GetRemoteDevices(); |
| 380 std::set<std::string> paired_devices; | 380 std::set<std::string> paired_devices; |
| 381 if (device_list) { | 381 if (device_list) { |
| 382 chromeos::EasyUnlockDeviceKeyDataList parsed_paired; | 382 chromeos::EasyUnlockDeviceKeyDataList parsed_paired; |
| 383 chromeos::EasyUnlockKeyManager::RemoteDeviceListToDeviceDataList( | 383 chromeos::EasyUnlockKeyManager::RemoteDeviceListToDeviceDataList( |
| 384 *device_list, &parsed_paired); | 384 *device_list, &parsed_paired); |
| 385 for (const auto& device_key_data : parsed_paired) | 385 for (const auto& device_key_data : parsed_paired) |
| 386 paired_devices.insert(device_key_data.public_key); | 386 paired_devices.insert(device_key_data.psk); |
| 387 } | 387 } |
| 388 if (paired_devices.empty()) { | 388 if (paired_devices.empty()) { |
| 389 SetHardlockState(EasyUnlockScreenlockStateHandler::NO_PAIRING); | 389 SetHardlockState(EasyUnlockScreenlockStateHandler::NO_PAIRING); |
| 390 return; | 390 return; |
| 391 } | 391 } |
| 392 | 392 |
| 393 // No need to compare if a change is already recorded. | |
| 394 if (GetHardlockState() == EasyUnlockScreenlockStateHandler::PAIRING_CHANGED) | |
|
tbarzic
2014/11/01 23:21:45
can we add this back now?
Tim Song
2014/11/03 19:10:43
Done.
| |
| 395 return; | |
| 396 | |
| 397 chromeos::EasyUnlockKeyManager* key_manager = | 393 chromeos::EasyUnlockKeyManager* key_manager = |
| 398 chromeos::UserSessionManager::GetInstance()->GetEasyUnlockKeyManager(); | 394 chromeos::UserSessionManager::GetInstance()->GetEasyUnlockKeyManager(); |
| 399 DCHECK(key_manager); | 395 DCHECK(key_manager); |
| 400 | 396 |
| 401 key_manager->GetDeviceDataList( | 397 key_manager->GetDeviceDataList( |
| 402 chromeos::UserContext(user_id), | 398 chromeos::UserContext(user_id), |
| 403 base::Bind(&EasyUnlockService::OnCryptohomeKeysFetchedForChecking, | 399 base::Bind(&EasyUnlockService::OnCryptohomeKeysFetchedForChecking, |
| 404 weak_ptr_factory_.GetWeakPtr(), | 400 weak_ptr_factory_.GetWeakPtr(), |
| 405 user_id, | 401 user_id, |
| 406 paired_devices)); | 402 paired_devices)); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 611 DCHECK(!user_id.empty() && !paired_devices.empty()); | 607 DCHECK(!user_id.empty() && !paired_devices.empty()); |
| 612 | 608 |
| 613 if (!success) { | 609 if (!success) { |
| 614 SetHardlockStateForUser(user_id, | 610 SetHardlockStateForUser(user_id, |
| 615 EasyUnlockScreenlockStateHandler::NO_PAIRING); | 611 EasyUnlockScreenlockStateHandler::NO_PAIRING); |
| 616 return; | 612 return; |
| 617 } | 613 } |
| 618 | 614 |
| 619 std::set<std::string> devices_in_cryptohome; | 615 std::set<std::string> devices_in_cryptohome; |
| 620 for (const auto& device_key_data : key_data_list) | 616 for (const auto& device_key_data : key_data_list) |
| 621 devices_in_cryptohome.insert(device_key_data.public_key); | 617 devices_in_cryptohome.insert(device_key_data.psk); |
| 622 | 618 |
| 623 if (paired_devices != devices_in_cryptohome || | 619 if (paired_devices != devices_in_cryptohome || |
| 624 GetHardlockState() == EasyUnlockScreenlockStateHandler::NO_PAIRING) { | 620 GetHardlockState() == EasyUnlockScreenlockStateHandler::NO_PAIRING) { |
| 625 SetHardlockStateForUser(user_id, | 621 SetHardlockStateForUser(user_id, |
| 626 EasyUnlockScreenlockStateHandler::PAIRING_CHANGED); | 622 EasyUnlockScreenlockStateHandler::PAIRING_CHANGED); |
| 627 } | 623 } |
| 628 } | 624 } |
| 629 #endif | 625 #endif |
| 630 | 626 |
| 631 void EasyUnlockService::PrepareForSuspend() { | 627 void EasyUnlockService::PrepareForSuspend() { |
| 632 DisableAppIfLoaded(); | 628 DisableAppIfLoaded(); |
| 633 if (screenlock_state_handler_ && screenlock_state_handler_->IsActive()) { | 629 if (screenlock_state_handler_ && screenlock_state_handler_->IsActive()) { |
| 634 UpdateScreenlockState( | 630 UpdateScreenlockState( |
| 635 EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING); | 631 EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING); |
| 636 } | 632 } |
| 637 } | 633 } |
| 638 | 634 |
| OLD | NEW |