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_util_posix.h" |
19 | 18 |
20 namespace autofill { | 19 namespace autofill { |
21 struct PasswordForm; | 20 struct PasswordForm; |
22 } | 21 } |
23 | 22 |
24 class LibsecretLoader { | 23 class NativeBackendLibsecret : public PasswordStoreX::NativeBackend { |
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, | |
51 public LibsecretLoader { | |
52 public: | 24 public: |
53 explicit NativeBackendLibsecret(LocalProfileId id); | 25 explicit NativeBackendLibsecret(LocalProfileId id); |
54 | 26 |
55 ~NativeBackendLibsecret() override; | 27 ~NativeBackendLibsecret() override; |
56 | 28 |
57 bool Init() override; | 29 bool Init() override; |
58 | 30 |
59 // Implements NativeBackend interface. | 31 // Implements NativeBackend interface. |
60 password_manager::PasswordStoreChangeList AddLogin( | 32 password_manager::PasswordStoreChangeList AddLogin( |
61 const autofill::PasswordForm& form) override; | 33 const autofill::PasswordForm& form) override; |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 GList* found, | 100 GList* found, |
129 const autofill::PasswordForm* lookup_form); | 101 const autofill::PasswordForm* lookup_form); |
130 | 102 |
131 // The app string, possibly based on the local profile id. | 103 // The app string, possibly based on the local profile id. |
132 std::string app_string_; | 104 std::string app_string_; |
133 | 105 |
134 DISALLOW_COPY_AND_ASSIGN(NativeBackendLibsecret); | 106 DISALLOW_COPY_AND_ASSIGN(NativeBackendLibsecret); |
135 }; | 107 }; |
136 | 108 |
137 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_LIBSECRET_H_ | 109 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_LIBSECRET_H_ |
OLD | NEW |