Index: components/os_crypt/key_storage_kwallet.h |
diff --git a/components/os_crypt/key_storage_kwallet.h b/components/os_crypt/key_storage_kwallet.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..35edcf2fd1c327b1ba9a99b5079931ca0af31f0c |
--- /dev/null |
+++ b/components/os_crypt/key_storage_kwallet.h |
@@ -0,0 +1,55 @@ |
+// Copyright 2016 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef COMPONENTS_OS_CRYPT_KEY_STORAGE_KWALLET_H_ |
+#define COMPONENTS_OS_CRYPT_KEY_STORAGE_KWALLET_H_ |
+ |
+#include <memory> |
+#include <string> |
+ |
+#include "base/macros.h" |
+#include "components/os_crypt/key_storage_linux.h" |
+#include "components/os_crypt/kwallet_dbus.h" |
+ |
+class KeyStorageKWallet : public KeyStorageLinux { |
+ public: |
+ KeyStorageKWallet(base::nix::DesktopEnvironment desktop_env, |
+ std::string app_name); |
+ ~KeyStorageKWallet() override; |
+ |
+ // KeyStorageLinux |
+ std::string GetKey() override; |
+ |
+ // Initialize using an optional KWalletDBus mock. |
+ // A DBus session will not be created if a mock is provided. |
+ bool InitWithKWalletDBus( |
+ std::unique_ptr<KWalletDBus> optional_kwallet_dbus_ptr); |
+ |
+ protected: |
+ // KeyStorageLinux |
+ bool Init() override; |
+ |
+ private: |
+ enum class InitResult { |
+ SUCCESS, |
+ TEMPORARY_FAIL, |
+ PERMANENT_FAIL, |
+ }; |
+ |
+ // Check whether KWallet is enabled and set |wallet_name_| |
+ InitResult InitWallet(); |
+ |
+ // Create Chrome's folder in the wallet, if it doesn't exist. |
+ bool InitFolder(); |
+ |
+ const base::nix::DesktopEnvironment desktop_env_; |
+ int32_t handle_; |
+ std::string wallet_name_; |
+ const std::string app_name_; |
+ std::unique_ptr<KWalletDBus> kwallet_dbus_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(KeyStorageKWallet); |
+}; |
+ |
+#endif // COMPONENTS_OS_CRYPT_KEY_STORAGE_KWALLET_H_ |