Index: chrome/browser/chromeos/login/easy_unlock/easy_unlock_refresh_keys_operation.cc |
diff --git a/chrome/browser/chromeos/login/easy_unlock/easy_unlock_refresh_keys_operation.cc b/chrome/browser/chromeos/login/easy_unlock/easy_unlock_refresh_keys_operation.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..c0863c56d4a8ad24d7451a119a05a354ce0e2acc |
--- /dev/null |
+++ b/chrome/browser/chromeos/login/easy_unlock/easy_unlock_refresh_keys_operation.cc |
@@ -0,0 +1,62 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "base/bind.h" |
+#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_create_keys_operation.h" |
+#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_refresh_keys_operation.h" |
+#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_remove_keys_operation.h" |
+ |
+namespace chromeos { |
+ |
+EasyUnlockRefreshKeysOperation::EasyUnlockRefreshKeysOperation( |
+ const UserContext& user_context, |
+ const std::string& tpm_public_key, |
+ const EasyUnlockDeviceKeyDataList& devices, |
+ const RefreshKeysCallback& callback) |
+ : user_context_(user_context), |
+ tpm_public_key_(tpm_public_key), |
+ devices_(devices), |
+ callback_(callback), |
+ weak_ptr_factory_(this) { |
+} |
+ |
+EasyUnlockRefreshKeysOperation::~EasyUnlockRefreshKeysOperation() { |
+} |
+ |
+void EasyUnlockRefreshKeysOperation::Start() { |
+ if (devices_.empty()) { |
+ OnKeysCreated(true); |
+ return; |
+ } |
+ |
+ create_keys_operation_.reset(new EasyUnlockCreateKeysOperation( |
+ user_context_, tpm_public_key_, devices_, |
+ base::Bind(&EasyUnlockRefreshKeysOperation::OnKeysCreated, |
+ weak_ptr_factory_.GetWeakPtr()))); |
+ create_keys_operation_->Start(); |
+} |
+ |
+void EasyUnlockRefreshKeysOperation::OnKeysCreated(bool success) { |
+ if (!success) { |
+ callback_.Run(false); |
+ return; |
+ } |
+ |
+ // Update the user context to have the new authorization keys after the create |
+ // keys operation. |
+ if (create_keys_operation_) |
+ user_context_ = create_keys_operation_->user_context(); |
+ |
+ remove_keys_operation_.reset(new EasyUnlockRemoveKeysOperation( |
+ user_context_, devices_.size(), |
+ base::Bind(&EasyUnlockRefreshKeysOperation::OnKeysRemoved, |
+ weak_ptr_factory_.GetWeakPtr()))); |
+ remove_keys_operation_->Start(); |
+} |
+ |
+void EasyUnlockRefreshKeysOperation::OnKeysRemoved(bool success) { |
+ callback_.Run(success); |
+} |
+ |
+} // namespace chromeos |