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 EasyUnlockDeviceKeyDataList& devices, |
| 15 const RefreshKeysCallback& callback) |
| 16 : user_context_(user_context), |
| 17 devices_(devices), |
| 18 callback_(callback), |
| 19 weak_ptr_factory_(this) { |
| 20 } |
| 21 |
| 22 EasyUnlockRefreshKeysOperation::~EasyUnlockRefreshKeysOperation() { |
| 23 } |
| 24 |
| 25 void EasyUnlockRefreshKeysOperation::Start() { |
| 26 if (devices_.empty()) { |
| 27 OnKeysCreated(true); |
| 28 return; |
| 29 } |
| 30 |
| 31 create_keys_operation_.reset(new EasyUnlockCreateKeysOperation( |
| 32 user_context_, devices_, |
| 33 base::Bind(&EasyUnlockRefreshKeysOperation::OnKeysCreated, |
| 34 weak_ptr_factory_.GetWeakPtr()))); |
| 35 create_keys_operation_->Start(); |
| 36 } |
| 37 |
| 38 void EasyUnlockRefreshKeysOperation::OnKeysCreated(bool success) { |
| 39 if (!success) { |
| 40 callback_.Run(false); |
| 41 return; |
| 42 } |
| 43 |
| 44 remove_keys_operation_.reset(new EasyUnlockRemoveKeysOperation( |
| 45 user_context_, devices_.size(), |
| 46 base::Bind(&EasyUnlockRefreshKeysOperation::OnKeysRemoved, |
| 47 weak_ptr_factory_.GetWeakPtr()))); |
| 48 remove_keys_operation_->Start(); |
| 49 } |
| 50 |
| 51 void EasyUnlockRefreshKeysOperation::OnKeysRemoved(bool success) { |
| 52 callback_.Run(success); |
| 53 } |
| 54 |
| 55 } // namespace chromeos |
OLD | NEW |