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