Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(845)

Side by Side Diff: components/password_manager/core/browser/login_database.h

Issue 906973007: PasswordStore: Clean up expectations about rewriting vectors of forms (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Linux compile Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 // delete in either direction. 62 // delete in either direction.
63 bool RemoveLoginsCreatedBetween(base::Time delete_begin, 63 bool RemoveLoginsCreatedBetween(base::Time delete_begin,
64 base::Time delete_end); 64 base::Time delete_end);
65 65
66 // Removes all logins synced from |delete_begin| onwards (inclusive) and 66 // Removes all logins synced from |delete_begin| onwards (inclusive) and
67 // before |delete_end|. You may use a null Time value to do an unbounded 67 // before |delete_end|. You may use a null Time value to do an unbounded
68 // delete in either direction. 68 // delete in either direction.
69 bool RemoveLoginsSyncedBetween(base::Time delete_begin, 69 bool RemoveLoginsSyncedBetween(base::Time delete_begin,
70 base::Time delete_end); 70 base::Time delete_end);
71 71
72 // Loads a list of matching password forms into the specified vector |forms|. 72 // All Get* methods below overwrite |forms| with the returned credentials. On
73 // The list will contain all possibly relevant entries to the observed |form|, 73 // success, those methods return true.
74 // including blacklisted matches. 74
75 // Gets a list of credentials matching |form|, including blacklisted matches.
75 bool GetLogins(const autofill::PasswordForm& form, 76 bool GetLogins(const autofill::PasswordForm& form,
76 ScopedVector<autofill::PasswordForm>* forms) const; 77 ScopedVector<autofill::PasswordForm>* forms) const
78 WARN_UNUSED_RESULT;
77 79
78 // Loads all logins created from |begin| onwards (inclusive) and before |end|. 80 // Gets all logins created from |begin| onwards (inclusive) and before |end|.
79 // You may use a null Time value to do an unbounded search in either 81 // You may use a null Time value to do an unbounded search in either
80 // direction. 82 // direction.
81 bool GetLoginsCreatedBetween( 83 bool GetLoginsCreatedBetween(
82 base::Time begin, 84 base::Time begin,
83 base::Time end, 85 base::Time end,
84 ScopedVector<autofill::PasswordForm>* forms) const; 86 ScopedVector<autofill::PasswordForm>* forms) const WARN_UNUSED_RESULT;
85 87
86 // Loads all logins synced from |begin| onwards (inclusive) and before |end|. 88 // Gets all logins synced from |begin| onwards (inclusive) and before |end|.
87 // You may use a null Time value to do an unbounded search in either 89 // You may use a null Time value to do an unbounded search in either
88 // direction. 90 // direction.
89 bool GetLoginsSyncedBetween( 91 bool GetLoginsSyncedBetween(base::Time begin,
90 base::Time begin, 92 base::Time end,
91 base::Time end, 93 ScopedVector<autofill::PasswordForm>* forms) const
92 ScopedVector<autofill::PasswordForm>* forms) const; 94 WARN_UNUSED_RESULT;
93 95
94 // Loads the complete list of autofillable password forms (i.e., not blacklist 96 // Gets the complete list of not blacklisted credentials.
95 // entries) into |forms|. 97 bool GetAutofillableLogins(ScopedVector<autofill::PasswordForm>* forms) const
96 bool GetAutofillableLogins(ScopedVector<autofill::PasswordForm>* forms) const; 98 WARN_UNUSED_RESULT;
97 99
98 // Loads the complete list of blacklist forms into |forms|. 100 // Gets the complete list of blacklisted credentials.
99 bool GetBlacklistLogins(ScopedVector<autofill::PasswordForm>* forms) const; 101 bool GetBlacklistLogins(ScopedVector<autofill::PasswordForm>* forms) const
102 WARN_UNUSED_RESULT;
100 103
101 // Deletes the login database file on disk, and creates a new, empty database. 104 // Deletes the login database file on disk, and creates a new, empty database.
102 // This can be used after migrating passwords to some other store, to ensure 105 // This can be used after migrating passwords to some other store, to ensure
103 // that SQLite doesn't leave fragments of passwords in the database file. 106 // that SQLite doesn't leave fragments of passwords in the database file.
104 // Returns true on success; otherwise, whether the file was deleted and 107 // Returns true on success; otherwise, whether the file was deleted and
105 // whether further use of this login database will succeed is unspecified. 108 // whether further use of this login database will succeed is unspecified.
106 bool DeleteAndRecreateDatabaseFile(); 109 bool DeleteAndRecreateDatabaseFile();
107 110
108 private: 111 private:
109 // Result values for encryption/decryption actions. 112 // Result values for encryption/decryption actions.
110 enum EncryptionResult { 113 enum EncryptionResult {
111 // Success. 114 // Success.
112 ENCRYPTION_RESULT_SUCCESS, 115 ENCRYPTION_RESULT_SUCCESS,
113 // Failure for a specific item (e.g., the encrypted value was manually 116 // Failure for a specific item (e.g., the encrypted value was manually
114 // moved from another machine, and can't be decrypted on this machine). 117 // moved from another machine, and can't be decrypted on this machine).
115 // This is presumed to be a permanent failure. 118 // This is presumed to be a permanent failure.
116 ENCRYPTION_RESULT_ITEM_FAILURE, 119 ENCRYPTION_RESULT_ITEM_FAILURE,
117 // A service-level failure (e.g., on a platform using a keyring, the keyring 120 // A service-level failure (e.g., on a platform using a keyring, the keyring
118 // is temporarily unavailable). 121 // is temporarily unavailable).
119 // This is presumed to be a temporary failure. 122 // This is presumed to be a temporary failure.
120 ENCRYPTION_RESULT_SERVICE_FAILURE, 123 ENCRYPTION_RESULT_SERVICE_FAILURE,
121 }; 124 };
122 125
123 // Encrypts plain_text, setting the value of cipher_text and returning true if 126 // Encrypts plain_text, setting the value of cipher_text and returning true if
124 // successful, or returning false and leaving cipher_text unchanged if 127 // successful, or returning false and leaving cipher_text unchanged if
125 // encryption fails (e.g., if the underlying OS encryption system is 128 // encryption fails (e.g., if the underlying OS encryption system is
126 // temporarily unavailable). 129 // temporarily unavailable).
127 EncryptionResult EncryptedString(const base::string16& plain_text, 130 static EncryptionResult EncryptedString(const base::string16& plain_text,
128 std::string* cipher_text) const; 131 std::string* cipher_text);
129 132
130 // Decrypts cipher_text, setting the value of plain_text and returning true if 133 // Decrypts cipher_text, setting the value of plain_text and returning true if
131 // successful, or returning false and leaving plain_text unchanged if 134 // successful, or returning false and leaving plain_text unchanged if
132 // decryption fails (e.g., if the underlying OS encryption system is 135 // decryption fails (e.g., if the underlying OS encryption system is
133 // temporarily unavailable). 136 // temporarily unavailable).
134 EncryptionResult DecryptedString(const std::string& cipher_text, 137 static EncryptionResult DecryptedString(const std::string& cipher_text,
135 base::string16* plain_text) const; 138 base::string16* plain_text);
136 139
137 bool InitLoginsTable(); 140 bool InitLoginsTable();
138 bool MigrateOldVersionsAsNeeded(); 141 bool MigrateOldVersionsAsNeeded();
139 142
140 // Fills |form| from the values in the given statement (which is assumed to 143 // Fills |form| from the values in the given statement (which is assumed to
141 // be of the form used by the Get*Logins methods). 144 // be of the form used by the Get*Logins methods).
142 // Returns the EncryptionResult from decrypting the password in |s|; if not 145 // Returns the EncryptionResult from decrypting the password in |s|; if not
143 // ENCRYPTION_RESULT_SUCCESS, |form| is not filled. 146 // ENCRYPTION_RESULT_SUCCESS, |form| is not filled.
144 EncryptionResult InitPasswordFormFromStatement(autofill::PasswordForm* form, 147 static EncryptionResult InitPasswordFormFromStatement(
145 sql::Statement& s) const; 148 autofill::PasswordForm* form,
149 sql::Statement& s);
146 150
147 // Loads all logins whose blacklist setting matches |blacklisted| into 151 // Gets all blacklisted or all non-blacklisted (depending on |blacklisted|)
148 // |forms|. 152 // credentials. On success returns true and overwrites |forms| with the
153 // result, otherwise returns false and clears |forms|.
engedy 2015/03/11 19:25:35 We should remove the promise about clearing forms
vabr (Chromium) 2015/03/12 15:30:51 Done.
149 bool GetAllLoginsWithBlacklistSetting( 154 bool GetAllLoginsWithBlacklistSetting(
150 bool blacklisted, 155 bool blacklisted,
151 ScopedVector<autofill::PasswordForm>* forms) const; 156 ScopedVector<autofill::PasswordForm>* forms) const;
152 157
158 // Overwrites |forms| with credentials retrieved from |statement|. If
159 // |psl_match| is not null, filters out all results but thos PSL-matching
160 // |*psl_match|. On success returns true, otherwise clears |forms| and returns
engedy 2015/03/11 19:25:35 Same here.
vabr (Chromium) 2015/03/12 15:30:51 Done.
161 // false.
162 static bool StatementToForms(sql::Statement* statement,
163 const autofill::PasswordForm* psl_match,
164 ScopedVector<autofill::PasswordForm>* forms);
165
153 base::FilePath db_path_; 166 base::FilePath db_path_;
154 mutable sql::Connection db_; 167 mutable sql::Connection db_;
155 sql::MetaTable meta_table_; 168 sql::MetaTable meta_table_;
156 169
157 DISALLOW_COPY_AND_ASSIGN(LoginDatabase); 170 DISALLOW_COPY_AND_ASSIGN(LoginDatabase);
158 }; 171 };
159 172
160 } // namespace password_manager 173 } // namespace password_manager
161 174
162 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOGIN_DATABASE_H_ 175 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_LOGIN_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698