Chromium Code Reviews| 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_LIBSECRET_LOADER_H_ | |
|
vabr (Chromium)
2016/04/28 14:42:13
nit: Don't forget to update the #include guard.
(I
cfroussios
2016/04/28 16:26:57
Done.
| |
| 6 #define COMPONENTS_OS_CRYPT_LIBSECRET_LOADER_H_ | |
| 7 | |
| 8 #include <libsecret/secret.h> | |
| 9 | |
| 10 #include <list> | |
| 11 #include <string> | |
| 12 | |
| 13 #include "base/macros.h" | |
| 14 | |
| 15 class LibsecretLoader { | |
| 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 protected: | |
| 27 LibsecretLoader() = default; | |
| 28 | |
| 29 static bool LoadLibsecret(); | |
| 30 static bool LibsecretIsAvailable(); | |
| 31 | |
| 32 static bool libsecret_loaded; | |
| 33 | |
| 34 private: | |
| 35 struct FunctionInfo { | |
| 36 const char* name; | |
| 37 void** pointer; | |
| 38 }; | |
| 39 | |
| 40 static const FunctionInfo functions[]; | |
| 41 | |
| 42 DISALLOW_COPY_AND_ASSIGN(LibsecretLoader); | |
| 43 }; | |
| 44 | |
| 45 class LibsecretAttributesBuilder { | |
| 46 public: | |
| 47 LibsecretAttributesBuilder(); | |
| 48 ~LibsecretAttributesBuilder(); | |
| 49 void Append(const std::string& name, const std::string& value); | |
|
vabr (Chromium)
2016/04/28 14:42:13
nit: Please add blank lines between method declara
cfroussios
2016/04/28 16:26:57
Done.
| |
| 50 void Append(const std::string& name, int64_t value); | |
| 51 // GHashTable, its keys and values returned from Get() are destroyed in | |
| 52 // |LibsecretAttributesBuilder| desctructor. | |
| 53 GHashTable* Get() { return attrs_; } | |
| 54 | |
| 55 private: | |
| 56 // |name_values_| is a storage for strings referenced in |attrs_|. | |
| 57 std::list<std::string> name_values_; | |
| 58 GHashTable* attrs_; | |
| 59 }; | |
|
vabr (Chromium)
2016/04/28 14:42:13
Add DISALLOW_COPY_AND_ASSIGN
cfroussios
2016/04/28 16:26:57
Done.
| |
| 60 | |
| 61 #endif // COMPONENTS_OS_CRYPT_LIBSECRET_LOADER_H_ | |
| OLD | NEW |