| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/memory/scoped_vector.h" |
| 12 #include "base/pickle.h" | 13 #include "base/pickle.h" |
| 13 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
| 15 #include "components/password_manager/core/browser/password_store.h" |
| 14 #include "components/password_manager/core/browser/password_store_change.h" | 16 #include "components/password_manager/core/browser/password_store_change.h" |
| 15 #include "components/password_manager/core/browser/psl_matching_helper.h" | 17 #include "components/password_manager/core/browser/psl_matching_helper.h" |
| 16 #include "sql/connection.h" | 18 #include "sql/connection.h" |
| 17 #include "sql/meta_table.h" | 19 #include "sql/meta_table.h" |
| 18 | 20 |
| 19 namespace password_manager { | 21 namespace password_manager { |
| 20 | 22 |
| 21 extern const int kCurrentVersionNumber; | 23 extern const int kCurrentVersionNumber; |
| 22 | 24 |
| 23 // Interface to the database storage of login information, intended as a helper | 25 // Interface to the database storage of login information, intended as a helper |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 base::Time delete_end); | 60 base::Time delete_end); |
| 59 | 61 |
| 60 // Removes all logins synced from |delete_begin| onwards (inclusive) and | 62 // Removes all logins synced from |delete_begin| onwards (inclusive) and |
| 61 // before |delete_end|. You may use a null Time value to do an unbounded | 63 // before |delete_end|. You may use a null Time value to do an unbounded |
| 62 // delete in either direction. | 64 // delete in either direction. |
| 63 bool RemoveLoginsSyncedBetween(base::Time delete_begin, | 65 bool RemoveLoginsSyncedBetween(base::Time delete_begin, |
| 64 base::Time delete_end); | 66 base::Time delete_end); |
| 65 | 67 |
| 66 // Loads a list of matching password forms into the specified vector |forms|. | 68 // Loads a list of matching password forms into the specified vector |forms|. |
| 67 // The list will contain all possibly relevant entries to the observed |form|, | 69 // The list will contain all possibly relevant entries to the observed |form|, |
| 68 // including blacklisted matches. The caller owns |forms| after the call. | 70 // including blacklisted matches. |
| 69 bool GetLogins(const autofill::PasswordForm& form, | 71 bool GetLogins(const autofill::PasswordForm& form, |
| 70 std::vector<autofill::PasswordForm*>* forms) const; | 72 ScopedVector<autofill::PasswordForm>* forms) const; |
| 71 | 73 |
| 72 // Loads all logins created from |begin| onwards (inclusive) and before |end|. | 74 // Loads all logins created from |begin| onwards (inclusive) and before |end|. |
| 73 // You may use a null Time value to do an unbounded search in either | 75 // You may use a null Time value to do an unbounded search in either |
| 74 // direction. The caller owns |forms| after the call. | 76 // direction. |
| 75 bool GetLoginsCreatedBetween( | 77 bool GetLoginsCreatedBetween( |
| 76 base::Time begin, | 78 base::Time begin, |
| 77 base::Time end, | 79 base::Time end, |
| 78 std::vector<autofill::PasswordForm*>* forms) const; | 80 ScopedVector<autofill::PasswordForm>* forms) const; |
| 79 | 81 |
| 80 // Loads all logins synced from |begin| onwards (inclusive) and before |end|. | 82 // Loads all logins synced from |begin| onwards (inclusive) and before |end|. |
| 81 // You may use a null Time value to do an unbounded search in either | 83 // You may use a null Time value to do an unbounded search in either |
| 82 // direction. The caller owns |forms| after the call. | 84 // direction. |
| 83 bool GetLoginsSyncedBetween( | 85 bool GetLoginsSyncedBetween( |
| 84 base::Time begin, | 86 base::Time begin, |
| 85 base::Time end, | 87 base::Time end, |
| 86 std::vector<autofill::PasswordForm*>* forms) const; | 88 ScopedVector<autofill::PasswordForm>* forms) const; |
| 87 | 89 |
| 88 // Loads the complete list of autofillable password forms (i.e., not blacklist | 90 // Loads the complete list of autofillable password forms (i.e., not blacklist |
| 89 // entries) into |forms|. The caller owns |forms| after the call. | 91 // entries) into |forms|. |
| 90 bool GetAutofillableLogins(std::vector<autofill::PasswordForm*>* forms) const; | 92 bool GetAutofillableLogins(ScopedVector<autofill::PasswordForm>* forms) const; |
| 91 | 93 |
| 92 // Loads the complete list of blacklist forms into |forms|. The caller owns | 94 // Loads the complete list of blacklist forms into |forms|. |
| 93 // |forms| after the call. | 95 bool GetBlacklistLogins(ScopedVector<autofill::PasswordForm>* forms) const; |
| 94 bool GetBlacklistLogins(std::vector<autofill::PasswordForm*>* forms) const; | |
| 95 | 96 |
| 96 // Deletes the login database file on disk, and creates a new, empty database. | 97 // Deletes the login database file on disk, and creates a new, empty database. |
| 97 // This can be used after migrating passwords to some other store, to ensure | 98 // This can be used after migrating passwords to some other store, to ensure |
| 98 // that SQLite doesn't leave fragments of passwords in the database file. | 99 // that SQLite doesn't leave fragments of passwords in the database file. |
| 99 // Returns true on success; otherwise, whether the file was deleted and | 100 // Returns true on success; otherwise, whether the file was deleted and |
| 100 // whether further use of this login database will succeed is unspecified. | 101 // whether further use of this login database will succeed is unspecified. |
| 101 bool DeleteAndRecreateDatabaseFile(); | 102 bool DeleteAndRecreateDatabaseFile(); |
| 102 | 103 |
| 103 private: | 104 private: |
| 104 // Result values for encryption/decryption actions. | 105 // Result values for encryption/decryption actions. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 // be of the form used by the Get*Logins methods). | 137 // be of the form used by the Get*Logins methods). |
| 137 // Returns the EncryptionResult from decrypting the password in |s|; if not | 138 // Returns the EncryptionResult from decrypting the password in |s|; if not |
| 138 // ENCRYPTION_RESULT_SUCCESS, |form| is not filled. | 139 // ENCRYPTION_RESULT_SUCCESS, |form| is not filled. |
| 139 EncryptionResult InitPasswordFormFromStatement(autofill::PasswordForm* form, | 140 EncryptionResult InitPasswordFormFromStatement(autofill::PasswordForm* form, |
| 140 sql::Statement& s) const; | 141 sql::Statement& s) const; |
| 141 | 142 |
| 142 // Loads all logins whose blacklist setting matches |blacklisted| into | 143 // Loads all logins whose blacklist setting matches |blacklisted| into |
| 143 // |forms|. | 144 // |forms|. |
| 144 bool GetAllLoginsWithBlacklistSetting( | 145 bool GetAllLoginsWithBlacklistSetting( |
| 145 bool blacklisted, | 146 bool blacklisted, |
| 146 std::vector<autofill::PasswordForm*>* forms) const; | 147 ScopedVector<autofill::PasswordForm>* forms) const; |
| 147 | 148 |
| 148 base::FilePath db_path_; | 149 base::FilePath db_path_; |
| 149 mutable sql::Connection db_; | 150 mutable sql::Connection db_; |
| 150 sql::MetaTable meta_table_; | 151 sql::MetaTable meta_table_; |
| 151 | 152 |
| 152 DISALLOW_COPY_AND_ASSIGN(LoginDatabase); | 153 DISALLOW_COPY_AND_ASSIGN(LoginDatabase); |
| 153 }; | 154 }; |
| 154 | 155 |
| 155 } // namespace password_manager | 156 } // namespace password_manager |
| 156 | 157 |
| 157 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOGIN_DATABASE_H_ | 158 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOGIN_DATABASE_H_ |
| OLD | NEW |