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/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
13 #include "base/memory/scoped_vector.h" | 13 #include "base/memory/scoped_vector.h" |
14 #include "base/pickle.h" | 14 #include "base/pickle.h" |
15 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
16 #include "components/password_manager/core/browser/password_store.h" | 16 #include "components/password_manager/core/browser/password_store.h" |
17 #include "components/password_manager/core/browser/password_store_change.h" | 17 #include "components/password_manager/core/browser/password_store_change.h" |
18 #include "components/password_manager/core/browser/psl_matching_helper.h" | 18 #include "components/password_manager/core/browser/psl_matching_helper.h" |
| 19 #include "components/password_manager/core/browser/statistics_table.h" |
19 #include "sql/connection.h" | 20 #include "sql/connection.h" |
20 #include "sql/meta_table.h" | 21 #include "sql/meta_table.h" |
21 | 22 |
22 namespace password_manager { | 23 namespace password_manager { |
23 | 24 |
24 extern const int kCurrentVersionNumber; | 25 extern const int kCurrentVersionNumber; |
25 | 26 |
26 // Interface to the database storage of login information, intended as a helper | 27 // Interface to the database storage of login information, intended as a helper |
27 // for PasswordStore on platforms that need internal storage of some or all of | 28 // for PasswordStore on platforms that need internal storage of some or all of |
28 // the login information. | 29 // the login information. |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 bool GetBlacklistLogins(ScopedVector<autofill::PasswordForm>* forms) const | 102 bool GetBlacklistLogins(ScopedVector<autofill::PasswordForm>* forms) const |
102 WARN_UNUSED_RESULT; | 103 WARN_UNUSED_RESULT; |
103 | 104 |
104 // Deletes the login database file on disk, and creates a new, empty database. | 105 // Deletes the login database file on disk, and creates a new, empty database. |
105 // This can be used after migrating passwords to some other store, to ensure | 106 // This can be used after migrating passwords to some other store, to ensure |
106 // that SQLite doesn't leave fragments of passwords in the database file. | 107 // that SQLite doesn't leave fragments of passwords in the database file. |
107 // Returns true on success; otherwise, whether the file was deleted and | 108 // Returns true on success; otherwise, whether the file was deleted and |
108 // whether further use of this login database will succeed is unspecified. | 109 // whether further use of this login database will succeed is unspecified. |
109 bool DeleteAndRecreateDatabaseFile(); | 110 bool DeleteAndRecreateDatabaseFile(); |
110 | 111 |
| 112 StatisticsTable& stats_table() { return stats_table_; } |
| 113 |
111 private: | 114 private: |
112 // Result values for encryption/decryption actions. | 115 // Result values for encryption/decryption actions. |
113 enum EncryptionResult { | 116 enum EncryptionResult { |
114 // Success. | 117 // Success. |
115 ENCRYPTION_RESULT_SUCCESS, | 118 ENCRYPTION_RESULT_SUCCESS, |
116 // Failure for a specific item (e.g., the encrypted value was manually | 119 // Failure for a specific item (e.g., the encrypted value was manually |
117 // moved from another machine, and can't be decrypted on this machine). | 120 // moved from another machine, and can't be decrypted on this machine). |
118 // This is presumed to be a permanent failure. | 121 // This is presumed to be a permanent failure. |
119 ENCRYPTION_RESULT_ITEM_FAILURE, | 122 ENCRYPTION_RESULT_ITEM_FAILURE, |
120 // A service-level failure (e.g., on a platform using a keyring, the keyring | 123 // A service-level failure (e.g., on a platform using a keyring, the keyring |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 // Overwrites |forms| with credentials retrieved from |statement|. If | 161 // Overwrites |forms| with credentials retrieved from |statement|. If |
159 // |psl_match| is not null, filters out all results but thos PSL-matching | 162 // |psl_match| is not null, filters out all results but thos PSL-matching |
160 // |*psl_match|. On success returns true. | 163 // |*psl_match|. On success returns true. |
161 static bool StatementToForms(sql::Statement* statement, | 164 static bool StatementToForms(sql::Statement* statement, |
162 const autofill::PasswordForm* psl_match, | 165 const autofill::PasswordForm* psl_match, |
163 ScopedVector<autofill::PasswordForm>* forms); | 166 ScopedVector<autofill::PasswordForm>* forms); |
164 | 167 |
165 base::FilePath db_path_; | 168 base::FilePath db_path_; |
166 mutable sql::Connection db_; | 169 mutable sql::Connection db_; |
167 sql::MetaTable meta_table_; | 170 sql::MetaTable meta_table_; |
| 171 StatisticsTable stats_table_; |
168 | 172 |
169 DISALLOW_COPY_AND_ASSIGN(LoginDatabase); | 173 DISALLOW_COPY_AND_ASSIGN(LoginDatabase); |
170 }; | 174 }; |
171 | 175 |
172 } // namespace password_manager | 176 } // namespace password_manager |
173 | 177 |
174 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOGIN_DATABASE_H_ | 178 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOGIN_DATABASE_H_ |
OLD | NEW |