Chromium Code Reviews| Index: components/os_crypt/key_storage_linux.cc |
| diff --git a/components/os_crypt/key_storage_linux.cc b/components/os_crypt/key_storage_linux.cc |
| index e54bb9e6719f89d22e763eb8a0aa0b70afa4c2c4..029bf9cd8c9e482c01e1f52ae33d1c664a23ac2e 100644 |
| --- a/components/os_crypt/key_storage_linux.cc |
| +++ b/components/os_crypt/key_storage_linux.cc |
| @@ -4,8 +4,6 @@ |
| #include "components/os_crypt/key_storage_linux.h" |
| -#include <string.h> |
| - |
| #include "base/environment.h" |
| #include "base/lazy_instance.h" |
| #include "base/logging.h" |
| @@ -15,7 +13,12 @@ |
| #include "components/os_crypt/key_storage_libsecret.h" |
| #endif |
| +#if defined(USE_KWALLET) |
| +#include "components/os_crypt/key_storage_kwallet.h" |
| +#endif |
| + |
| base::LazyInstance<std::string> g_store_ = LAZY_INSTANCE_INITIALIZER; |
| +base::LazyInstance<std::string> g_product_name_ = LAZY_INSTANCE_INITIALIZER; |
|
Lei Zhang
2016/07/20 01:08:26
Sorry if I missed it earlier, but g_foo doesn't ne
cfroussios
2016/07/20 15:22:46
Done.
|
| // static |
| void KeyStorageLinux::SetStore(const std::string& store_type) { |
| @@ -24,6 +27,11 @@ void KeyStorageLinux::SetStore(const std::string& store_type) { |
| } |
| // static |
| +void KeyStorageLinux::SetProductName(const std::string& product_name) { |
| + g_product_name_.Get() = product_name; |
| +} |
| + |
| +// static |
| std::unique_ptr<KeyStorageLinux> KeyStorageLinux::CreateService() { |
| base::nix::DesktopEnvironment used_desktop_env; |
| if (g_store_.Get() == "kwallet") { |
| @@ -51,6 +59,17 @@ std::unique_ptr<KeyStorageLinux> KeyStorageLinux::CreateService() { |
| return key_storage; |
| } |
| #endif |
| + } else if (used_desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE4 || |
| + used_desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE5) { |
| +#if defined(USE_KWALLET) |
| + DCHECK(!g_product_name_.Get().empty()); |
| + key_storage.reset( |
| + new KeyStorageKWallet(used_desktop_env, g_product_name_.Get())); |
| + if (key_storage->Init()) { |
| + VLOG(1) << "OSCrypt using KWallet as backend."; |
| + return key_storage; |
| + } |
| +#endif |
| } |
| // The appropriate store was not available. |