OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_OS_CRYPT_LIBSECRET_UTIL_POSIX_H_ | 5 #ifndef COMPONENTS_OS_CRYPT_LIBSECRET_UTIL_LINUX_H_ |
6 #define COMPONENTS_OS_CRYPT_LIBSECRET_UTIL_POSIX_H_ | 6 #define COMPONENTS_OS_CRYPT_LIBSECRET_UTIL_LINUX_H_ |
7 | 7 |
8 #include <libsecret/secret.h> | 8 #include <libsecret/secret.h> |
9 | 9 |
10 #include <list> | 10 #include <list> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/macros.h" | 13 #include "base/macros.h" |
14 | 14 |
15 // Utility for dynamically loading libsecret. | 15 // Utility for dynamically loading libsecret. |
16 class LibsecretLoader { | 16 class LibsecretLoader { |
17 public: | 17 public: |
| 18 static decltype(&::secret_item_get_attributes) secret_item_get_attributes; |
| 19 static decltype(&::secret_item_get_secret) secret_item_get_secret; |
| 20 static decltype(&::secret_item_load_secret_sync) secret_item_load_secret_sync; |
| 21 static decltype(&::secret_password_clear_sync) secret_password_clear_sync; |
18 static decltype(&::secret_password_store_sync) secret_password_store_sync; | 22 static decltype(&::secret_password_store_sync) secret_password_store_sync; |
| 23 static decltype(&::secret_service_lookup_sync) secret_service_lookup_sync; |
19 static decltype(&::secret_service_search_sync) secret_service_search_sync; | 24 static decltype(&::secret_service_search_sync) secret_service_search_sync; |
20 static decltype(&::secret_password_clear_sync) secret_password_clear_sync; | |
21 static decltype(&::secret_item_get_secret) secret_item_get_secret; | |
22 static decltype(&::secret_value_get_text) secret_value_get_text; | 25 static decltype(&::secret_value_get_text) secret_value_get_text; |
23 static decltype(&::secret_item_get_attributes) secret_item_get_attributes; | |
24 static decltype(&::secret_item_load_secret_sync) secret_item_load_secret_sync; | |
25 static decltype(&::secret_value_unref) secret_value_unref; | 26 static decltype(&::secret_value_unref) secret_value_unref; |
26 | 27 |
27 // Loads the libsecret library and checks that it responds to queries. | 28 // Loads the libsecret library and checks that it responds to queries. |
28 // Returns false if either step fails. | 29 // Returns false if either step fails. |
29 // Repeated calls check the responsiveness every time, but do not load the | 30 // Repeated calls check the responsiveness every time, but do not load the |
30 // the library again if already successful. | 31 // the library again if already successful. |
31 static bool EnsureLibsecretLoaded(); | 32 static bool EnsureLibsecretLoaded(); |
32 | 33 |
33 protected: | 34 protected: |
34 static bool libsecret_loaded_; | 35 static bool libsecret_loaded_; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // TODO(crbug.com/607950): Make implementation more robust by not depending on | 74 // TODO(crbug.com/607950): Make implementation more robust by not depending on |
74 // the implementation details of containers. External objects keep references | 75 // the implementation details of containers. External objects keep references |
75 // to the objects stored in this container. Using a vector here will fail the | 76 // to the objects stored in this container. Using a vector here will fail the |
76 // ASan tests, because it may move the objects and break the references. | 77 // ASan tests, because it may move the objects and break the references. |
77 std::list<std::string> name_values_; | 78 std::list<std::string> name_values_; |
78 GHashTable* attrs_; | 79 GHashTable* attrs_; |
79 | 80 |
80 DISALLOW_COPY_AND_ASSIGN(LibsecretAttributesBuilder); | 81 DISALLOW_COPY_AND_ASSIGN(LibsecretAttributesBuilder); |
81 }; | 82 }; |
82 | 83 |
83 #endif // COMPONENTS_OS_CRYPT_LIBSECRET_UTIL_POSIX_H_ | 84 #endif // COMPONENTS_OS_CRYPT_LIBSECRET_UTIL_LINUX_H_ |
OLD | NEW |