| 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> | 8 #include <libsecret/secret.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/compiler_specific.h" |
| 13 #include "base/memory/scoped_vector.h" | 14 #include "base/memory/scoped_vector.h" |
| 14 #include "base/time/time.h" | 15 #include "base/time/time.h" |
| 15 #include "chrome/browser/password_manager/password_store_factory.h" | 16 #include "chrome/browser/password_manager/password_store_factory.h" |
| 16 #include "chrome/browser/password_manager/password_store_x.h" | 17 #include "chrome/browser/password_manager/password_store_x.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 18 | 19 |
| 19 namespace autofill { | 20 namespace autofill { |
| 20 struct PasswordForm; | 21 struct PasswordForm; |
| 21 } | 22 } |
| 22 | 23 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 enum TimestampToCompare { | 80 enum TimestampToCompare { |
| 80 CREATION_TIMESTAMP, | 81 CREATION_TIMESTAMP, |
| 81 SYNC_TIMESTAMP, | 82 SYNC_TIMESTAMP, |
| 82 }; | 83 }; |
| 83 | 84 |
| 84 enum AddUpdateLoginSearchOptions { | 85 enum AddUpdateLoginSearchOptions { |
| 85 SEARCH_USE_SUBMIT, | 86 SEARCH_USE_SUBMIT, |
| 86 SEARCH_IGNORE_SUBMIT, | 87 SEARCH_IGNORE_SUBMIT, |
| 87 }; | 88 }; |
| 88 | 89 |
| 89 // Search that is used in AddLogin and UpdateLogin methods | 90 // Returns credentials matching |lookup_form| and |options|. |
| 90 void AddUpdateLoginSearch(const autofill::PasswordForm& lookup_form, | 91 ScopedVector<autofill::PasswordForm> AddUpdateLoginSearch( |
| 91 AddUpdateLoginSearchOptions options, | 92 const autofill::PasswordForm& lookup_form, |
| 92 ScopedVector<autofill::PasswordForm>* forms); | 93 AddUpdateLoginSearchOptions options); |
| 93 | 94 |
| 94 // Adds a login form without checking for one to replace first. | 95 // Adds a login form without checking for one to replace first. |
| 95 bool RawAddLogin(const autofill::PasswordForm& form); | 96 bool RawAddLogin(const autofill::PasswordForm& form); |
| 96 | 97 |
| 97 enum GetLoginsListOptions { | 98 enum GetLoginsListOptions { |
| 98 ALL_LOGINS, | 99 ALL_LOGINS, |
| 99 AUTOFILLABLE_LOGINS, | 100 AUTOFILLABLE_LOGINS, |
| 100 BLACKLISTED_LOGINS, | 101 BLACKLISTED_LOGINS, |
| 101 }; | 102 }; |
| 102 | 103 |
| 103 // Reads PasswordForms from the keyring with the given autofillability state. | 104 // Retrieves credentials matching |options| from the keyring into |forms|, |
| 105 // overwriting the original contents of |forms|. If |lookup_form| is not NULL, |
| 106 // only retrieves credentials PSL-matching it. Returns true on success. |
| 104 bool GetLoginsList(const autofill::PasswordForm* lookup_form, | 107 bool GetLoginsList(const autofill::PasswordForm* lookup_form, |
| 105 GetLoginsListOptions options, | 108 GetLoginsListOptions options, |
| 106 ScopedVector<autofill::PasswordForm>* forms); | 109 ScopedVector<autofill::PasswordForm>* forms) |
| 110 WARN_UNUSED_RESULT; |
| 107 | 111 |
| 108 // Helper for GetLoginsCreatedBetween(). | 112 // Retrieves password created/synced in the time interval into |forms|, |
| 109 bool GetAllLogins(ScopedVector<autofill::PasswordForm>* forms); | 113 // overwriting the original contents of |forms|. Returns true on success. |
| 110 | |
| 111 // Retrieves password created/synced in the time interval. Returns |true| if | |
| 112 // the operation succeeded. | |
| 113 bool GetLoginsBetween(base::Time get_begin, | 114 bool GetLoginsBetween(base::Time get_begin, |
| 114 base::Time get_end, | 115 base::Time get_end, |
| 115 TimestampToCompare date_to_compare, | 116 TimestampToCompare date_to_compare, |
| 116 ScopedVector<autofill::PasswordForm>* forms); | 117 ScopedVector<autofill::PasswordForm>* forms) |
| 118 WARN_UNUSED_RESULT; |
| 117 | 119 |
| 118 // Removes password created/synced in the time interval. Returns |true| if the | 120 // Removes password created/synced in the time interval. Returns |true| if the |
| 119 // operation succeeded. |changes| will contain the changes applied. | 121 // operation succeeded. |changes| will contain the changes applied. |
| 120 bool RemoveLoginsBetween(base::Time get_begin, | 122 bool RemoveLoginsBetween(base::Time get_begin, |
| 121 base::Time get_end, | 123 base::Time get_end, |
| 122 TimestampToCompare date_to_compare, | 124 TimestampToCompare date_to_compare, |
| 123 password_manager::PasswordStoreChangeList* changes); | 125 password_manager::PasswordStoreChangeList* changes); |
| 124 | 126 |
| 125 // convert data get from Libsecret to Passwordform | 127 // convert data get from Libsecret to Passwordform |
| 126 bool ConvertFormList(GList* found, | 128 ScopedVector<autofill::PasswordForm> ConvertFormList( |
| 127 const autofill::PasswordForm* lookup_form, | 129 GList* found, |
| 128 ScopedVector<autofill::PasswordForm>* forms); | 130 const autofill::PasswordForm* lookup_form); |
| 129 | |
| 130 // Generates a profile-specific app string based on profile_id_. | |
| 131 static std::string GetProfileSpecificAppString(LocalProfileId id); | |
| 132 | 131 |
| 133 // The app string, possibly based on the local profile id. | 132 // The app string, possibly based on the local profile id. |
| 134 std::string app_string_; | 133 std::string app_string_; |
| 135 | 134 |
| 136 DISALLOW_COPY_AND_ASSIGN(NativeBackendLibsecret); | 135 DISALLOW_COPY_AND_ASSIGN(NativeBackendLibsecret); |
| 137 }; | 136 }; |
| 138 | 137 |
| 139 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_LIBSECRET_H_ | 138 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_LIBSECRET_H_ |
| OLD | NEW |