OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 CHROMEOS_DBUS_FAKE_CRYPTOHOME_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_FAKE_CRYPTOHOME_CLIENT_H_ |
6 #define CHROMEOS_DBUS_FAKE_CRYPTOHOME_CLIENT_H_ | 6 #define CHROMEOS_DBUS_FAKE_CRYPTOHOME_CLIENT_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <map> | 10 #include <map> |
9 | 11 |
10 #include "base/basictypes.h" | 12 #include "base/macros.h" |
11 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
12 #include "chromeos/dbus/cryptohome_client.h" | 14 #include "chromeos/dbus/cryptohome_client.h" |
13 | 15 |
14 namespace chromeos { | 16 namespace chromeos { |
15 | 17 |
16 class CHROMEOS_EXPORT FakeCryptohomeClient : public CryptohomeClient { | 18 class CHROMEOS_EXPORT FakeCryptohomeClient : public CryptohomeClient { |
17 public: | 19 public: |
18 FakeCryptohomeClient(); | 20 FakeCryptohomeClient(); |
19 ~FakeCryptohomeClient() override; | 21 ~FakeCryptohomeClient() override; |
20 | 22 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 void TpmCanAttemptOwnership(const VoidDBusMethodCallback& callback) override; | 66 void TpmCanAttemptOwnership(const VoidDBusMethodCallback& callback) override; |
65 void TpmClearStoredPassword(const VoidDBusMethodCallback& callback) override; | 67 void TpmClearStoredPassword(const VoidDBusMethodCallback& callback) override; |
66 bool CallTpmClearStoredPasswordAndBlock() override; | 68 bool CallTpmClearStoredPasswordAndBlock() override; |
67 void Pkcs11IsTpmTokenReady(const BoolDBusMethodCallback& callback) override; | 69 void Pkcs11IsTpmTokenReady(const BoolDBusMethodCallback& callback) override; |
68 void Pkcs11GetTpmTokenInfo( | 70 void Pkcs11GetTpmTokenInfo( |
69 const Pkcs11GetTpmTokenInfoCallback& callback) override; | 71 const Pkcs11GetTpmTokenInfoCallback& callback) override; |
70 void Pkcs11GetTpmTokenInfoForUser( | 72 void Pkcs11GetTpmTokenInfoForUser( |
71 const std::string& username, | 73 const std::string& username, |
72 const Pkcs11GetTpmTokenInfoCallback& callback) override; | 74 const Pkcs11GetTpmTokenInfoCallback& callback) override; |
73 bool InstallAttributesGet(const std::string& name, | 75 bool InstallAttributesGet(const std::string& name, |
74 std::vector<uint8>* value, | 76 std::vector<uint8_t>* value, |
75 bool* successful) override; | 77 bool* successful) override; |
76 bool InstallAttributesSet(const std::string& name, | 78 bool InstallAttributesSet(const std::string& name, |
77 const std::vector<uint8>& value, | 79 const std::vector<uint8_t>& value, |
78 bool* successful) override; | 80 bool* successful) override; |
79 bool InstallAttributesFinalize(bool* successful) override; | 81 bool InstallAttributesFinalize(bool* successful) override; |
80 void InstallAttributesIsReady( | 82 void InstallAttributesIsReady( |
81 const BoolDBusMethodCallback& callback) override; | 83 const BoolDBusMethodCallback& callback) override; |
82 bool InstallAttributesIsInvalid(bool* is_invalid) override; | 84 bool InstallAttributesIsInvalid(bool* is_invalid) override; |
83 bool InstallAttributesIsFirstInstall(bool* is_first_install) override; | 85 bool InstallAttributesIsFirstInstall(bool* is_first_install) override; |
84 void TpmAttestationIsPrepared( | 86 void TpmAttestationIsPrepared( |
85 const BoolDBusMethodCallback& callback) override; | 87 const BoolDBusMethodCallback& callback) override; |
86 void TpmAttestationIsEnrolled( | 88 void TpmAttestationIsEnrolled( |
87 const BoolDBusMethodCallback& callback) override; | 89 const BoolDBusMethodCallback& callback) override; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 void SetServiceIsAvailable(bool is_available); | 190 void SetServiceIsAvailable(bool is_available); |
189 | 191 |
190 // Sets the unmount result of Unmount() call. | 192 // Sets the unmount result of Unmount() call. |
191 void set_unmount_result(bool result) { | 193 void set_unmount_result(bool result) { |
192 unmount_result_ = result; | 194 unmount_result_ = result; |
193 } | 195 } |
194 | 196 |
195 // Sets the system salt which will be returned from GetSystemSalt(). By | 197 // Sets the system salt which will be returned from GetSystemSalt(). By |
196 // default, GetSystemSalt() returns the value generated by | 198 // default, GetSystemSalt() returns the value generated by |
197 // GetStubSystemSalt(). | 199 // GetStubSystemSalt(). |
198 void set_system_salt(const std::vector<uint8>& system_salt) { | 200 void set_system_salt(const std::vector<uint8_t>& system_salt) { |
199 system_salt_ = system_salt; | 201 system_salt_ = system_salt; |
200 } | 202 } |
201 | 203 |
202 // Returns the stub system salt as raw bytes. (not as a string encoded in the | 204 // Returns the stub system salt as raw bytes. (not as a string encoded in the |
203 // format used by SystemSaltGetter::ConvertRawSaltToHexString()). | 205 // format used by SystemSaltGetter::ConvertRawSaltToHexString()). |
204 static std::vector<uint8> GetStubSystemSalt(); | 206 static std::vector<uint8_t> GetStubSystemSalt(); |
205 | 207 |
206 private: | 208 private: |
207 void ReturnProtobufMethodCallback( | 209 void ReturnProtobufMethodCallback( |
208 const cryptohome::BaseReply& reply, | 210 const cryptohome::BaseReply& reply, |
209 const ProtobufMethodCallback& callback); | 211 const ProtobufMethodCallback& callback); |
210 | 212 |
211 // Posts tasks which return fake results to the UI thread. | 213 // Posts tasks which return fake results to the UI thread. |
212 void ReturnAsyncMethodResult(const AsyncMethodCallback& callback, | 214 void ReturnAsyncMethodResult(const AsyncMethodCallback& callback, |
213 bool returns_data); | 215 bool returns_data); |
214 | 216 |
215 // This method is used to implement ReturnAsyncMethodResult. | 217 // This method is used to implement ReturnAsyncMethodResult. |
216 void ReturnAsyncMethodResultInternal(const AsyncMethodCallback& callback, | 218 void ReturnAsyncMethodResultInternal(const AsyncMethodCallback& callback, |
217 bool returns_data); | 219 bool returns_data); |
218 | 220 |
219 bool service_is_available_; | 221 bool service_is_available_; |
220 int async_call_id_; | 222 int async_call_id_; |
221 AsyncCallStatusHandler async_call_status_handler_; | 223 AsyncCallStatusHandler async_call_status_handler_; |
222 AsyncCallStatusWithDataHandler async_call_status_data_handler_; | 224 AsyncCallStatusWithDataHandler async_call_status_data_handler_; |
223 bool unmount_result_; | 225 bool unmount_result_; |
224 std::vector<uint8> system_salt_; | 226 std::vector<uint8_t> system_salt_; |
225 | 227 |
226 std::vector<WaitForServiceToBeAvailableCallback> | 228 std::vector<WaitForServiceToBeAvailableCallback> |
227 pending_wait_for_service_to_be_available_callbacks_; | 229 pending_wait_for_service_to_be_available_callbacks_; |
228 | 230 |
229 // A stub store for InstallAttributes, mapping an attribute name to the | 231 // A stub store for InstallAttributes, mapping an attribute name to the |
230 // associated data blob. Used to implement InstallAttributesSet and -Get. | 232 // associated data blob. Used to implement InstallAttributesSet and -Get. |
231 std::map<std::string, std::vector<uint8> > install_attrs_; | 233 std::map<std::string, std::vector<uint8_t>> install_attrs_; |
232 bool locked_; | 234 bool locked_; |
233 base::WeakPtrFactory<FakeCryptohomeClient> weak_ptr_factory_; | 235 base::WeakPtrFactory<FakeCryptohomeClient> weak_ptr_factory_; |
234 | 236 |
235 DISALLOW_COPY_AND_ASSIGN(FakeCryptohomeClient); | 237 DISALLOW_COPY_AND_ASSIGN(FakeCryptohomeClient); |
236 }; | 238 }; |
237 | 239 |
238 } // namespace chromeos | 240 } // namespace chromeos |
239 | 241 |
240 #endif // CHROMEOS_DBUS_FAKE_CRYPTOHOME_CLIENT_H_ | 242 #endif // CHROMEOS_DBUS_FAKE_CRYPTOHOME_CLIENT_H_ |
OLD | NEW |