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.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_CREATE_KEYS_OPERATION_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_CREATE_KEYS_OPERATION_H_
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 #include "third_party/cros_system_api/dbus/service_constants.h"
21 // A class to create Easy unlock cryptohome keys for the given user and devices.
22 class EasyUnlockCreateKeysOperation
{
24 typedef base::Callback
<void (bool success
)> CreateKeysCallback
;
25 EasyUnlockCreateKeysOperation(
26 const UserContext
& user_context
,
27 const std::string
& tpm_public_key
,
28 const EasyUnlockDeviceKeyDataList
& devices
,
29 const CreateKeysCallback
& callback
);
30 ~EasyUnlockCreateKeysOperation();
34 // The UserContext returned will contain the new key if called after the
35 // operation has completed successfully.
36 const UserContext
& user_context() const { return user_context_
; }
39 class ChallengeCreator
;
41 void CreateKeyForDeviceAtIndex(size_t index
);
42 void OnChallengeCreated(size_t index
, bool success
);
43 void OnGetSystemSalt(size_t index
,
44 const std::string
& system_salt
);
45 void OnKeyCreated(size_t index
,
48 cryptohome::MountError return_code
);
50 UserContext user_context_
;
51 std::string tpm_public_key_
;
52 EasyUnlockDeviceKeyDataList devices_
;
53 CreateKeysCallback callback_
;
55 // Index of the key to be created.
56 size_t key_creation_index_
;
58 scoped_ptr
<ChallengeCreator
> challenge_creator_
;
60 base::WeakPtrFactory
<EasyUnlockCreateKeysOperation
> weak_ptr_factory_
;
62 DISALLOW_COPY_AND_ASSIGN(EasyUnlockCreateKeysOperation
);
65 } // namespace chromeos
67 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_EASY_UNLOCK_CREATE_KEYS_OPERATION_H_