Chromium Code Reviews| 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..f99cf4d3b094ac83c61adf33f933926a5c9207fd |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/login/easy_unlock/easy_unlock_refresh_keys_operation.cc |
| @@ -0,0 +1,55 @@ |
| +// 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 EasyUnlockDeviceKeyDataList& devices, |
| + const RefreshKeysCallback& callback) |
| + : user_context_(user_context), |
| + 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_, devices_, |
| + base::Bind(&EasyUnlockRefreshKeysOperation::OnKeysCreated, |
| + weak_ptr_factory_.GetWeakPtr()))); |
| + create_keys_operation_->Start(); |
| +} |
| + |
| +void EasyUnlockRefreshKeysOperation::OnKeysCreated(bool success) { |
| + if (!success) { |
| + callback_.Run(false); |
| + return; |
| + } |
| + |
| + remove_keys_operation_.reset(new EasyUnlockRemoveKeysOperation( |
| + user_context_, devices_.size(), |
|
xiyuan
2014/12/17 00:23:14
Think we need to follow existing code to use the u
Tim Song
2014/12/17 02:05:14
Hmm... I tested this and easy sign-in still works
xiyuan
2014/12/17 03:26:33
This works now because we have one and only one ke
Tim Song
2014/12/17 20:57:57
Done.
|
| + base::Bind(&EasyUnlockRefreshKeysOperation::OnKeysRemoved, |
| + weak_ptr_factory_.GetWeakPtr()))); |
| + remove_keys_operation_->Start(); |
| +} |
| + |
| +void EasyUnlockRefreshKeysOperation::OnKeysRemoved(bool success) { |
| + callback_.Run(success); |
| +} |
| + |
| +} // namespace chromeos |