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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 chromeos::EasyUnlockKeyManager::RemoteDeviceListToDeviceDataList( | 355 chromeos::EasyUnlockKeyManager::RemoteDeviceListToDeviceDataList( |
| 356 *device_list, &parsed_paired); | 356 *device_list, &parsed_paired); |
| 357 for (const auto& device_key_data : parsed_paired) | 357 for (const auto& device_key_data : parsed_paired) |
| 358 paired_devices.insert(device_key_data.public_key); | 358 paired_devices.insert(device_key_data.public_key); |
| 359 } | 359 } |
| 360 if (paired_devices.empty()) { | 360 if (paired_devices.empty()) { |
| 361 SetHardlockState(EasyUnlockScreenlockStateHandler::NO_PAIRING); | 361 SetHardlockState(EasyUnlockScreenlockStateHandler::NO_PAIRING); |
| 362 return; | 362 return; |
| 363 } | 363 } |
| 364 | 364 |
| 365 // No need to compare if a change is already recorded. | |
| 366 if (GetHardlockState() == EasyUnlockScreenlockStateHandler::PAIRING_CHANGED) | |
| 367 return; | |
| 368 | |
| 369 chromeos::EasyUnlockKeyManager* key_manager = | 365 chromeos::EasyUnlockKeyManager* key_manager = |
| 370 chromeos::UserSessionManager::GetInstance()->GetEasyUnlockKeyManager(); | 366 chromeos::UserSessionManager::GetInstance()->GetEasyUnlockKeyManager(); |
| 371 DCHECK(key_manager); | 367 DCHECK(key_manager); |
| 372 | 368 |
| 373 key_manager->GetDeviceDataList( | 369 key_manager->GetDeviceDataList( |
| 374 chromeos::UserContext(user_id), | 370 chromeos::UserContext(user_id), |
| 375 base::Bind(&EasyUnlockService::OnCryptohomeKeysFetchedForChecking, | 371 base::Bind(&EasyUnlockService::OnCryptohomeKeysFetchedForChecking, |
| 376 weak_ptr_factory_.GetWeakPtr(), | 372 weak_ptr_factory_.GetWeakPtr(), |
| 377 user_id, | 373 user_id, |
| 378 paired_devices)); | 374 paired_devices)); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 585 if (!success) { | 581 if (!success) { |
| 586 SetHardlockStateForUser(user_id, | 582 SetHardlockStateForUser(user_id, |
| 587 EasyUnlockScreenlockStateHandler::NO_PAIRING); | 583 EasyUnlockScreenlockStateHandler::NO_PAIRING); |
| 588 return; | 584 return; |
| 589 } | 585 } |
| 590 | 586 |
| 591 std::set<std::string> devices_in_cryptohome; | 587 std::set<std::string> devices_in_cryptohome; |
| 592 for (const auto& device_key_data : key_data_list) | 588 for (const auto& device_key_data : key_data_list) |
| 593 devices_in_cryptohome.insert(device_key_data.public_key); | 589 devices_in_cryptohome.insert(device_key_data.public_key); |
| 594 | 590 |
| 595 if (paired_devices != devices_in_cryptohome || | 591 if (paired_devices == devices_in_cryptohome) { |
|
tbarzic
2014/10/27 21:44:43
I don't think this is the right thing to do in gen
xiyuan
2014/10/28 20:38:03
For 1, maybe we should consider using psk instead
Tim Song
2014/10/31 17:57:37
For 1, I did as Xiyuan suggested and made the chec
tbarzic
2014/10/31 18:24:09
cryptohome keys are actually cleared on the next u
Tim Song
2014/11/01 03:16:52
Okay that makes sense. I changed the hardlock stat
| |
| 596 GetHardlockState() == EasyUnlockScreenlockStateHandler::NO_PAIRING) { | 592 if (GetHardlockState() != EasyUnlockScreenlockStateHandler::USER_HARDLOCK) { |
| 593 SetHardlockStateForUser(user_id, | |
| 594 EasyUnlockScreenlockStateHandler::NO_HARDLOCK); | |
| 595 } | |
| 596 } else { | |
| 597 SetHardlockStateForUser(user_id, | 597 SetHardlockStateForUser(user_id, |
| 598 EasyUnlockScreenlockStateHandler::PAIRING_CHANGED); | 598 EasyUnlockScreenlockStateHandler::PAIRING_CHANGED); |
| 599 } | 599 } |
| 600 } | 600 } |
| 601 #endif | 601 #endif |
| 602 | 602 |
| 603 void EasyUnlockService::PrepareForSuspend() { | 603 void EasyUnlockService::PrepareForSuspend() { |
| 604 DisableAppIfLoaded(); | 604 DisableAppIfLoaded(); |
| 605 if (screenlock_state_handler_ && screenlock_state_handler_->IsActive()) { | 605 if (screenlock_state_handler_ && screenlock_state_handler_->IsActive()) { |
| 606 UpdateScreenlockState( | 606 UpdateScreenlockState( |
| 607 EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING); | 607 EasyUnlockScreenlockStateHandler::STATE_BLUETOOTH_CONNECTING); |
| 608 } | 608 } |
| 609 } | 609 } |
| 610 | 610 |
| OLD | NEW |