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 #include "components/password_manager/core/browser/login_database.h" | 5 #include "components/password_manager/core/browser/login_database.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.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/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
17 #include "components/autofill/core/common/password_form.h" | 17 #include "components/autofill/core/common/password_form.h" |
18 #include "google_apis/gaia/gaia_auth_util.h" | 18 #include "google_apis/gaia/gaia_auth_util.h" |
19 #include "google_apis/gaia/gaia_urls.h" | 19 #include "google_apis/gaia/gaia_urls.h" |
20 #include "sql/connection.h" | 20 #include "sql/connection.h" |
21 #include "sql/statement.h" | 21 #include "sql/statement.h" |
22 #include "sql/transaction.h" | 22 #include "sql/transaction.h" |
23 | 23 |
24 using autofill::PasswordForm; | 24 using autofill::PasswordForm; |
25 | 25 |
26 namespace password_manager { | 26 namespace password_manager { |
27 | 27 |
28 static const int kCurrentVersionNumber = 6; | 28 static const int kCurrentVersionNumber = 7; |
29 static const int kCompatibleVersionNumber = 1; | 29 static const int kCompatibleVersionNumber = 1; |
30 | 30 |
31 Pickle SerializeVector(const std::vector<base::string16>& vec) { | 31 Pickle SerializeVector(const std::vector<base::string16>& vec) { |
32 Pickle p; | 32 Pickle p; |
33 for (size_t i = 0; i < vec.size(); ++i) { | 33 for (size_t i = 0; i < vec.size(); ++i) { |
34 p.WriteString16(vec[i]); | 34 p.WriteString16(vec[i]); |
35 } | 35 } |
36 return p; | 36 return p; |
37 } | 37 } |
38 | 38 |
(...skipping 23 matching lines...) Expand all Loading... |
62 COLUMN_SSL_VALID, | 62 COLUMN_SSL_VALID, |
63 COLUMN_PREFERRED, | 63 COLUMN_PREFERRED, |
64 COLUMN_DATE_CREATED, | 64 COLUMN_DATE_CREATED, |
65 COLUMN_BLACKLISTED_BY_USER, | 65 COLUMN_BLACKLISTED_BY_USER, |
66 COLUMN_SCHEME, | 66 COLUMN_SCHEME, |
67 COLUMN_PASSWORD_TYPE, | 67 COLUMN_PASSWORD_TYPE, |
68 COLUMN_POSSIBLE_USERNAMES, | 68 COLUMN_POSSIBLE_USERNAMES, |
69 COLUMN_TIMES_USED, | 69 COLUMN_TIMES_USED, |
70 COLUMN_FORM_DATA, | 70 COLUMN_FORM_DATA, |
71 COLUMN_USE_ADDITIONAL_AUTH, | 71 COLUMN_USE_ADDITIONAL_AUTH, |
72 COLUMN_DATE_SYNCED | 72 COLUMN_DATE_SYNCED, |
| 73 COLUMN_DISPLAY_NAME, |
| 74 COLUMN_AVATAR_URL, |
| 75 COLUMN_FEDERATION_URL, |
| 76 COLUMN_IS_ZERO_CLICK, |
73 }; | 77 }; |
74 | 78 |
75 void BindAddStatement(const PasswordForm& form, | 79 void BindAddStatement(const PasswordForm& form, |
76 const std::string& encrypted_password, | 80 const std::string& encrypted_password, |
77 sql::Statement* s) { | 81 sql::Statement* s) { |
78 s->BindString(COLUMN_ORIGIN_URL, form.origin.spec()); | 82 s->BindString(COLUMN_ORIGIN_URL, form.origin.spec()); |
79 s->BindString(COLUMN_ACTION_URL, form.action.spec()); | 83 s->BindString(COLUMN_ACTION_URL, form.action.spec()); |
80 s->BindString16(COLUMN_USERNAME_ELEMENT, form.username_element); | 84 s->BindString16(COLUMN_USERNAME_ELEMENT, form.username_element); |
81 s->BindString16(COLUMN_USERNAME_VALUE, form.username_value); | 85 s->BindString16(COLUMN_USERNAME_VALUE, form.username_value); |
82 s->BindString16(COLUMN_PASSWORD_ELEMENT, form.password_element); | 86 s->BindString16(COLUMN_PASSWORD_ELEMENT, form.password_element); |
(...skipping 12 matching lines...) Expand all Loading... |
95 usernames_pickle.data(), | 99 usernames_pickle.data(), |
96 usernames_pickle.size()); | 100 usernames_pickle.size()); |
97 s->BindInt(COLUMN_TIMES_USED, form.times_used); | 101 s->BindInt(COLUMN_TIMES_USED, form.times_used); |
98 Pickle form_data_pickle; | 102 Pickle form_data_pickle; |
99 autofill::SerializeFormData(form.form_data, &form_data_pickle); | 103 autofill::SerializeFormData(form.form_data, &form_data_pickle); |
100 s->BindBlob(COLUMN_FORM_DATA, | 104 s->BindBlob(COLUMN_FORM_DATA, |
101 form_data_pickle.data(), | 105 form_data_pickle.data(), |
102 form_data_pickle.size()); | 106 form_data_pickle.size()); |
103 s->BindInt(COLUMN_USE_ADDITIONAL_AUTH, form.use_additional_authentication); | 107 s->BindInt(COLUMN_USE_ADDITIONAL_AUTH, form.use_additional_authentication); |
104 s->BindInt64(COLUMN_DATE_SYNCED, form.date_synced.ToInternalValue()); | 108 s->BindInt64(COLUMN_DATE_SYNCED, form.date_synced.ToInternalValue()); |
| 109 s->BindString16(COLUMN_DISPLAY_NAME, form.display_name); |
| 110 s->BindString(COLUMN_AVATAR_URL, form.avatar_url.spec()); |
| 111 s->BindString(COLUMN_FEDERATION_URL, form.federation_url.spec()); |
| 112 s->BindInt(COLUMN_IS_ZERO_CLICK, form.is_zero_click); |
105 } | 113 } |
106 | 114 |
107 void AddCallback(int err, sql::Statement* /*stmt*/) { | 115 void AddCallback(int err, sql::Statement* /*stmt*/) { |
108 if (err == 19 /*SQLITE_CONSTRAINT*/) | 116 if (err == 19 /*SQLITE_CONSTRAINT*/) |
109 DLOG(WARNING) << "LoginDatabase::AddLogin updated an existing form"; | 117 DLOG(WARNING) << "LoginDatabase::AddLogin updated an existing form"; |
110 } | 118 } |
111 | 119 |
112 } // namespace | 120 } // namespace |
113 | 121 |
114 LoginDatabase::LoginDatabase() { | 122 LoginDatabase::LoginDatabase() { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 meta_table_.SetVersionNumber(4); | 204 meta_table_.SetVersionNumber(4); |
197 // Fall through. | 205 // Fall through. |
198 case 4: | 206 case 4: |
199 if (!db_.Execute( | 207 if (!db_.Execute( |
200 "ALTER TABLE logins ADD COLUMN use_additional_auth INTEGER")) { | 208 "ALTER TABLE logins ADD COLUMN use_additional_auth INTEGER")) { |
201 return false; | 209 return false; |
202 } | 210 } |
203 meta_table_.SetVersionNumber(5); | 211 meta_table_.SetVersionNumber(5); |
204 // Fall through. | 212 // Fall through. |
205 case 5: | 213 case 5: |
206 if (!db_.Execute( | 214 if (!db_.Execute("ALTER TABLE logins ADD COLUMN date_synced INTEGER")) { |
207 "ALTER TABLE logins ADD COLUMN date_synced INTEGER")) { | |
208 return false; | 215 return false; |
209 } | 216 } |
210 meta_table_.SetVersionNumber(6); | 217 meta_table_.SetVersionNumber(6); |
211 // Fall through. | 218 // Fall through. |
| 219 case 6: |
| 220 if (!db_.Execute("ALTER TABLE logins ADD COLUMN display_name VARCHAR") || |
| 221 !db_.Execute("ALTER TABLE logins ADD COLUMN avatar_url VARCHAR") || |
| 222 !db_.Execute("ALTER TABLE logins " |
| 223 "ADD COLUMN federation_url VARCHAR") || |
| 224 !db_.Execute("ALTER TABLE logins ADD COLUMN is_zero_click INTEGER")) { |
| 225 return false; |
| 226 } |
| 227 meta_table_.SetVersionNumber(7); |
| 228 // Fall through. |
212 case kCurrentVersionNumber: | 229 case kCurrentVersionNumber: |
213 // Already up to date | 230 // Already up to date |
214 return true; | 231 return true; |
215 default: | 232 default: |
216 NOTREACHED(); | 233 NOTREACHED(); |
217 return false; | 234 return false; |
218 } | 235 } |
219 } | 236 } |
220 | 237 |
221 bool LoginDatabase::InitLoginsTable() { | 238 bool LoginDatabase::InitLoginsTable() { |
(...skipping 11 matching lines...) Expand all Loading... |
233 "preferred INTEGER NOT NULL," | 250 "preferred INTEGER NOT NULL," |
234 "date_created INTEGER NOT NULL," | 251 "date_created INTEGER NOT NULL," |
235 "blacklisted_by_user INTEGER NOT NULL," | 252 "blacklisted_by_user INTEGER NOT NULL," |
236 "scheme INTEGER NOT NULL," | 253 "scheme INTEGER NOT NULL," |
237 "password_type INTEGER," | 254 "password_type INTEGER," |
238 "possible_usernames BLOB," | 255 "possible_usernames BLOB," |
239 "times_used INTEGER," | 256 "times_used INTEGER," |
240 "form_data BLOB," | 257 "form_data BLOB," |
241 "use_additional_auth INTEGER," | 258 "use_additional_auth INTEGER," |
242 "date_synced INTEGER," | 259 "date_synced INTEGER," |
| 260 "display_name VARCHAR," |
| 261 "avatar_url VARCHAR," |
| 262 "federation_url VARCHAR," |
| 263 "is_zero_click INTEGER," |
243 "UNIQUE " | 264 "UNIQUE " |
244 "(origin_url, username_element, " | 265 "(origin_url, username_element, " |
245 "username_value, password_element, " | 266 "username_value, password_element, " |
246 "submit_element, signon_realm))")) { | 267 "submit_element, signon_realm))")) { |
247 NOTREACHED(); | 268 NOTREACHED(); |
248 return false; | 269 return false; |
249 } | 270 } |
250 if (!db_.Execute("CREATE INDEX logins_signon ON " | 271 if (!db_.Execute("CREATE INDEX logins_signon ON " |
251 "logins (signon_realm)")) { | 272 "logins (signon_realm)")) { |
252 NOTREACHED(); | 273 NOTREACHED(); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 ENCRYPTION_RESULT_SUCCESS) | 358 ENCRYPTION_RESULT_SUCCESS) |
338 return list; | 359 return list; |
339 | 360 |
340 // You *must* change LoginTableColumns if this query changes. | 361 // You *must* change LoginTableColumns if this query changes. |
341 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, | 362 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, |
342 "INSERT INTO logins " | 363 "INSERT INTO logins " |
343 "(origin_url, action_url, username_element, username_value, " | 364 "(origin_url, action_url, username_element, username_value, " |
344 " password_element, password_value, submit_element, " | 365 " password_element, password_value, submit_element, " |
345 " signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " | 366 " signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " |
346 " scheme, password_type, possible_usernames, times_used, form_data, " | 367 " scheme, password_type, possible_usernames, times_used, form_data, " |
347 " use_additional_auth, date_synced) VALUES " | 368 " use_additional_auth, date_synced, display_name, avatar_url," |
348 "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")); | 369 " federation_url, is_zero_click) VALUES " |
| 370 "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")); |
349 BindAddStatement(form, encrypted_password, &s); | 371 BindAddStatement(form, encrypted_password, &s); |
350 db_.set_error_callback(base::Bind(&AddCallback)); | 372 db_.set_error_callback(base::Bind(&AddCallback)); |
351 const bool success = s.Run(); | 373 const bool success = s.Run(); |
352 db_.reset_error_callback(); | 374 db_.reset_error_callback(); |
353 if (success) { | 375 if (success) { |
354 list.push_back(PasswordStoreChange(PasswordStoreChange::ADD, form)); | 376 list.push_back(PasswordStoreChange(PasswordStoreChange::ADD, form)); |
355 return list; | 377 return list; |
356 } | 378 } |
357 // Repeat the same statement but with REPLACE semantic. | 379 // Repeat the same statement but with REPLACE semantic. |
358 s.Assign(db_.GetCachedStatement(SQL_FROM_HERE, | 380 s.Assign(db_.GetCachedStatement(SQL_FROM_HERE, |
359 "INSERT OR REPLACE INTO logins " | 381 "INSERT OR REPLACE INTO logins " |
360 "(origin_url, action_url, username_element, username_value, " | 382 "(origin_url, action_url, username_element, username_value, " |
361 " password_element, password_value, submit_element, " | 383 " password_element, password_value, submit_element, " |
362 " signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " | 384 " signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " |
363 " scheme, password_type, possible_usernames, times_used, form_data, " | 385 " scheme, password_type, possible_usernames, times_used, form_data, " |
364 " use_additional_auth, date_synced) VALUES " | 386 " use_additional_auth, date_synced, display_name, avatar_url," |
365 "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")); | 387 " federation_url, is_zero_click) VALUES " |
| 388 "(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")); |
366 BindAddStatement(form, encrypted_password, &s); | 389 BindAddStatement(form, encrypted_password, &s); |
367 if (s.Run()) { | 390 if (s.Run()) { |
368 list.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, form)); | 391 list.push_back(PasswordStoreChange(PasswordStoreChange::REMOVE, form)); |
369 list.push_back(PasswordStoreChange(PasswordStoreChange::ADD, form)); | 392 list.push_back(PasswordStoreChange(PasswordStoreChange::ADD, form)); |
370 } | 393 } |
371 return list; | 394 return list; |
372 } | 395 } |
373 | 396 |
374 PasswordStoreChangeList LoginDatabase::UpdateLogin(const PasswordForm& form) { | 397 PasswordStoreChangeList LoginDatabase::UpdateLogin(const PasswordForm& form) { |
375 std::string encrypted_password; | 398 std::string encrypted_password; |
376 if (EncryptedString(form.password_value, &encrypted_password) != | 399 if (EncryptedString(form.password_value, &encrypted_password) != |
377 ENCRYPTION_RESULT_SUCCESS) | 400 ENCRYPTION_RESULT_SUCCESS) |
378 return PasswordStoreChangeList(); | 401 return PasswordStoreChangeList(); |
379 | 402 |
380 // Replacement is necessary to deal with updating imported credentials. See | 403 // Replacement is necessary to deal with updating imported credentials. See |
381 // crbug.com/349138 for details. | 404 // crbug.com/349138 for details. |
382 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, | 405 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, |
383 "UPDATE OR REPLACE logins SET " | 406 "UPDATE OR REPLACE logins SET " |
384 "action_url = ?, " | 407 "action_url = ?, " |
385 "password_value = ?, " | 408 "password_value = ?, " |
386 "ssl_valid = ?, " | 409 "ssl_valid = ?, " |
387 "preferred = ?, " | 410 "preferred = ?, " |
388 "possible_usernames = ?, " | 411 "possible_usernames = ?, " |
389 "times_used = ?, " | 412 "times_used = ?, " |
390 "submit_element = ?, " | 413 "submit_element = ?, " |
391 "date_synced = ?, " | 414 "date_synced = ?, " |
392 "date_created = ?, " | 415 "date_created = ?, " |
393 "blacklisted_by_user = ?, " | 416 "blacklisted_by_user = ?, " |
394 "scheme = ?, " | 417 "scheme = ?, " |
395 "password_type = ? " | 418 "password_type = ?, " |
| 419 "display_name = ?, " |
| 420 "avatar_url = ?, " |
| 421 "federation_url = ?, " |
| 422 "is_zero_click = ? " |
396 "WHERE origin_url = ? AND " | 423 "WHERE origin_url = ? AND " |
397 "username_element = ? AND " | 424 "username_element = ? AND " |
398 "username_value = ? AND " | 425 "username_value = ? AND " |
399 "password_element = ? AND " | 426 "password_element = ? AND " |
400 "signon_realm = ?")); | 427 "signon_realm = ?")); |
401 s.BindString(0, form.action.spec()); | 428 s.BindString(0, form.action.spec()); |
402 s.BindBlob(1, encrypted_password.data(), | 429 s.BindBlob(1, encrypted_password.data(), |
403 static_cast<int>(encrypted_password.length())); | 430 static_cast<int>(encrypted_password.length())); |
404 s.BindInt(2, form.ssl_valid); | 431 s.BindInt(2, form.ssl_valid); |
405 s.BindInt(3, form.preferred); | 432 s.BindInt(3, form.preferred); |
406 Pickle pickle = SerializeVector(form.other_possible_usernames); | 433 Pickle pickle = SerializeVector(form.other_possible_usernames); |
407 s.BindBlob(4, pickle.data(), pickle.size()); | 434 s.BindBlob(4, pickle.data(), pickle.size()); |
408 s.BindInt(5, form.times_used); | 435 s.BindInt(5, form.times_used); |
409 s.BindString16(6, form.submit_element); | 436 s.BindString16(6, form.submit_element); |
410 s.BindInt64(7, form.date_synced.ToInternalValue()); | 437 s.BindInt64(7, form.date_synced.ToInternalValue()); |
411 s.BindInt64(8, form.date_created.ToTimeT()); | 438 s.BindInt64(8, form.date_created.ToTimeT()); |
412 s.BindInt(9, form.blacklisted_by_user); | 439 s.BindInt(9, form.blacklisted_by_user); |
413 s.BindInt(10, form.scheme); | 440 s.BindInt(10, form.scheme); |
414 s.BindInt(11, form.type); | 441 s.BindInt(11, form.type); |
| 442 s.BindString16(12, form.display_name); |
| 443 s.BindString(13, form.avatar_url.spec()); |
| 444 s.BindString(14, form.federation_url.spec()); |
| 445 s.BindInt(15, form.is_zero_click); |
415 | 446 |
416 s.BindString(12, form.origin.spec()); | 447 // WHERE starts here. |
417 s.BindString16(13, form.username_element); | 448 s.BindString(16, form.origin.spec()); |
418 s.BindString16(14, form.username_value); | 449 s.BindString16(17, form.username_element); |
419 s.BindString16(15, form.password_element); | 450 s.BindString16(18, form.username_value); |
420 s.BindString(16, form.signon_realm); | 451 s.BindString16(19, form.password_element); |
| 452 s.BindString(20, form.signon_realm); |
421 | 453 |
422 if (!s.Run()) | 454 if (!s.Run()) |
423 return PasswordStoreChangeList(); | 455 return PasswordStoreChangeList(); |
424 | 456 |
425 PasswordStoreChangeList list; | 457 PasswordStoreChangeList list; |
426 if (db_.GetLastChangeCount()) | 458 if (db_.GetLastChangeCount()) |
427 list.push_back(PasswordStoreChange(PasswordStoreChange::UPDATE, form)); | 459 list.push_back(PasswordStoreChange(PasswordStoreChange::UPDATE, form)); |
428 | 460 |
429 return list; | 461 return list; |
430 } | 462 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 Pickle form_data_pickle( | 550 Pickle form_data_pickle( |
519 static_cast<const char*>(s.ColumnBlob(COLUMN_FORM_DATA)), | 551 static_cast<const char*>(s.ColumnBlob(COLUMN_FORM_DATA)), |
520 s.ColumnByteLength(COLUMN_FORM_DATA)); | 552 s.ColumnByteLength(COLUMN_FORM_DATA)); |
521 PickleIterator form_data_iter(form_data_pickle); | 553 PickleIterator form_data_iter(form_data_pickle); |
522 autofill::DeserializeFormData(&form_data_iter, &form->form_data); | 554 autofill::DeserializeFormData(&form_data_iter, &form->form_data); |
523 } | 555 } |
524 form->use_additional_authentication = | 556 form->use_additional_authentication = |
525 (s.ColumnInt(COLUMN_USE_ADDITIONAL_AUTH) > 0); | 557 (s.ColumnInt(COLUMN_USE_ADDITIONAL_AUTH) > 0); |
526 form->date_synced = base::Time::FromInternalValue( | 558 form->date_synced = base::Time::FromInternalValue( |
527 s.ColumnInt64(COLUMN_DATE_SYNCED)); | 559 s.ColumnInt64(COLUMN_DATE_SYNCED)); |
| 560 form->display_name = s.ColumnString16(COLUMN_DISPLAY_NAME); |
| 561 form->avatar_url = GURL(s.ColumnString(COLUMN_AVATAR_URL)); |
| 562 form->federation_url = GURL(s.ColumnString(COLUMN_FEDERATION_URL)); |
| 563 form->is_zero_click = (s.ColumnInt(COLUMN_IS_ZERO_CLICK) > 0); |
528 return ENCRYPTION_RESULT_SUCCESS; | 564 return ENCRYPTION_RESULT_SUCCESS; |
529 } | 565 } |
530 | 566 |
531 bool LoginDatabase::GetLogins(const PasswordForm& form, | 567 bool LoginDatabase::GetLogins(const PasswordForm& form, |
532 std::vector<PasswordForm*>* forms) const { | 568 std::vector<PasswordForm*>* forms) const { |
533 DCHECK(forms); | 569 DCHECK(forms); |
534 // You *must* change LoginTableColumns if this query changes. | 570 // You *must* change LoginTableColumns if this query changes. |
535 const std::string sql_query = "SELECT origin_url, action_url, " | 571 const std::string sql_query = "SELECT origin_url, action_url, " |
536 "username_element, username_value, " | 572 "username_element, username_value, " |
537 "password_element, password_value, submit_element, " | 573 "password_element, password_value, submit_element, " |
538 "signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " | 574 "signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " |
539 "scheme, password_type, possible_usernames, times_used, form_data, " | 575 "scheme, password_type, possible_usernames, times_used, form_data, " |
540 "use_additional_auth, date_synced FROM logins WHERE signon_realm == ? "; | 576 "use_additional_auth, date_synced, display_name, avatar_url, " |
| 577 "federation_url, is_zero_click FROM logins WHERE signon_realm == ? "; |
541 sql::Statement s; | 578 sql::Statement s; |
542 const GURL signon_realm(form.signon_realm); | 579 const GURL signon_realm(form.signon_realm); |
543 std::string registered_domain = | 580 std::string registered_domain = |
544 PSLMatchingHelper::GetRegistryControlledDomain(signon_realm); | 581 PSLMatchingHelper::GetRegistryControlledDomain(signon_realm); |
545 PSLMatchingHelper::PSLDomainMatchMetric psl_domain_match_metric = | 582 PSLMatchingHelper::PSLDomainMatchMetric psl_domain_match_metric = |
546 PSLMatchingHelper::PSL_DOMAIN_MATCH_NONE; | 583 PSLMatchingHelper::PSL_DOMAIN_MATCH_NONE; |
547 // PSL matching only applies to HTML forms. | 584 // PSL matching only applies to HTML forms. |
548 if (form.scheme == PasswordForm::SCHEME_HTML && | 585 if (form.scheme == PasswordForm::SCHEME_HTML && |
549 psl_helper_.ShouldPSLDomainMatchingApply(registered_domain)) { | 586 psl_helper_.ShouldPSLDomainMatchingApply(registered_domain)) { |
550 // We are extending the original SQL query with one that includes more | 587 // We are extending the original SQL query with one that includes more |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 const base::Time begin, | 662 const base::Time begin, |
626 const base::Time end, | 663 const base::Time end, |
627 std::vector<autofill::PasswordForm*>* forms) const { | 664 std::vector<autofill::PasswordForm*>* forms) const { |
628 DCHECK(forms); | 665 DCHECK(forms); |
629 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, | 666 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, |
630 "SELECT origin_url, action_url, " | 667 "SELECT origin_url, action_url, " |
631 "username_element, username_value, " | 668 "username_element, username_value, " |
632 "password_element, password_value, submit_element, " | 669 "password_element, password_value, submit_element, " |
633 "signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " | 670 "signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " |
634 "scheme, password_type, possible_usernames, times_used, form_data, " | 671 "scheme, password_type, possible_usernames, times_used, form_data, " |
635 "use_additional_auth, date_synced FROM logins " | 672 "use_additional_auth, date_synced, display_name, avatar_url, " |
| 673 "federation_url, is_zero_click FROM logins " |
636 "WHERE date_created >= ? AND date_created < ?" | 674 "WHERE date_created >= ? AND date_created < ?" |
637 "ORDER BY origin_url")); | 675 "ORDER BY origin_url")); |
638 s.BindInt64(0, begin.ToTimeT()); | 676 s.BindInt64(0, begin.ToTimeT()); |
639 s.BindInt64(1, end.is_null() ? std::numeric_limits<int64>::max() | 677 s.BindInt64(1, end.is_null() ? std::numeric_limits<int64>::max() |
640 : end.ToTimeT()); | 678 : end.ToTimeT()); |
641 | 679 |
642 while (s.Step()) { | 680 while (s.Step()) { |
643 scoped_ptr<PasswordForm> new_form(new PasswordForm()); | 681 scoped_ptr<PasswordForm> new_form(new PasswordForm()); |
644 EncryptionResult result = InitPasswordFormFromStatement(new_form.get(), s); | 682 EncryptionResult result = InitPasswordFormFromStatement(new_form.get(), s); |
645 if (result == ENCRYPTION_RESULT_SERVICE_FAILURE) | 683 if (result == ENCRYPTION_RESULT_SERVICE_FAILURE) |
(...skipping 10 matching lines...) Expand all Loading... |
656 const base::Time begin, | 694 const base::Time begin, |
657 const base::Time end, | 695 const base::Time end, |
658 std::vector<autofill::PasswordForm*>* forms) const { | 696 std::vector<autofill::PasswordForm*>* forms) const { |
659 DCHECK(forms); | 697 DCHECK(forms); |
660 sql::Statement s(db_.GetCachedStatement( | 698 sql::Statement s(db_.GetCachedStatement( |
661 SQL_FROM_HERE, | 699 SQL_FROM_HERE, |
662 "SELECT origin_url, action_url, username_element, username_value, " | 700 "SELECT origin_url, action_url, username_element, username_value, " |
663 "password_element, password_value, submit_element, signon_realm, " | 701 "password_element, password_value, submit_element, signon_realm, " |
664 "ssl_valid, preferred, date_created, blacklisted_by_user, " | 702 "ssl_valid, preferred, date_created, blacklisted_by_user, " |
665 "scheme, password_type, possible_usernames, times_used, form_data, " | 703 "scheme, password_type, possible_usernames, times_used, form_data, " |
666 "use_additional_auth, date_synced FROM logins " | 704 "use_additional_auth, date_synced, display_name, avatar_url, " |
| 705 "federation_url, is_zero_click FROM logins " |
667 "WHERE date_synced >= ? AND date_synced < ?" | 706 "WHERE date_synced >= ? AND date_synced < ?" |
668 "ORDER BY origin_url")); | 707 "ORDER BY origin_url")); |
669 s.BindInt64(0, begin.ToInternalValue()); | 708 s.BindInt64(0, begin.ToInternalValue()); |
670 s.BindInt64(1, | 709 s.BindInt64(1, |
671 end.is_null() ? base::Time::Max().ToInternalValue() | 710 end.is_null() ? base::Time::Max().ToInternalValue() |
672 : end.ToInternalValue()); | 711 : end.ToInternalValue()); |
673 | 712 |
674 while (s.Step()) { | 713 while (s.Step()) { |
675 scoped_ptr<PasswordForm> new_form(new PasswordForm()); | 714 scoped_ptr<PasswordForm> new_form(new PasswordForm()); |
676 EncryptionResult result = InitPasswordFormFromStatement(new_form.get(), s); | 715 EncryptionResult result = InitPasswordFormFromStatement(new_form.get(), s); |
(...skipping 20 matching lines...) Expand all Loading... |
697 bool LoginDatabase::GetAllLoginsWithBlacklistSetting( | 736 bool LoginDatabase::GetAllLoginsWithBlacklistSetting( |
698 bool blacklisted, std::vector<PasswordForm*>* forms) const { | 737 bool blacklisted, std::vector<PasswordForm*>* forms) const { |
699 DCHECK(forms); | 738 DCHECK(forms); |
700 // You *must* change LoginTableColumns if this query changes. | 739 // You *must* change LoginTableColumns if this query changes. |
701 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, | 740 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, |
702 "SELECT origin_url, action_url, " | 741 "SELECT origin_url, action_url, " |
703 "username_element, username_value, " | 742 "username_element, username_value, " |
704 "password_element, password_value, submit_element, " | 743 "password_element, password_value, submit_element, " |
705 "signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " | 744 "signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " |
706 "scheme, password_type, possible_usernames, times_used, form_data, " | 745 "scheme, password_type, possible_usernames, times_used, form_data, " |
707 "use_additional_auth, date_synced FROM logins " | 746 "use_additional_auth, date_synced, display_name, avatar_url, " |
| 747 "federation_url, is_zero_click FROM logins " |
708 "WHERE blacklisted_by_user == ? ORDER BY origin_url")); | 748 "WHERE blacklisted_by_user == ? ORDER BY origin_url")); |
709 s.BindInt(0, blacklisted ? 1 : 0); | 749 s.BindInt(0, blacklisted ? 1 : 0); |
710 | 750 |
711 while (s.Step()) { | 751 while (s.Step()) { |
712 scoped_ptr<PasswordForm> new_form(new PasswordForm()); | 752 scoped_ptr<PasswordForm> new_form(new PasswordForm()); |
713 EncryptionResult result = InitPasswordFormFromStatement(new_form.get(), s); | 753 EncryptionResult result = InitPasswordFormFromStatement(new_form.get(), s); |
714 if (result == ENCRYPTION_RESULT_SERVICE_FAILURE) | 754 if (result == ENCRYPTION_RESULT_SERVICE_FAILURE) |
715 return false; | 755 return false; |
716 if (result == ENCRYPTION_RESULT_ITEM_FAILURE) | 756 if (result == ENCRYPTION_RESULT_ITEM_FAILURE) |
717 continue; | 757 continue; |
718 DCHECK(result == ENCRYPTION_RESULT_SUCCESS); | 758 DCHECK(result == ENCRYPTION_RESULT_SUCCESS); |
719 forms->push_back(new_form.release()); | 759 forms->push_back(new_form.release()); |
720 } | 760 } |
721 return s.Succeeded(); | 761 return s.Succeeded(); |
722 } | 762 } |
723 | 763 |
724 bool LoginDatabase::DeleteAndRecreateDatabaseFile() { | 764 bool LoginDatabase::DeleteAndRecreateDatabaseFile() { |
725 DCHECK(db_.is_open()); | 765 DCHECK(db_.is_open()); |
726 meta_table_.Reset(); | 766 meta_table_.Reset(); |
727 db_.Close(); | 767 db_.Close(); |
728 sql::Connection::Delete(db_path_); | 768 sql::Connection::Delete(db_path_); |
729 return Init(db_path_); | 769 return Init(db_path_); |
730 } | 770 } |
731 | 771 |
732 } // namespace password_manager | 772 } // namespace password_manager |
OLD | NEW |