| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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 CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_LIBSECRET_H_ | 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_LIBSECRET_H_ |
| 6 #define CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_LIBSECRET_H_ | 6 #define CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_LIBSECRET_H_ |
| 7 | 7 |
| 8 #include <libsecret/secret.h> | |
| 9 | |
| 10 #include <string> | 8 #include <string> |
| 11 | 9 |
| 12 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 11 #include "base/macros.h" |
| 14 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
| 15 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 16 #include "chrome/browser/password_manager/password_store_factory.h" | 14 #include "chrome/browser/password_manager/password_store_factory.h" |
| 17 #include "chrome/browser/password_manager/password_store_x.h" | 15 #include "chrome/browser/password_manager/password_store_x.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "components/os_crypt/libsecret_loader.h" |
| 19 | 18 |
| 20 namespace autofill { | 19 namespace autofill { |
| 21 struct PasswordForm; | 20 struct PasswordForm; |
| 22 } | 21 } |
| 23 | 22 |
| 24 class LibsecretLoader { | |
| 25 public: | |
| 26 static decltype(&::secret_password_store_sync) secret_password_store_sync; | |
| 27 static decltype(&::secret_service_search_sync) secret_service_search_sync; | |
| 28 static decltype(&::secret_password_clear_sync) secret_password_clear_sync; | |
| 29 static decltype(&::secret_item_get_secret) secret_item_get_secret; | |
| 30 static decltype(&::secret_value_get_text) secret_value_get_text; | |
| 31 static decltype(&::secret_item_get_attributes) secret_item_get_attributes; | |
| 32 static decltype(&::secret_item_load_secret_sync) secret_item_load_secret_sync; | |
| 33 static decltype(&::secret_value_unref) secret_value_unref; | |
| 34 | |
| 35 protected: | |
| 36 static bool LoadLibsecret(); | |
| 37 static bool LibsecretIsAvailable(); | |
| 38 | |
| 39 static bool libsecret_loaded; | |
| 40 | |
| 41 private: | |
| 42 struct FunctionInfo { | |
| 43 const char* name; | |
| 44 void** pointer; | |
| 45 }; | |
| 46 | |
| 47 static const FunctionInfo functions[]; | |
| 48 }; | |
| 49 | |
| 50 class NativeBackendLibsecret : public PasswordStoreX::NativeBackend, | 23 class NativeBackendLibsecret : public PasswordStoreX::NativeBackend, |
| 51 public LibsecretLoader { | 24 public LibsecretLoader { |
| 52 public: | 25 public: |
| 53 explicit NativeBackendLibsecret(LocalProfileId id); | 26 explicit NativeBackendLibsecret(LocalProfileId id); |
| 54 | 27 |
| 55 ~NativeBackendLibsecret() override; | 28 ~NativeBackendLibsecret() override; |
| 56 | 29 |
| 57 bool Init() override; | 30 bool Init() override; |
| 58 | 31 |
| 59 // Implements NativeBackend interface. | 32 // Implements NativeBackend interface. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 GList* found, | 101 GList* found, |
| 129 const autofill::PasswordForm* lookup_form); | 102 const autofill::PasswordForm* lookup_form); |
| 130 | 103 |
| 131 // The app string, possibly based on the local profile id. | 104 // The app string, possibly based on the local profile id. |
| 132 std::string app_string_; | 105 std::string app_string_; |
| 133 | 106 |
| 134 DISALLOW_COPY_AND_ASSIGN(NativeBackendLibsecret); | 107 DISALLOW_COPY_AND_ASSIGN(NativeBackendLibsecret); |
| 135 }; | 108 }; |
| 136 | 109 |
| 137 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_LIBSECRET_H_ | 110 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_LIBSECRET_H_ |
| OLD | NEW |