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 <memory> |
8 #include <string> | 9 #include <string> |
| 10 #include <vector> |
9 | 11 |
10 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
11 #include "base/macros.h" | 13 #include "base/macros.h" |
12 #include "base/memory/scoped_vector.h" | |
13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
14 #include "chrome/browser/password_manager/password_store_factory.h" | 15 #include "chrome/browser/password_manager/password_store_factory.h" |
15 #include "chrome/browser/password_manager/password_store_x.h" | 16 #include "chrome/browser/password_manager/password_store_x.h" |
16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
17 #include "components/os_crypt/libsecret_util_linux.h" | 18 #include "components/os_crypt/libsecret_util_linux.h" |
18 | 19 |
19 namespace autofill { | 20 namespace autofill { |
20 struct PasswordForm; | 21 struct PasswordForm; |
21 } | 22 } |
22 | 23 |
(...skipping 16 matching lines...) Expand all Loading... |
39 base::Time delete_begin, | 40 base::Time delete_begin, |
40 base::Time delete_end, | 41 base::Time delete_end, |
41 password_manager::PasswordStoreChangeList* changes) override; | 42 password_manager::PasswordStoreChangeList* changes) override; |
42 bool RemoveLoginsSyncedBetween( | 43 bool RemoveLoginsSyncedBetween( |
43 base::Time delete_begin, | 44 base::Time delete_begin, |
44 base::Time delete_end, | 45 base::Time delete_end, |
45 password_manager::PasswordStoreChangeList* changes) override; | 46 password_manager::PasswordStoreChangeList* changes) override; |
46 bool DisableAutoSignInForOrigins( | 47 bool DisableAutoSignInForOrigins( |
47 const base::Callback<bool(const GURL&)>& origin_filter, | 48 const base::Callback<bool(const GURL&)>& origin_filter, |
48 password_manager::PasswordStoreChangeList* changes) override; | 49 password_manager::PasswordStoreChangeList* changes) override; |
49 bool GetLogins(const password_manager::PasswordStore::FormDigest& form, | 50 bool GetLogins( |
50 ScopedVector<autofill::PasswordForm>* forms) override; | 51 const password_manager::PasswordStore::FormDigest& form, |
| 52 std::vector<std::unique_ptr<autofill::PasswordForm>>* forms) override; |
51 bool GetAutofillableLogins( | 53 bool GetAutofillableLogins( |
52 ScopedVector<autofill::PasswordForm>* forms) override; | 54 std::vector<std::unique_ptr<autofill::PasswordForm>>* forms) override; |
53 bool GetBlacklistLogins(ScopedVector<autofill::PasswordForm>* forms) override; | 55 bool GetBlacklistLogins( |
54 bool GetAllLogins(ScopedVector<autofill::PasswordForm>* forms) override; | 56 std::vector<std::unique_ptr<autofill::PasswordForm>>* forms) override; |
| 57 bool GetAllLogins( |
| 58 std::vector<std::unique_ptr<autofill::PasswordForm>>* forms) override; |
55 | 59 |
56 private: | 60 private: |
57 enum TimestampToCompare { | 61 enum TimestampToCompare { |
58 CREATION_TIMESTAMP, | 62 CREATION_TIMESTAMP, |
59 SYNC_TIMESTAMP, | 63 SYNC_TIMESTAMP, |
60 }; | 64 }; |
61 | 65 |
62 // Returns credentials matching |lookup_form| via |forms|. | 66 // Returns credentials matching |lookup_form| via |forms|. |
63 bool AddUpdateLoginSearch( | 67 bool AddUpdateLoginSearch( |
64 const autofill::PasswordForm& lookup_form, | 68 const autofill::PasswordForm& lookup_form, |
65 ScopedVector<autofill::PasswordForm>* forms); | 69 std::vector<std::unique_ptr<autofill::PasswordForm>>* forms); |
66 | 70 |
67 // Adds a login form without checking for one to replace first. | 71 // Adds a login form without checking for one to replace first. |
68 bool RawAddLogin(const autofill::PasswordForm& form); | 72 bool RawAddLogin(const autofill::PasswordForm& form); |
69 | 73 |
70 enum GetLoginsListOptions { | 74 enum GetLoginsListOptions { |
71 ALL_LOGINS, | 75 ALL_LOGINS, |
72 AUTOFILLABLE_LOGINS, | 76 AUTOFILLABLE_LOGINS, |
73 BLACKLISTED_LOGINS, | 77 BLACKLISTED_LOGINS, |
74 }; | 78 }; |
75 | 79 |
76 // Retrieves credentials matching |options| from the keyring into |forms|, | 80 // Retrieves credentials matching |options| from the keyring into |forms|, |
77 // overwriting the original contents of |forms|. If |lookup_form| is not NULL, | 81 // overwriting the original contents of |forms|. If |lookup_form| is not NULL, |
78 // only retrieves credentials PSL-matching it. Returns true on success. | 82 // only retrieves credentials PSL-matching it. Returns true on success. |
79 bool GetLoginsList( | 83 bool GetLoginsList( |
80 const password_manager::PasswordStore::FormDigest* lookup_form, | 84 const password_manager::PasswordStore::FormDigest* lookup_form, |
81 GetLoginsListOptions options, | 85 GetLoginsListOptions options, |
82 ScopedVector<autofill::PasswordForm>* forms) WARN_UNUSED_RESULT; | 86 std::vector<std::unique_ptr<autofill::PasswordForm>>* forms) |
| 87 WARN_UNUSED_RESULT; |
83 | 88 |
84 // Retrieves password created/synced in the time interval into |forms|, | 89 // Retrieves password created/synced in the time interval into |forms|, |
85 // overwriting the original contents of |forms|. Returns true on success. | 90 // overwriting the original contents of |forms|. Returns true on success. |
86 bool GetLoginsBetween(base::Time get_begin, | 91 bool GetLoginsBetween(base::Time get_begin, |
87 base::Time get_end, | 92 base::Time get_end, |
88 TimestampToCompare date_to_compare, | 93 TimestampToCompare date_to_compare, |
89 ScopedVector<autofill::PasswordForm>* forms) | 94 std::vector<std::unique_ptr<autofill::PasswordForm>>* |
90 WARN_UNUSED_RESULT; | 95 forms) WARN_UNUSED_RESULT; |
91 | 96 |
92 // Removes password created/synced in the time interval. Returns |true| if the | 97 // Removes password created/synced in the time interval. Returns |true| if the |
93 // operation succeeded. |changes| will contain the changes applied. | 98 // operation succeeded. |changes| will contain the changes applied. |
94 bool RemoveLoginsBetween(base::Time get_begin, | 99 bool RemoveLoginsBetween(base::Time get_begin, |
95 base::Time get_end, | 100 base::Time get_end, |
96 TimestampToCompare date_to_compare, | 101 TimestampToCompare date_to_compare, |
97 password_manager::PasswordStoreChangeList* changes); | 102 password_manager::PasswordStoreChangeList* changes); |
98 | 103 |
99 // Convert data get from Libsecret to Passwordform. Uses |lookup_form| for | 104 // Convert data get from Libsecret to Passwordform. Uses |lookup_form| for |
100 // additional (PSL) matching, if present. | 105 // additional (PSL) matching, if present. |
101 ScopedVector<autofill::PasswordForm> ConvertFormList( | 106 std::vector<std::unique_ptr<autofill::PasswordForm>> ConvertFormList( |
102 GList* found, | 107 GList* found, |
103 const password_manager::PasswordStore::FormDigest* lookup_form); | 108 const password_manager::PasswordStore::FormDigest* lookup_form); |
104 | 109 |
105 // The app string, possibly based on the local profile id. | 110 // The app string, possibly based on the local profile id. |
106 std::string app_string_; | 111 std::string app_string_; |
107 | 112 |
108 // True if we're already ensured that the default keyring has been unlocked | 113 // True if we're already ensured that the default keyring has been unlocked |
109 // once. | 114 // once. |
110 bool ensured_keyring_unlocked_; | 115 bool ensured_keyring_unlocked_; |
111 | 116 |
112 DISALLOW_COPY_AND_ASSIGN(NativeBackendLibsecret); | 117 DISALLOW_COPY_AND_ASSIGN(NativeBackendLibsecret); |
113 }; | 118 }; |
114 | 119 |
115 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_LIBSECRET_H_ | 120 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_LIBSECRET_H_ |
OLD | NEW |