| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/bind.h" | |
| 6 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_create_keys_oper
ation.h" | |
| 7 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_refresh_keys_ope
ration.h" | |
| 8 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_remove_keys_oper
ation.h" | |
| 9 | |
| 10 namespace chromeos { | |
| 11 | |
| 12 EasyUnlockRefreshKeysOperation::EasyUnlockRefreshKeysOperation( | |
| 13 const UserContext& user_context, | |
| 14 const std::string& tpm_public_key, | |
| 15 const EasyUnlockDeviceKeyDataList& devices, | |
| 16 const RefreshKeysCallback& callback) | |
| 17 : user_context_(user_context), | |
| 18 tpm_public_key_(tpm_public_key), | |
| 19 devices_(devices), | |
| 20 callback_(callback), | |
| 21 weak_ptr_factory_(this) { | |
| 22 } | |
| 23 | |
| 24 EasyUnlockRefreshKeysOperation::~EasyUnlockRefreshKeysOperation() { | |
| 25 } | |
| 26 | |
| 27 void EasyUnlockRefreshKeysOperation::Start() { | |
| 28 if (devices_.empty()) { | |
| 29 OnKeysCreated(true); | |
| 30 return; | |
| 31 } | |
| 32 | |
| 33 create_keys_operation_.reset(new EasyUnlockCreateKeysOperation( | |
| 34 user_context_, tpm_public_key_, devices_, | |
| 35 base::Bind(&EasyUnlockRefreshKeysOperation::OnKeysCreated, | |
| 36 weak_ptr_factory_.GetWeakPtr()))); | |
| 37 create_keys_operation_->Start(); | |
| 38 } | |
| 39 | |
| 40 void EasyUnlockRefreshKeysOperation::OnKeysCreated(bool success) { | |
| 41 if (!success) { | |
| 42 callback_.Run(false); | |
| 43 return; | |
| 44 } | |
| 45 | |
| 46 // Update the user context to have the new authorization key after the create | |
| 47 // keys operation. This is necessary because the old authorization key | |
| 48 // associated with the user context will be invalidated after the create keys | |
| 49 // operation. | |
| 50 if (create_keys_operation_) | |
| 51 user_context_ = create_keys_operation_->user_context(); | |
| 52 | |
| 53 remove_keys_operation_.reset(new EasyUnlockRemoveKeysOperation( | |
| 54 user_context_, devices_.size(), | |
| 55 base::Bind(&EasyUnlockRefreshKeysOperation::OnKeysRemoved, | |
| 56 weak_ptr_factory_.GetWeakPtr()))); | |
| 57 remove_keys_operation_->Start(); | |
| 58 } | |
| 59 | |
| 60 void EasyUnlockRefreshKeysOperation::OnKeysRemoved(bool success) { | |
| 61 callback_.Run(success); | |
| 62 } | |
| 63 | |
| 64 } // namespace chromeos | |
| OLD | NEW |