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_KEYRING_H_ |
| 6 #define COMPONENTS_OS_CRYPT_KEY_STORAGE_KEYRING_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "components/os_crypt/key_storage_linux.h" |
| 12 |
| 13 namespace base { |
| 14 class SingleThreadTaskRunner; |
| 15 class WaitableEvent; |
| 16 } // namespace base |
| 17 |
| 18 // Specialisation of KeyStorageLinux that uses Libsecret. |
| 19 class KeyStorageKeyring : public KeyStorageLinux { |
| 20 public: |
| 21 explicit KeyStorageKeyring( |
| 22 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner); |
| 23 ~KeyStorageKeyring() override; |
| 24 |
| 25 // KeyStorageLinux |
| 26 std::string GetKey() override; |
| 27 |
| 28 protected: |
| 29 // KeyStorageLinux |
| 30 bool Init() override; |
| 31 |
| 32 private: |
| 33 // Gnome keyring requires calls to originate from the main thread. |
| 34 // This is the part of GetKey() that gets dispatched to the main thread. |
| 35 // The password is stored in |password_ptr|. If |password_loaded_ptr| is not |
| 36 // null, it will be signaled when |password_ptr| is safe to read. |
| 37 void GetKeyDelegate(std::string* password_ptr, |
| 38 base::WaitableEvent* password_loaded_ptr); |
| 39 |
| 40 // Generate a random string and store it as OScrypt's new password. |
| 41 std::string AddRandomPasswordInKeyring(); |
| 42 |
| 43 // Keyring calls need to originate from the main thread. |
| 44 scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner_; |
| 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(KeyStorageKeyring); |
| 47 }; |
| 48 |
| 49 #endif // COMPONENTS_OS_CRYPT_KEY_STORAGE_KEYRING_H_ |
OLD | NEW |