OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/browser/password_manager/login_database.h" | 5 #include "chrome/browser/password_manager/login_database.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/pickle.h" | 14 #include "base/pickle.h" |
15 #include "base/stringprintf.h" | |
15 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
16 #include "base/time.h" | 17 #include "base/time.h" |
17 #include "base/utf_string_conversions.h" | 18 #include "base/utf_string_conversions.h" |
18 #include "sql/statement.h" | 19 #include "sql/statement.h" |
19 #include "sql/transaction.h" | 20 #include "sql/transaction.h" |
20 | 21 |
21 using content::PasswordForm; | 22 using content::PasswordForm; |
22 | 23 |
23 static const int kCurrentVersionNumber = 2; | 24 static const int kCurrentVersionNumber = 3; |
24 static const int kCompatibleVersionNumber = 1; | 25 static const int kCompatibleVersionNumber = 1; |
25 | 26 |
26 namespace { | 27 namespace { |
27 | 28 |
28 // Convenience enum for interacting with SQL queries that use all the columns. | 29 // Convenience enum for interacting with SQL queries that use all the columns. |
29 enum LoginTableColumns { | 30 enum LoginTableColumns { |
30 COLUMN_ORIGIN_URL = 0, | 31 COLUMN_ORIGIN_URL = 0, |
31 COLUMN_ACTION_URL, | 32 COLUMN_ACTION_URL, |
32 COLUMN_USERNAME_ELEMENT, | 33 COLUMN_USERNAME_ELEMENT, |
33 COLUMN_USERNAME_VALUE, | 34 COLUMN_USERNAME_VALUE, |
34 COLUMN_PASSWORD_ELEMENT, | 35 COLUMN_PASSWORD_ELEMENT, |
35 COLUMN_PASSWORD_VALUE, | 36 COLUMN_PASSWORD_VALUE, |
36 COLUMN_SUBMIT_ELEMENT, | 37 COLUMN_SUBMIT_ELEMENT, |
37 COLUMN_SIGNON_REALM, | 38 COLUMN_SIGNON_REALM, |
38 COLUMN_SSL_VALID, | 39 COLUMN_SSL_VALID, |
39 COLUMN_PREFERRED, | 40 COLUMN_PREFERRED, |
40 COLUMN_DATE_CREATED, | 41 COLUMN_DATE_CREATED, |
41 COLUMN_BLACKLISTED_BY_USER, | 42 COLUMN_BLACKLISTED_BY_USER, |
42 COLUMN_SCHEME, | 43 COLUMN_SCHEME, |
43 COLUMN_PASSWORD_TYPE, | 44 COLUMN_PASSWORD_TYPE, |
44 COLUMN_POSSIBLE_USERNAMES | 45 COLUMN_POSSIBLE_USERNAMES, |
46 COLUMN_TIMES_USED | |
45 }; | 47 }; |
46 | 48 |
47 } // namespace | 49 } // namespace |
48 | 50 |
49 LoginDatabase::LoginDatabase() { | 51 LoginDatabase::LoginDatabase() { |
50 } | 52 } |
51 | 53 |
52 LoginDatabase::~LoginDatabase() { | 54 LoginDatabase::~LoginDatabase() { |
53 } | 55 } |
54 | 56 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 | 99 |
98 if (!transaction.Commit()) { | 100 if (!transaction.Commit()) { |
99 db_.Close(); | 101 db_.Close(); |
100 return false; | 102 return false; |
101 } | 103 } |
102 return true; | 104 return true; |
103 } | 105 } |
104 | 106 |
105 bool LoginDatabase::MigrateOldVersionsAsNeeded() { | 107 bool LoginDatabase::MigrateOldVersionsAsNeeded() { |
106 switch (meta_table_.GetVersionNumber()) { | 108 switch (meta_table_.GetVersionNumber()) { |
107 case kCompatibleVersionNumber: | 109 case 1: |
108 if (!db_.Execute("ALTER TABLE logins " | 110 if (!db_.Execute("ALTER TABLE logins " |
109 "ADD COLUMN password_type INTEGER") || | 111 "ADD COLUMN password_type INTEGER") || |
110 !db_.Execute("ALTER TABLE logins " | 112 !db_.Execute("ALTER TABLE logins " |
111 "ADD COLUMN possible_usernames BLOB")) { | 113 "ADD COLUMN possible_usernames BLOB")) { |
112 return false; | 114 return false; |
113 } else { | |
114 meta_table_.SetVersionNumber(kCurrentVersionNumber); | |
115 } | 115 } |
116 case 2: | |
117 if (!db_.Execute("ALTER TABLE logins " | |
118 "ADD COLUMN times_used INTEGER")) { | |
119 return false; | |
120 } | |
121 break; | |
122 case kCurrentVersionNumber: | |
123 // Already up to date | |
124 return true; | |
125 break; | |
126 default: | |
127 NOTREACHED(); | |
128 return false; | |
116 } | 129 } |
130 meta_table_.SetVersionNumber(kCurrentVersionNumber); | |
117 return true; | 131 return true; |
118 } | 132 } |
119 | 133 |
120 bool LoginDatabase::InitLoginsTable() { | 134 bool LoginDatabase::InitLoginsTable() { |
121 if (!db_.DoesTableExist("logins")) { | 135 if (!db_.DoesTableExist("logins")) { |
122 if (!db_.Execute("CREATE TABLE logins (" | 136 if (!db_.Execute("CREATE TABLE logins (" |
123 "origin_url VARCHAR NOT NULL, " | 137 "origin_url VARCHAR NOT NULL, " |
124 "action_url VARCHAR, " | 138 "action_url VARCHAR, " |
125 "username_element VARCHAR, " | 139 "username_element VARCHAR, " |
126 "username_value VARCHAR, " | 140 "username_value VARCHAR, " |
127 "password_element VARCHAR, " | 141 "password_element VARCHAR, " |
128 "password_value BLOB, " | 142 "password_value BLOB, " |
129 "submit_element VARCHAR, " | 143 "submit_element VARCHAR, " |
130 "signon_realm VARCHAR NOT NULL," | 144 "signon_realm VARCHAR NOT NULL," |
131 "ssl_valid INTEGER NOT NULL," | 145 "ssl_valid INTEGER NOT NULL," |
132 "preferred INTEGER NOT NULL," | 146 "preferred INTEGER NOT NULL," |
133 "date_created INTEGER NOT NULL," | 147 "date_created INTEGER NOT NULL," |
134 "blacklisted_by_user INTEGER NOT NULL," | 148 "blacklisted_by_user INTEGER NOT NULL," |
135 "scheme INTEGER NOT NULL," | 149 "scheme INTEGER NOT NULL," |
136 "password_type INTEGER," | 150 "password_type INTEGER," |
137 "possible_usernames BLOB," | 151 "possible_usernames BLOB," |
152 "times_used INTEGER," | |
138 "UNIQUE " | 153 "UNIQUE " |
139 "(origin_url, username_element, " | 154 "(origin_url, username_element, " |
140 "username_value, password_element, " | 155 "username_value, password_element, " |
141 "submit_element, signon_realm))")) { | 156 "submit_element, signon_realm))")) { |
142 NOTREACHED(); | 157 NOTREACHED(); |
143 return false; | 158 return false; |
144 } | 159 } |
145 if (!db_.Execute("CREATE INDEX logins_signon ON " | 160 if (!db_.Execute("CREATE INDEX logins_signon ON " |
146 "logins (signon_realm)")) { | 161 "logins (signon_realm)")) { |
147 NOTREACHED(); | 162 NOTREACHED(); |
(...skipping 13 matching lines...) Expand all Loading... | |
161 | 176 |
162 int total_accounts = 0; | 177 int total_accounts = 0; |
163 while (s.Step()) { | 178 while (s.Step()) { |
164 int accounts_per_site = s.ColumnInt(1); | 179 int accounts_per_site = s.ColumnInt(1); |
165 total_accounts += accounts_per_site; | 180 total_accounts += accounts_per_site; |
166 UMA_HISTOGRAM_CUSTOM_COUNTS("PasswordManager.AccountsPerSite", | 181 UMA_HISTOGRAM_CUSTOM_COUNTS("PasswordManager.AccountsPerSite", |
167 accounts_per_site, 0, 32, 6); | 182 accounts_per_site, 0, 32, 6); |
168 } | 183 } |
169 UMA_HISTOGRAM_CUSTOM_COUNTS("PasswordManager.TotalAccounts", | 184 UMA_HISTOGRAM_CUSTOM_COUNTS("PasswordManager.TotalAccounts", |
170 total_accounts, 0, 32, 6); | 185 total_accounts, 0, 32, 6); |
186 | |
187 sql::Statement usage_statement(db_.GetCachedStatement( | |
188 SQL_FROM_HERE, | |
189 "SELECT password_type, times_used FROM logins")); | |
190 | |
191 if (!usage_statement.is_valid()) | |
192 return; | |
193 | |
194 while (usage_statement.Step()) { | |
195 PasswordForm::Type type = static_cast<PasswordForm::Type>( | |
196 usage_statement.ColumnInt(0)); | |
197 | |
198 std::string password_type = ""; | |
199 if (type == PasswordForm::TYPE_GENERATED) | |
200 password_type = "Generated"; | |
201 | |
202 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
203 base::StringPrintf("PasswordManager.Times%sPasswordUsed", | |
vadimb1
2013/05/28 19:55:39
Does this work if the histogram name changes betwe
Garrett Casto
2013/05/28 21:00:22
Good catch. Changed.
| |
204 password_type.c_str()), | |
205 usage_statement.ColumnInt(1), 0, 100, 10); | |
206 } | |
171 } | 207 } |
172 | 208 |
173 bool LoginDatabase::AddLogin(const PasswordForm& form) { | 209 bool LoginDatabase::AddLogin(const PasswordForm& form) { |
174 std::string encrypted_password; | 210 std::string encrypted_password; |
175 if (!EncryptedString(form.password_value, &encrypted_password)) | 211 if (!EncryptedString(form.password_value, &encrypted_password)) |
176 return false; | 212 return false; |
177 | 213 |
178 // You *must* change LoginTableColumns if this query changes. | 214 // You *must* change LoginTableColumns if this query changes. |
179 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, | 215 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, |
180 "INSERT OR REPLACE INTO logins " | 216 "INSERT OR REPLACE INTO logins " |
181 "(origin_url, action_url, username_element, username_value, " | 217 "(origin_url, action_url, username_element, username_value, " |
182 " password_element, password_value, submit_element, " | 218 " password_element, password_value, submit_element, " |
183 " signon_realm, ssl_valid, preferred, date_created, " | 219 " signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " |
184 " blacklisted_by_user, scheme, password_type, possible_usernames) " | 220 " scheme, password_type, possible_usernames, times_used) " |
185 "VALUES " | 221 "VALUES " |
186 "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")); | 222 "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")); |
187 s.BindString(COLUMN_ORIGIN_URL, form.origin.spec()); | 223 s.BindString(COLUMN_ORIGIN_URL, form.origin.spec()); |
188 s.BindString(COLUMN_ACTION_URL, form.action.spec()); | 224 s.BindString(COLUMN_ACTION_URL, form.action.spec()); |
189 s.BindString16(COLUMN_USERNAME_ELEMENT, form.username_element); | 225 s.BindString16(COLUMN_USERNAME_ELEMENT, form.username_element); |
190 s.BindString16(COLUMN_USERNAME_VALUE, form.username_value); | 226 s.BindString16(COLUMN_USERNAME_VALUE, form.username_value); |
191 s.BindString16(COLUMN_PASSWORD_ELEMENT, form.password_element); | 227 s.BindString16(COLUMN_PASSWORD_ELEMENT, form.password_element); |
192 s.BindBlob(COLUMN_PASSWORD_VALUE, encrypted_password.data(), | 228 s.BindBlob(COLUMN_PASSWORD_VALUE, encrypted_password.data(), |
193 static_cast<int>(encrypted_password.length())); | 229 static_cast<int>(encrypted_password.length())); |
194 s.BindString16(COLUMN_SUBMIT_ELEMENT, form.submit_element); | 230 s.BindString16(COLUMN_SUBMIT_ELEMENT, form.submit_element); |
195 s.BindString(COLUMN_SIGNON_REALM, form.signon_realm); | 231 s.BindString(COLUMN_SIGNON_REALM, form.signon_realm); |
196 s.BindInt(COLUMN_SSL_VALID, form.ssl_valid); | 232 s.BindInt(COLUMN_SSL_VALID, form.ssl_valid); |
197 s.BindInt(COLUMN_PREFERRED, form.preferred); | 233 s.BindInt(COLUMN_PREFERRED, form.preferred); |
198 s.BindInt64(COLUMN_DATE_CREATED, form.date_created.ToTimeT()); | 234 s.BindInt64(COLUMN_DATE_CREATED, form.date_created.ToTimeT()); |
199 s.BindInt(COLUMN_BLACKLISTED_BY_USER, form.blacklisted_by_user); | 235 s.BindInt(COLUMN_BLACKLISTED_BY_USER, form.blacklisted_by_user); |
200 s.BindInt(COLUMN_SCHEME, form.scheme); | 236 s.BindInt(COLUMN_SCHEME, form.scheme); |
201 s.BindInt(COLUMN_PASSWORD_TYPE, form.type); | 237 s.BindInt(COLUMN_PASSWORD_TYPE, form.type); |
202 Pickle pickle = SerializeVector(form.possible_usernames); | 238 Pickle pickle = SerializeVector(form.possible_usernames); |
203 s.BindBlob(COLUMN_POSSIBLE_USERNAMES, pickle.data(), pickle.size()); | 239 s.BindBlob(COLUMN_POSSIBLE_USERNAMES, pickle.data(), pickle.size()); |
240 s.BindInt(COLUMN_TIMES_USED, form.times_used); | |
204 | 241 |
205 return s.Run(); | 242 return s.Run(); |
206 } | 243 } |
207 | 244 |
208 bool LoginDatabase::UpdateLogin(const PasswordForm& form, int* items_changed) { | 245 bool LoginDatabase::UpdateLogin(const PasswordForm& form, int* items_changed) { |
209 std::string encrypted_password; | 246 std::string encrypted_password; |
210 if (!EncryptedString(form.password_value, &encrypted_password)) | 247 if (!EncryptedString(form.password_value, &encrypted_password)) |
211 return false; | 248 return false; |
212 | 249 |
213 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, | 250 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, |
214 "UPDATE logins SET " | 251 "UPDATE logins SET " |
215 "action_url = ?, " | 252 "action_url = ?, " |
216 "password_value = ?, " | 253 "password_value = ?, " |
217 "ssl_valid = ?, " | 254 "ssl_valid = ?, " |
218 "preferred = ?, " | 255 "preferred = ?, " |
219 "possible_usernames = ? " | 256 "possible_usernames = ?, " |
257 "times_used = ? " | |
220 "WHERE origin_url = ? AND " | 258 "WHERE origin_url = ? AND " |
221 "username_element = ? AND " | 259 "username_element = ? AND " |
222 "username_value = ? AND " | 260 "username_value = ? AND " |
223 "password_element = ? AND " | 261 "password_element = ? AND " |
224 "signon_realm = ?")); | 262 "signon_realm = ?")); |
225 s.BindString(0, form.action.spec()); | 263 s.BindString(0, form.action.spec()); |
226 s.BindBlob(1, encrypted_password.data(), | 264 s.BindBlob(1, encrypted_password.data(), |
227 static_cast<int>(encrypted_password.length())); | 265 static_cast<int>(encrypted_password.length())); |
228 s.BindInt(2, form.ssl_valid); | 266 s.BindInt(2, form.ssl_valid); |
229 s.BindInt(3, form.preferred); | 267 s.BindInt(3, form.preferred); |
230 Pickle pickle = SerializeVector(form.possible_usernames); | 268 Pickle pickle = SerializeVector(form.possible_usernames); |
231 s.BindBlob(4, pickle.data(), pickle.size()); | 269 s.BindBlob(4, pickle.data(), pickle.size()); |
232 s.BindString(5, form.origin.spec()); | 270 s.BindInt(5, form.times_used); |
233 s.BindString16(6, form.username_element); | 271 s.BindString(6, form.origin.spec()); |
234 s.BindString16(7, form.username_value); | 272 s.BindString16(7, form.username_element); |
235 s.BindString16(8, form.password_element); | 273 s.BindString16(8, form.username_value); |
236 s.BindString(9, form.signon_realm); | 274 s.BindString16(9, form.password_element); |
275 s.BindString(10, form.signon_realm); | |
237 | 276 |
238 if (!s.Run()) | 277 if (!s.Run()) |
239 return false; | 278 return false; |
240 | 279 |
241 if (items_changed) | 280 if (items_changed) |
242 *items_changed = db_.GetLastChangeCount(); | 281 *items_changed = db_.GetLastChangeCount(); |
243 | 282 |
244 return true; | 283 return true; |
245 } | 284 } |
246 | 285 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
303 int scheme_int = s.ColumnInt(COLUMN_SCHEME); | 342 int scheme_int = s.ColumnInt(COLUMN_SCHEME); |
304 DCHECK((scheme_int >= 0) && (scheme_int <= PasswordForm::SCHEME_OTHER)); | 343 DCHECK((scheme_int >= 0) && (scheme_int <= PasswordForm::SCHEME_OTHER)); |
305 form->scheme = static_cast<PasswordForm::Scheme>(scheme_int); | 344 form->scheme = static_cast<PasswordForm::Scheme>(scheme_int); |
306 int type_int = s.ColumnInt(COLUMN_PASSWORD_TYPE); | 345 int type_int = s.ColumnInt(COLUMN_PASSWORD_TYPE); |
307 DCHECK(type_int >= 0 && type_int <= PasswordForm::TYPE_GENERATED); | 346 DCHECK(type_int >= 0 && type_int <= PasswordForm::TYPE_GENERATED); |
308 form->type = static_cast<PasswordForm::Type>(type_int); | 347 form->type = static_cast<PasswordForm::Type>(type_int); |
309 Pickle pickle( | 348 Pickle pickle( |
310 static_cast<const char*>(s.ColumnBlob(COLUMN_POSSIBLE_USERNAMES)), | 349 static_cast<const char*>(s.ColumnBlob(COLUMN_POSSIBLE_USERNAMES)), |
311 s.ColumnByteLength(COLUMN_POSSIBLE_USERNAMES)); | 350 s.ColumnByteLength(COLUMN_POSSIBLE_USERNAMES)); |
312 form->possible_usernames = DeserializeVector(pickle); | 351 form->possible_usernames = DeserializeVector(pickle); |
352 form->times_used = s.ColumnInt(COLUMN_TIMES_USED); | |
313 return true; | 353 return true; |
314 } | 354 } |
315 | 355 |
316 bool LoginDatabase::GetLogins(const PasswordForm& form, | 356 bool LoginDatabase::GetLogins(const PasswordForm& form, |
317 std::vector<PasswordForm*>* forms) const { | 357 std::vector<PasswordForm*>* forms) const { |
318 DCHECK(forms); | 358 DCHECK(forms); |
319 // You *must* change LoginTableColumns if this query changes. | 359 // You *must* change LoginTableColumns if this query changes. |
320 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, | 360 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, |
321 "SELECT origin_url, action_url, " | 361 "SELECT origin_url, action_url, " |
322 "username_element, username_value, " | 362 "username_element, username_value, " |
323 "password_element, password_value, " | 363 "password_element, password_value, submit_element, " |
324 "submit_element, signon_realm, ssl_valid, preferred, date_created, " | 364 "signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " |
325 "blacklisted_by_user, scheme, password_type, possible_usernames " | 365 "scheme, password_type, possible_usernames, times_used " |
326 "FROM logins WHERE signon_realm == ? ")); | 366 "FROM logins WHERE signon_realm == ? ")); |
327 s.BindString(0, form.signon_realm); | 367 s.BindString(0, form.signon_realm); |
328 | 368 |
329 while (s.Step()) { | 369 while (s.Step()) { |
330 scoped_ptr<PasswordForm> new_form(new PasswordForm()); | 370 scoped_ptr<PasswordForm> new_form(new PasswordForm()); |
331 if (!InitPasswordFormFromStatement(new_form.get(), s)) | 371 if (!InitPasswordFormFromStatement(new_form.get(), s)) |
332 return false; | 372 return false; |
333 forms->push_back(new_form.release()); | 373 forms->push_back(new_form.release()); |
334 } | 374 } |
335 return s.Succeeded(); | 375 return s.Succeeded(); |
336 } | 376 } |
337 | 377 |
338 bool LoginDatabase::GetLoginsCreatedBetween( | 378 bool LoginDatabase::GetLoginsCreatedBetween( |
339 const base::Time begin, | 379 const base::Time begin, |
340 const base::Time end, | 380 const base::Time end, |
341 std::vector<content::PasswordForm*>* forms) const { | 381 std::vector<content::PasswordForm*>* forms) const { |
342 DCHECK(forms); | 382 DCHECK(forms); |
343 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, | 383 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, |
344 "SELECT origin_url, action_url, " | 384 "SELECT origin_url, action_url, " |
345 "username_element, username_value, " | 385 "username_element, username_value, " |
346 "password_element, password_value, " | 386 "password_element, password_value, submit_element, " |
347 "submit_element, signon_realm, ssl_valid, preferred, date_created, " | 387 "signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " |
348 "blacklisted_by_user, scheme, password_type, possible_usernames " | 388 "scheme, password_type, possible_usernames, times_used " |
349 "FROM logins WHERE date_created >= ? AND date_created < ?" | 389 "FROM logins WHERE date_created >= ? AND date_created < ?" |
350 "ORDER BY origin_url")); | 390 "ORDER BY origin_url")); |
351 s.BindInt64(0, begin.ToTimeT()); | 391 s.BindInt64(0, begin.ToTimeT()); |
352 s.BindInt64(1, end.is_null() ? std::numeric_limits<int64>::max() | 392 s.BindInt64(1, end.is_null() ? std::numeric_limits<int64>::max() |
353 : end.ToTimeT()); | 393 : end.ToTimeT()); |
354 | 394 |
355 while (s.Step()) { | 395 while (s.Step()) { |
356 scoped_ptr<PasswordForm> new_form(new PasswordForm()); | 396 scoped_ptr<PasswordForm> new_form(new PasswordForm()); |
357 if (!InitPasswordFormFromStatement(new_form.get(), s)) | 397 if (!InitPasswordFormFromStatement(new_form.get(), s)) |
358 return false; | 398 return false; |
(...skipping 12 matching lines...) Expand all Loading... | |
371 return GetAllLoginsWithBlacklistSetting(true, forms); | 411 return GetAllLoginsWithBlacklistSetting(true, forms); |
372 } | 412 } |
373 | 413 |
374 bool LoginDatabase::GetAllLoginsWithBlacklistSetting( | 414 bool LoginDatabase::GetAllLoginsWithBlacklistSetting( |
375 bool blacklisted, std::vector<PasswordForm*>* forms) const { | 415 bool blacklisted, std::vector<PasswordForm*>* forms) const { |
376 DCHECK(forms); | 416 DCHECK(forms); |
377 // You *must* change LoginTableColumns if this query changes. | 417 // You *must* change LoginTableColumns if this query changes. |
378 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, | 418 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, |
379 "SELECT origin_url, action_url, " | 419 "SELECT origin_url, action_url, " |
380 "username_element, username_value, " | 420 "username_element, username_value, " |
381 "password_element, password_value, " | 421 "password_element, password_value, submit_element, " |
382 "submit_element, signon_realm, ssl_valid, preferred, date_created, " | 422 "signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " |
383 "blacklisted_by_user, scheme, password_type, possible_usernames " | 423 "scheme, password_type, possible_usernames, times_used " |
384 "FROM logins WHERE blacklisted_by_user == ? " | 424 "FROM logins WHERE blacklisted_by_user == ? " |
385 "ORDER BY origin_url")); | 425 "ORDER BY origin_url")); |
386 s.BindInt(0, blacklisted ? 1 : 0); | 426 s.BindInt(0, blacklisted ? 1 : 0); |
387 | 427 |
388 while (s.Step()) { | 428 while (s.Step()) { |
389 scoped_ptr<PasswordForm> new_form(new PasswordForm()); | 429 scoped_ptr<PasswordForm> new_form(new PasswordForm()); |
390 if (!InitPasswordFormFromStatement(new_form.get(), s)) | 430 if (!InitPasswordFormFromStatement(new_form.get(), s)) |
391 return false; | 431 return false; |
392 forms->push_back(new_form.release()); | 432 forms->push_back(new_form.release()); |
393 } | 433 } |
(...skipping 19 matching lines...) Expand all Loading... | |
413 std::vector<string16> LoginDatabase::DeserializeVector(const Pickle& p) const { | 453 std::vector<string16> LoginDatabase::DeserializeVector(const Pickle& p) const { |
414 std::vector<string16> ret; | 454 std::vector<string16> ret; |
415 string16 str; | 455 string16 str; |
416 | 456 |
417 PickleIterator iterator(p); | 457 PickleIterator iterator(p); |
418 while (iterator.ReadString16(&str)) { | 458 while (iterator.ReadString16(&str)) { |
419 ret.push_back(str); | 459 ret.push_back(str); |
420 } | 460 } |
421 return ret; | 461 return ret; |
422 } | 462 } |
OLD | NEW |