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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_REFRESH_KEYS_OPERATION_H_ 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_REFRESH_KEYS_OPERATION_H_ 7 8 #include <string> 9 10 #include "base/callback.h" 11 #include "base/macros.h" 12 #include "base/memory/weak_ptr.h" 13 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_types.h" 14 #include "chromeos/login/auth/user_context.h" 15 16 namespace chromeos { 17 18 class EasyUnlockCreateKeysOperation; 19 class EasyUnlockRemoveKeysOperation; 20 class UserContext; 21 22 // The refresh keys operation replaces the existing keys in cryptohome with a 23 // new list of keys. This operation is a simple sequence of the create and 24 // remove keys operations. 25 class EasyUnlockRefreshKeysOperation { 26 public: 27 typedef base::Callback<void(bool success)> RefreshKeysCallback; 28 EasyUnlockRefreshKeysOperation(const UserContext& user_context, 29 const std::string& tpm_public_key, 30 const EasyUnlockDeviceKeyDataList& devices, 31 const RefreshKeysCallback& callback); 32 ~EasyUnlockRefreshKeysOperation(); 33 34 void Start(); 35 36 private: 37 void OnKeysCreated(bool success); 38 void RemoveKeysStartingFromIndex(size_t key_index); 39 void OnKeysRemoved(bool success); 40 41 UserContext user_context_; 42 std::string tpm_public_key_; 43 EasyUnlockDeviceKeyDataList devices_; 44 RefreshKeysCallback callback_; 45 46 std::unique_ptr<EasyUnlockCreateKeysOperation> create_keys_operation_; 47 std::unique_ptr<EasyUnlockRemoveKeysOperation> remove_keys_operation_; 48 49 base::WeakPtrFactory<EasyUnlockRefreshKeysOperation> weak_ptr_factory_{this}; 50 51 DISALLOW_COPY_AND_ASSIGN(EasyUnlockRefreshKeysOperation); 52 }; 53 54 } // namespace chromeos 55 56 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_REFRESH_KEYS_OPERATION_H_ 57