OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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. |
| 4 |
| 5 #ifndef COMPONENTS_OS_CRYPT_KEY_STORAGE_KWALLET_H_ |
| 6 #define COMPONENTS_OS_CRYPT_KEY_STORAGE_KWALLET_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <string> |
| 10 |
| 11 #include "base/macros.h" |
| 12 #include "components/os_crypt/key_storage_linux.h" |
| 13 #include "components/os_crypt/kwallet_dbus.h" |
| 14 |
| 15 class KeyStorageKWallet : public KeyStorageLinux { |
| 16 public: |
| 17 KeyStorageKWallet(base::nix::DesktopEnvironment desktop_env, |
| 18 std::string app_name); |
| 19 ~KeyStorageKWallet() override; |
| 20 |
| 21 // KeyStorageLinux |
| 22 std::string GetKey() override; |
| 23 |
| 24 // Initialize using an optional KWalletDBus mock. |
| 25 // A DBus session will not be created if a mock is provided. |
| 26 bool InitWithKWalletDBus( |
| 27 std::unique_ptr<KWalletDBus> optional_kwallet_dbus_ptr); |
| 28 |
| 29 protected: |
| 30 // KeyStorageLinux |
| 31 bool Init() override; |
| 32 |
| 33 private: |
| 34 enum class InitResult { |
| 35 SUCCESS, |
| 36 TEMPORARY_FAIL, |
| 37 PERMANENT_FAIL, |
| 38 }; |
| 39 |
| 40 // Check whether KWallet is enabled and set |wallet_name_| |
| 41 InitResult InitWallet(); |
| 42 |
| 43 // Create Chrome's folder in the wallet, if it doesn't exist. |
| 44 bool InitFolder(); |
| 45 |
| 46 const base::nix::DesktopEnvironment desktop_env_; |
| 47 int32_t handle_; |
| 48 std::string wallet_name_; |
| 49 const std::string app_name_; |
| 50 std::unique_ptr<KWalletDBus> kwallet_dbus_; |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(KeyStorageKWallet); |
| 53 }; |
| 54 |
| 55 #endif // COMPONENTS_OS_CRYPT_KEY_STORAGE_KWALLET_H_ |
OLD | NEW |