Chromium Code Reviews| Index: components/os_crypt/os_crypt.h |
| diff --git a/components/os_crypt/os_crypt.h b/components/os_crypt/os_crypt.h |
| index ecffa4e5ed4c8c81b4acde3b8169b156eb305f51..a65064e88fe9275eb8568d02a50e5f4c0afe1908 100644 |
| --- a/components/os_crypt/os_crypt.h |
| +++ b/components/os_crypt/os_crypt.h |
| @@ -11,6 +11,10 @@ |
| #include "base/strings/string16.h" |
| #include "build/build_config.h" |
| +#if defined(USE_LIBSECRET) |
| +#include "components/os_crypt/key_storage_linux.h" |
| +#endif |
| + |
| // The OSCrypt class gives access to simple encryption and decryption of |
| // strings. Note that on Mac, access to the system Keychain is required and |
| // these calls can block the current thread to collect user input. |
| @@ -47,4 +51,16 @@ class OSCrypt { |
| DISALLOW_IMPLICIT_CONSTRUCTORS(OSCrypt); |
| }; |
| +#if defined(USE_LIBSECRET) && defined(UNIT_TEST) |
| +// For unit testing purposes, inject methods to be used. |
| +// |get_key_storage_mock| provides the desired |KeyStorage| implementation. |
| +// If the provider returns |nullptr|, a hardcoded password will be used. |
| +// |get_password_v11_mock| provides a password to derive the encryption key from |
| +// If |use| is true, the provided values will be injected. Otherwise, the |
| +// real implementation is restored. |
| +void UseMockKeyStorageForTesting(bool use, |
|
Lei Zhang
2016/05/19 22:45:38
You probably don't need |use| - you can indicate u
cfroussios
2016/05/20 16:44:52
Done.
|
| + KeyStorageLinux* (*get_key_storage_mock)(), |
| + std::string* (*get_password_v11_mock)()); |
| +#endif // defined(USE_LIBSECRET) && defined(UNIT_TEST) |
| + |
| #endif // COMPONENTS_OS_CRYPT_OS_CRYPT_H_ |