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 "components/password_manager/core/browser/statistics_table.h" |
20 #include "sql/connection.h" | 20 #include "sql/connection.h" |
21 #include "sql/meta_table.h" | 21 #include "sql/meta_table.h" |
22 | 22 |
| 23 #if defined(OS_IOS) |
| 24 #include "base/gtest_prod_util.h" |
| 25 #endif |
| 26 |
23 namespace password_manager { | 27 namespace password_manager { |
24 | 28 |
25 extern const int kCurrentVersionNumber; | 29 extern const int kCurrentVersionNumber; |
26 | 30 |
27 // Interface to the database storage of login information, intended as a helper | 31 // Interface to the database storage of login information, intended as a helper |
28 // for PasswordStore on platforms that need internal storage of some or all of | 32 // for PasswordStore on platforms that need internal storage of some or all of |
29 // the login information. | 33 // the login information. |
30 class LoginDatabase { | 34 class LoginDatabase { |
31 public: | 35 public: |
32 LoginDatabase(const base::FilePath& db_path); | 36 LoginDatabase(const base::FilePath& db_path); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 bool GetBlacklistLogins(ScopedVector<autofill::PasswordForm>* forms) const | 106 bool GetBlacklistLogins(ScopedVector<autofill::PasswordForm>* forms) const |
103 WARN_UNUSED_RESULT; | 107 WARN_UNUSED_RESULT; |
104 | 108 |
105 // Deletes the login database file on disk, and creates a new, empty database. | 109 // Deletes the login database file on disk, and creates a new, empty database. |
106 // This can be used after migrating passwords to some other store, to ensure | 110 // This can be used after migrating passwords to some other store, to ensure |
107 // that SQLite doesn't leave fragments of passwords in the database file. | 111 // that SQLite doesn't leave fragments of passwords in the database file. |
108 // Returns true on success; otherwise, whether the file was deleted and | 112 // Returns true on success; otherwise, whether the file was deleted and |
109 // whether further use of this login database will succeed is unspecified. | 113 // whether further use of this login database will succeed is unspecified. |
110 bool DeleteAndRecreateDatabaseFile(); | 114 bool DeleteAndRecreateDatabaseFile(); |
111 | 115 |
| 116 // Returns the encrypted password value for the specified |form|. Returns an |
| 117 // empty string if the row for this |form| is not found. |
| 118 std::string GetEncryptedPassword(const autofill::PasswordForm& form) const; |
| 119 |
112 StatisticsTable& stats_table() { return stats_table_; } | 120 StatisticsTable& stats_table() { return stats_table_; } |
113 | 121 |
114 void set_clear_password_values(bool val) { clear_password_values_ = val; } | 122 void set_clear_password_values(bool val) { clear_password_values_ = val; } |
115 | 123 |
116 private: | 124 private: |
| 125 #if defined(OS_IOS) |
| 126 friend class LoginDatabaseIOSTest; |
| 127 FRIEND_TEST_ALL_PREFIXES(LoginDatabaseIOSTest, KeychainStorage); |
| 128 |
| 129 // On iOS, removes the keychain item that is used to store the |
| 130 // encrypted password for the supplied |form|. |
| 131 void DeleteEncryptedPassword(const autofill::PasswordForm& form); |
| 132 #endif |
| 133 |
117 // Result values for encryption/decryption actions. | 134 // Result values for encryption/decryption actions. |
118 enum EncryptionResult { | 135 enum EncryptionResult { |
119 // Success. | 136 // Success. |
120 ENCRYPTION_RESULT_SUCCESS, | 137 ENCRYPTION_RESULT_SUCCESS, |
121 // Failure for a specific item (e.g., the encrypted value was manually | 138 // Failure for a specific item (e.g., the encrypted value was manually |
122 // moved from another machine, and can't be decrypted on this machine). | 139 // moved from another machine, and can't be decrypted on this machine). |
123 // This is presumed to be a permanent failure. | 140 // This is presumed to be a permanent failure. |
124 ENCRYPTION_RESULT_ITEM_FAILURE, | 141 ENCRYPTION_RESULT_ITEM_FAILURE, |
125 // A service-level failure (e.g., on a platform using a keyring, the keyring | 142 // A service-level failure (e.g., on a platform using a keyring, the keyring |
126 // is temporarily unavailable). | 143 // is temporarily unavailable). |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 // This is a temporary measure for migration the Keychain on Mac. | 195 // This is a temporary measure for migration the Keychain on Mac. |
179 // crbug.com/466638 | 196 // crbug.com/466638 |
180 bool clear_password_values_; | 197 bool clear_password_values_; |
181 | 198 |
182 DISALLOW_COPY_AND_ASSIGN(LoginDatabase); | 199 DISALLOW_COPY_AND_ASSIGN(LoginDatabase); |
183 }; | 200 }; |
184 | 201 |
185 } // namespace password_manager | 202 } // namespace password_manager |
186 | 203 |
187 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOGIN_DATABASE_H_ | 204 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOGIN_DATABASE_H_ |
OLD | NEW |