| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOGIN_DATABASE_H_ | 5 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOGIN_DATABASE_H_ |
| 6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOGIN_DATABASE_H_ | 6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOGIN_DATABASE_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/memory/scoped_vector.h" | |
| 16 #include "base/pickle.h" | 15 #include "base/pickle.h" |
| 17 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
| 18 #include "build/build_config.h" | 17 #include "build/build_config.h" |
| 19 #include "components/password_manager/core/browser/password_store.h" | 18 #include "components/password_manager/core/browser/password_store.h" |
| 20 #include "components/password_manager/core/browser/password_store_change.h" | 19 #include "components/password_manager/core/browser/password_store_change.h" |
| 21 #include "components/password_manager/core/browser/psl_matching_helper.h" | 20 #include "components/password_manager/core/browser/psl_matching_helper.h" |
| 22 #include "components/password_manager/core/browser/statistics_table.h" | 21 #include "components/password_manager/core/browser/statistics_table.h" |
| 23 #include "sql/connection.h" | 22 #include "sql/connection.h" |
| 24 #include "sql/meta_table.h" | 23 #include "sql/meta_table.h" |
| 25 | 24 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 bool GetLogins(const PasswordStore::FormDigest& form, | 90 bool GetLogins(const PasswordStore::FormDigest& form, |
| 92 std::vector<std::unique_ptr<autofill::PasswordForm>>* forms) | 91 std::vector<std::unique_ptr<autofill::PasswordForm>>* forms) |
| 93 const WARN_UNUSED_RESULT; | 92 const WARN_UNUSED_RESULT; |
| 94 | 93 |
| 95 // Gets all logins created from |begin| onwards (inclusive) and before |end|. | 94 // Gets all logins created from |begin| onwards (inclusive) and before |end|. |
| 96 // You may use a null Time value to do an unbounded search in either | 95 // You may use a null Time value to do an unbounded search in either |
| 97 // direction. | 96 // direction. |
| 98 bool GetLoginsCreatedBetween( | 97 bool GetLoginsCreatedBetween( |
| 99 base::Time begin, | 98 base::Time begin, |
| 100 base::Time end, | 99 base::Time end, |
| 101 ScopedVector<autofill::PasswordForm>* forms) const WARN_UNUSED_RESULT; | 100 std::vector<std::unique_ptr<autofill::PasswordForm>>* forms) const |
| 101 WARN_UNUSED_RESULT; |
| 102 | 102 |
| 103 // Gets all logins synced from |begin| onwards (inclusive) and before |end|. | 103 // Gets all logins synced from |begin| onwards (inclusive) and before |end|. |
| 104 // You may use a null Time value to do an unbounded search in either | 104 // You may use a null Time value to do an unbounded search in either |
| 105 // direction. | 105 // direction. |
| 106 bool GetLoginsSyncedBetween(base::Time begin, | 106 bool GetLoginsSyncedBetween( |
| 107 base::Time end, | 107 base::Time begin, |
| 108 ScopedVector<autofill::PasswordForm>* forms) const | 108 base::Time end, |
| 109 std::vector<std::unique_ptr<autofill::PasswordForm>>* forms) const |
| 109 WARN_UNUSED_RESULT; | 110 WARN_UNUSED_RESULT; |
| 110 | 111 |
| 111 // Gets the complete list of not blacklisted credentials. | 112 // Gets the complete list of not blacklisted credentials. |
| 112 bool GetAutofillableLogins( | 113 bool GetAutofillableLogins( |
| 113 std::vector<std::unique_ptr<autofill::PasswordForm>>* forms) const | 114 std::vector<std::unique_ptr<autofill::PasswordForm>>* forms) const |
| 114 WARN_UNUSED_RESULT; | 115 WARN_UNUSED_RESULT; |
| 115 | 116 |
| 116 // Gets the complete list of blacklisted credentials. | 117 // Gets the complete list of blacklisted credentials. |
| 117 bool GetBlacklistLogins(std::vector<std::unique_ptr<autofill::PasswordForm>>* | 118 bool GetBlacklistLogins(std::vector<std::unique_ptr<autofill::PasswordForm>>* |
| 118 forms) const WARN_UNUSED_RESULT; | 119 forms) const WARN_UNUSED_RESULT; |
| 119 | 120 |
| 120 // Gets the list of auto-sign-inable credentials. | 121 // Gets the list of auto-sign-inable credentials. |
| 121 bool GetAutoSignInLogins(ScopedVector<autofill::PasswordForm>* forms) const | 122 bool GetAutoSignInLogins(std::vector<std::unique_ptr<autofill::PasswordForm>>* |
| 122 WARN_UNUSED_RESULT; | 123 forms) const WARN_UNUSED_RESULT; |
| 123 | 124 |
| 124 // Deletes the login database file on disk, and creates a new, empty database. | 125 // Deletes the login database file on disk, and creates a new, empty database. |
| 125 // This can be used after migrating passwords to some other store, to ensure | 126 // This can be used after migrating passwords to some other store, to ensure |
| 126 // that SQLite doesn't leave fragments of passwords in the database file. | 127 // that SQLite doesn't leave fragments of passwords in the database file. |
| 127 // Returns true on success; otherwise, whether the file was deleted and | 128 // Returns true on success; otherwise, whether the file was deleted and |
| 128 // whether further use of this login database will succeed is unspecified. | 129 // whether further use of this login database will succeed is unspecified. |
| 129 bool DeleteAndRecreateDatabaseFile(); | 130 bool DeleteAndRecreateDatabaseFile(); |
| 130 | 131 |
| 131 // Returns the encrypted password value for the specified |form|. Returns an | 132 // Returns the encrypted password value for the specified |form|. Returns an |
| 132 // empty string if the row for this |form| is not found. | 133 // empty string if the row for this |form| is not found. |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 // Gets all blacklisted or all non-blacklisted (depending on |blacklisted|) | 186 // Gets all blacklisted or all non-blacklisted (depending on |blacklisted|) |
| 186 // credentials. On success returns true and overwrites |forms| with the | 187 // credentials. On success returns true and overwrites |forms| with the |
| 187 // result. | 188 // result. |
| 188 bool GetAllLoginsWithBlacklistSetting( | 189 bool GetAllLoginsWithBlacklistSetting( |
| 189 bool blacklisted, | 190 bool blacklisted, |
| 190 std::vector<std::unique_ptr<autofill::PasswordForm>>* forms) const; | 191 std::vector<std::unique_ptr<autofill::PasswordForm>>* forms) const; |
| 191 | 192 |
| 192 // Overwrites |forms| with credentials retrieved from |statement|. If | 193 // Overwrites |forms| with credentials retrieved from |statement|. If |
| 193 // |matched_form| is not null, filters out all results but those PSL-matching | 194 // |matched_form| is not null, filters out all results but those PSL-matching |
| 194 // |*matched_form| or federated credentials for it. On success returns true. | 195 // |*matched_form| or federated credentials for it. On success returns true. |
| 195 static bool StatementToForms(sql::Statement* statement, | 196 static bool StatementToForms( |
| 196 const PasswordStore::FormDigest* matched_form, | 197 sql::Statement* statement, |
| 197 ScopedVector<autofill::PasswordForm>* forms); | 198 const PasswordStore::FormDigest* matched_form, |
| 199 std::vector<std::unique_ptr<autofill::PasswordForm>>* forms); |
| 198 | 200 |
| 199 // Initializes all the *_statement_ data members with appropriate SQL | 201 // Initializes all the *_statement_ data members with appropriate SQL |
| 200 // fragments based on |builder|. | 202 // fragments based on |builder|. |
| 201 void InitializeStatementStrings(const SQLTableBuilder& builder); | 203 void InitializeStatementStrings(const SQLTableBuilder& builder); |
| 202 | 204 |
| 203 base::FilePath db_path_; | 205 base::FilePath db_path_; |
| 204 mutable sql::Connection db_; | 206 mutable sql::Connection db_; |
| 205 sql::MetaTable meta_table_; | 207 sql::MetaTable meta_table_; |
| 206 StatisticsTable stats_table_; | 208 StatisticsTable stats_table_; |
| 207 | 209 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 226 std::string synced_statement_; | 228 std::string synced_statement_; |
| 227 std::string blacklisted_statement_; | 229 std::string blacklisted_statement_; |
| 228 std::string encrypted_statement_; | 230 std::string encrypted_statement_; |
| 229 | 231 |
| 230 DISALLOW_COPY_AND_ASSIGN(LoginDatabase); | 232 DISALLOW_COPY_AND_ASSIGN(LoginDatabase); |
| 231 }; | 233 }; |
| 232 | 234 |
| 233 } // namespace password_manager | 235 } // namespace password_manager |
| 234 | 236 |
| 235 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOGIN_DATABASE_H_ | 237 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOGIN_DATABASE_H_ |
| OLD | NEW |