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_OS_CRYPT_POSIX_UTIL_LIBSECRET_H_ | |
Lei Zhang
2016/04/28 21:49:09
Can we name the file libsecret_util_posix.h?
cfroussios
2016/04/29 12:14:05
Done.
| |
6 #define COMPONENTS_OS_CRYPT_OS_CRYPT_POSIX_UTIL_LIBSECRET_H_ | |
7 | |
8 #include <libsecret/secret.h> | |
9 | |
10 #include <list> | |
11 #include <string> | |
12 | |
13 #include "base/macros.h" | |
14 | |
15 class LibsecretLoader { | |
Lei Zhang
2016/04/28 21:49:09
Can you add some documentation to explain what thi
cfroussios
2016/04/29 12:14:05
I understand the confusion. I've introduced a meth
| |
16 public: | |
17 static decltype(&::secret_password_store_sync) secret_password_store_sync; | |
18 static decltype(&::secret_service_search_sync) secret_service_search_sync; | |
19 static decltype(&::secret_password_clear_sync) secret_password_clear_sync; | |
20 static decltype(&::secret_item_get_secret) secret_item_get_secret; | |
21 static decltype(&::secret_value_get_text) secret_value_get_text; | |
22 static decltype(&::secret_item_get_attributes) secret_item_get_attributes; | |
23 static decltype(&::secret_item_load_secret_sync) secret_item_load_secret_sync; | |
24 static decltype(&::secret_value_unref) secret_value_unref; | |
25 | |
26 static bool LoadLibsecret(); | |
27 | |
28 static bool LibsecretIsAvailable(); | |
29 | |
30 protected: | |
31 static bool libsecret_loaded; | |
32 | |
33 private: | |
34 struct FunctionInfo { | |
35 const char* name; | |
36 void** pointer; | |
37 }; | |
38 | |
39 static const FunctionInfo functions[]; | |
40 | |
41 DISALLOW_IMPLICIT_CONSTRUCTORS(LibsecretLoader); | |
42 }; | |
43 | |
44 class LibsecretAttributesBuilder { | |
45 public: | |
46 LibsecretAttributesBuilder(); | |
47 ~LibsecretAttributesBuilder(); | |
48 | |
49 void Append(const std::string& name, const std::string& value); | |
50 | |
51 void Append(const std::string& name, int64_t value); | |
52 | |
53 // GHashTable, its keys and values returned from Get() are destroyed in | |
54 // |LibsecretAttributesBuilder| desctructor. | |
Lei Zhang
2016/04/28 21:49:09
typo
cfroussios
2016/04/29 12:14:05
Done.
| |
55 GHashTable* Get() { return attrs_; } | |
56 | |
57 private: | |
58 // |name_values_| is a storage for strings referenced in |attrs_|. | |
59 std::list<std::string> name_values_; | |
Lei Zhang
2016/04/28 21:49:09
I realize this is code being moved, but what's the
cfroussios
2016/04/29 12:14:05
There are no benefits that I can see. I've switche
cfroussios
2016/04/29 16:39:37
It turns out that list is necessary. Switching to
| |
60 GHashTable* attrs_; | |
61 | |
62 DISALLOW_COPY_AND_ASSIGN(LibsecretAttributesBuilder); | |
63 }; | |
64 | |
65 #endif // COMPONENTS_OS_CRYPT_OS_CRYPT_POSIX_UTIL_LIBSECRET_H_ | |
OLD | NEW |