| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_CREATE_KEYS_OPERAT
ION_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_CREATE_KEYS_OPERAT
ION_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_CREATE_KEYS_OPERAT
ION_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_CREATE_KEYS_OPERAT
ION_H_ |
| 7 | 7 |
| 8 #include <string> |
| 9 |
| 8 #include "base/callback.h" | 10 #include "base/callback.h" |
| 9 #include "base/macros.h" | 11 #include "base/macros.h" |
| 10 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 11 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_types.h" | 13 #include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_types.h" |
| 12 #include "chromeos/login/auth/user_context.h" | 14 #include "chromeos/login/auth/user_context.h" |
| 13 #include "third_party/cros_system_api/dbus/service_constants.h" | 15 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 14 | 16 |
| 15 namespace chromeos { | 17 namespace chromeos { |
| 16 | 18 |
| 17 class UserContext; | 19 class UserContext; |
| 18 | 20 |
| 19 // A class to create Easy unlock cryptohome keys for the given user and devices. | 21 // A class to create Easy unlock cryptohome keys for the given user and devices. |
| 20 class EasyUnlockCreateKeysOperation { | 22 class EasyUnlockCreateKeysOperation { |
| 21 public: | 23 public: |
| 22 typedef base::Callback<void (bool success)> CreateKeysCallback; | 24 typedef base::Callback<void (bool success)> CreateKeysCallback; |
| 23 EasyUnlockCreateKeysOperation( | 25 EasyUnlockCreateKeysOperation( |
| 24 const UserContext& user_context, | 26 const UserContext& user_context, |
| 25 const EasyUnlockDeviceKeyDataList& devices, | 27 const EasyUnlockDeviceKeyDataList& devices, |
| 26 const CreateKeysCallback& callback); | 28 const CreateKeysCallback& callback); |
| 27 ~EasyUnlockCreateKeysOperation(); | 29 ~EasyUnlockCreateKeysOperation(); |
| 28 | 30 |
| 29 void Start(); | 31 void Start(); |
| 30 | 32 |
| 33 const UserContext& user_context() const { return user_context_; } |
| 34 |
| 31 private: | 35 private: |
| 32 class ChallengeCreator; | 36 class ChallengeCreator; |
| 33 | 37 |
| 34 void CreateKeyForDeviceAtIndex(size_t index); | 38 void CreateKeyForDeviceAtIndex(size_t index); |
| 35 void OnChallengeCreated(size_t index, bool success); | 39 void OnChallengeCreated(size_t index, bool success); |
| 36 void OnGetSystemSalt(size_t index, | 40 void OnGetSystemSalt(size_t index, |
| 37 const std::string& system_salt); | 41 const std::string& system_salt); |
| 38 void OnKeyCreated(size_t index, | 42 void OnKeyCreated(size_t index, |
| 43 const Key& user_key, |
| 39 bool success, | 44 bool success, |
| 40 cryptohome::MountError return_code); | 45 cryptohome::MountError return_code); |
| 41 | 46 |
| 42 UserContext user_context_; | 47 UserContext user_context_; |
| 43 EasyUnlockDeviceKeyDataList devices_; | 48 EasyUnlockDeviceKeyDataList devices_; |
| 44 CreateKeysCallback callback_; | 49 CreateKeysCallback callback_; |
| 45 | 50 |
| 46 // Index of the key to be created. | 51 // Index of the key to be created. |
| 47 size_t key_creation_index_; | 52 size_t key_creation_index_; |
| 48 | 53 |
| 49 scoped_ptr<ChallengeCreator> challenge_creator_; | 54 scoped_ptr<ChallengeCreator> challenge_creator_; |
| 50 | 55 |
| 51 base::WeakPtrFactory<EasyUnlockCreateKeysOperation> weak_ptr_factory_; | 56 base::WeakPtrFactory<EasyUnlockCreateKeysOperation> weak_ptr_factory_; |
| 52 | 57 |
| 53 DISALLOW_COPY_AND_ASSIGN(EasyUnlockCreateKeysOperation); | 58 DISALLOW_COPY_AND_ASSIGN(EasyUnlockCreateKeysOperation); |
| 54 }; | 59 }; |
| 55 | 60 |
| 56 } // namespace chromeos | 61 } // namespace chromeos |
| 57 | 62 |
| 58 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_CREATE_KEYS_OPE
RATION_H_ | 63 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_CREATE_KEYS_OPE
RATION_H_ |
| OLD | NEW |