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