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_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()); | |
Mike West
2014/08/18 18:52:11
How do we deal with invalid URLs here? Perhaps a D
vasilii
2014/08/20 11:45:34
GURL::spec() will assert and return the empty stri
| |
112 s->BindInt(COLUMN_ZERO_CLICK, form.is_zero_click); | |
Mike West
2014/08/18 18:52:11
Nit: I'd suggest standardizing on either "zero cli
vasilii
2014/08/20 11:45:34
Done.
| |
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 s.BindString(16, form.origin.spec()); |
Mike West
2014/08/18 18:52:11
Nit: It's probably worth adding a "// WHERE starts
vasilii
2014/08/20 11:45:34
Done.
| |
417 s.BindString16(13, form.username_element); | 448 s.BindString16(17, form.username_element); |
418 s.BindString16(14, form.username_value); | 449 s.BindString16(18, form.username_value); |
419 s.BindString16(15, form.password_element); | 450 s.BindString16(19, form.password_element); |
420 s.BindString(16, form.signon_realm); | 451 s.BindString(20, form.signon_realm); |
421 | 452 |
422 if (!s.Run()) | 453 if (!s.Run()) |
423 return PasswordStoreChangeList(); | 454 return PasswordStoreChangeList(); |
424 | 455 |
425 PasswordStoreChangeList list; | 456 PasswordStoreChangeList list; |
426 if (db_.GetLastChangeCount()) | 457 if (db_.GetLastChangeCount()) |
427 list.push_back(PasswordStoreChange(PasswordStoreChange::UPDATE, form)); | 458 list.push_back(PasswordStoreChange(PasswordStoreChange::UPDATE, form)); |
428 | 459 |
429 return list; | 460 return list; |
430 } | 461 } |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
518 Pickle form_data_pickle( | 549 Pickle form_data_pickle( |
519 static_cast<const char*>(s.ColumnBlob(COLUMN_FORM_DATA)), | 550 static_cast<const char*>(s.ColumnBlob(COLUMN_FORM_DATA)), |
520 s.ColumnByteLength(COLUMN_FORM_DATA)); | 551 s.ColumnByteLength(COLUMN_FORM_DATA)); |
521 PickleIterator form_data_iter(form_data_pickle); | 552 PickleIterator form_data_iter(form_data_pickle); |
522 autofill::DeserializeFormData(&form_data_iter, &form->form_data); | 553 autofill::DeserializeFormData(&form_data_iter, &form->form_data); |
523 } | 554 } |
524 form->use_additional_authentication = | 555 form->use_additional_authentication = |
525 (s.ColumnInt(COLUMN_USE_ADDITIONAL_AUTH) > 0); | 556 (s.ColumnInt(COLUMN_USE_ADDITIONAL_AUTH) > 0); |
526 form->date_synced = base::Time::FromInternalValue( | 557 form->date_synced = base::Time::FromInternalValue( |
527 s.ColumnInt64(COLUMN_DATE_SYNCED)); | 558 s.ColumnInt64(COLUMN_DATE_SYNCED)); |
559 form->display_name = s.ColumnString16(COLUMN_DISPLAY_NAME); | |
560 form->avatar_url = GURL(s.ColumnString(COLUMN_AVATAR_URL)); | |
561 form->federation_url = GURL(s.ColumnString(COLUMN_FEDERATION_URL)); | |
Mike West
2014/08/18 18:52:11
Nit: Do we do error handling anywhere else for thi
vasilii
2014/08/20 11:45:34
But empty URLs are invalid too.
| |
562 form->is_zero_click = (s.ColumnInt(COLUMN_ZERO_CLICK) > 0); | |
528 return ENCRYPTION_RESULT_SUCCESS; | 563 return ENCRYPTION_RESULT_SUCCESS; |
529 } | 564 } |
530 | 565 |
531 bool LoginDatabase::GetLogins(const PasswordForm& form, | 566 bool LoginDatabase::GetLogins(const PasswordForm& form, |
532 std::vector<PasswordForm*>* forms) const { | 567 std::vector<PasswordForm*>* forms) const { |
533 DCHECK(forms); | 568 DCHECK(forms); |
534 // You *must* change LoginTableColumns if this query changes. | 569 // You *must* change LoginTableColumns if this query changes. |
535 const std::string sql_query = "SELECT origin_url, action_url, " | 570 const std::string sql_query = "SELECT origin_url, action_url, " |
536 "username_element, username_value, " | 571 "username_element, username_value, " |
537 "password_element, password_value, submit_element, " | 572 "password_element, password_value, submit_element, " |
538 "signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " | 573 "signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " |
539 "scheme, password_type, possible_usernames, times_used, form_data, " | 574 "scheme, password_type, possible_usernames, times_used, form_data, " |
540 "use_additional_auth, date_synced FROM logins WHERE signon_realm == ? "; | 575 "use_additional_auth, date_synced, display_name, avatar_url, " |
576 "federation_url, is_zero_click FROM logins WHERE signon_realm == ? "; | |
541 sql::Statement s; | 577 sql::Statement s; |
542 const GURL signon_realm(form.signon_realm); | 578 const GURL signon_realm(form.signon_realm); |
543 std::string registered_domain = | 579 std::string registered_domain = |
544 PSLMatchingHelper::GetRegistryControlledDomain(signon_realm); | 580 PSLMatchingHelper::GetRegistryControlledDomain(signon_realm); |
545 PSLMatchingHelper::PSLDomainMatchMetric psl_domain_match_metric = | 581 PSLMatchingHelper::PSLDomainMatchMetric psl_domain_match_metric = |
546 PSLMatchingHelper::PSL_DOMAIN_MATCH_NONE; | 582 PSLMatchingHelper::PSL_DOMAIN_MATCH_NONE; |
547 // PSL matching only applies to HTML forms. | 583 // PSL matching only applies to HTML forms. |
548 if (form.scheme == PasswordForm::SCHEME_HTML && | 584 if (form.scheme == PasswordForm::SCHEME_HTML && |
549 psl_helper_.ShouldPSLDomainMatchingApply(registered_domain)) { | 585 psl_helper_.ShouldPSLDomainMatchingApply(registered_domain)) { |
550 // We are extending the original SQL query with one that includes more | 586 // 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, | 661 const base::Time begin, |
626 const base::Time end, | 662 const base::Time end, |
627 std::vector<autofill::PasswordForm*>* forms) const { | 663 std::vector<autofill::PasswordForm*>* forms) const { |
628 DCHECK(forms); | 664 DCHECK(forms); |
629 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, | 665 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, |
630 "SELECT origin_url, action_url, " | 666 "SELECT origin_url, action_url, " |
631 "username_element, username_value, " | 667 "username_element, username_value, " |
632 "password_element, password_value, submit_element, " | 668 "password_element, password_value, submit_element, " |
633 "signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " | 669 "signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " |
634 "scheme, password_type, possible_usernames, times_used, form_data, " | 670 "scheme, password_type, possible_usernames, times_used, form_data, " |
635 "use_additional_auth, date_synced FROM logins " | 671 "use_additional_auth, date_synced, display_name, avatar_url, " |
672 "federation_url, is_zero_click FROM logins " | |
636 "WHERE date_created >= ? AND date_created < ?" | 673 "WHERE date_created >= ? AND date_created < ?" |
637 "ORDER BY origin_url")); | 674 "ORDER BY origin_url")); |
638 s.BindInt64(0, begin.ToTimeT()); | 675 s.BindInt64(0, begin.ToTimeT()); |
639 s.BindInt64(1, end.is_null() ? std::numeric_limits<int64>::max() | 676 s.BindInt64(1, end.is_null() ? std::numeric_limits<int64>::max() |
640 : end.ToTimeT()); | 677 : end.ToTimeT()); |
641 | 678 |
642 while (s.Step()) { | 679 while (s.Step()) { |
643 scoped_ptr<PasswordForm> new_form(new PasswordForm()); | 680 scoped_ptr<PasswordForm> new_form(new PasswordForm()); |
644 EncryptionResult result = InitPasswordFormFromStatement(new_form.get(), s); | 681 EncryptionResult result = InitPasswordFormFromStatement(new_form.get(), s); |
645 if (result == ENCRYPTION_RESULT_SERVICE_FAILURE) | 682 if (result == ENCRYPTION_RESULT_SERVICE_FAILURE) |
(...skipping 10 matching lines...) Expand all Loading... | |
656 const base::Time begin, | 693 const base::Time begin, |
657 const base::Time end, | 694 const base::Time end, |
658 std::vector<autofill::PasswordForm*>* forms) const { | 695 std::vector<autofill::PasswordForm*>* forms) const { |
659 DCHECK(forms); | 696 DCHECK(forms); |
660 sql::Statement s(db_.GetCachedStatement( | 697 sql::Statement s(db_.GetCachedStatement( |
661 SQL_FROM_HERE, | 698 SQL_FROM_HERE, |
662 "SELECT origin_url, action_url, username_element, username_value, " | 699 "SELECT origin_url, action_url, username_element, username_value, " |
663 "password_element, password_value, submit_element, signon_realm, " | 700 "password_element, password_value, submit_element, signon_realm, " |
664 "ssl_valid, preferred, date_created, blacklisted_by_user, " | 701 "ssl_valid, preferred, date_created, blacklisted_by_user, " |
665 "scheme, password_type, possible_usernames, times_used, form_data, " | 702 "scheme, password_type, possible_usernames, times_used, form_data, " |
666 "use_additional_auth, date_synced FROM logins " | 703 "use_additional_auth, date_synced, display_name, avatar_url, " |
704 "federation_url, is_zero_click FROM logins " | |
667 "WHERE date_synced >= ? AND date_synced < ?" | 705 "WHERE date_synced >= ? AND date_synced < ?" |
668 "ORDER BY origin_url")); | 706 "ORDER BY origin_url")); |
669 s.BindInt64(0, begin.ToInternalValue()); | 707 s.BindInt64(0, begin.ToInternalValue()); |
670 s.BindInt64(1, | 708 s.BindInt64(1, |
671 end.is_null() ? base::Time::Max().ToInternalValue() | 709 end.is_null() ? base::Time::Max().ToInternalValue() |
672 : end.ToInternalValue()); | 710 : end.ToInternalValue()); |
673 | 711 |
674 while (s.Step()) { | 712 while (s.Step()) { |
675 scoped_ptr<PasswordForm> new_form(new PasswordForm()); | 713 scoped_ptr<PasswordForm> new_form(new PasswordForm()); |
676 EncryptionResult result = InitPasswordFormFromStatement(new_form.get(), s); | 714 EncryptionResult result = InitPasswordFormFromStatement(new_form.get(), s); |
(...skipping 20 matching lines...) Expand all Loading... | |
697 bool LoginDatabase::GetAllLoginsWithBlacklistSetting( | 735 bool LoginDatabase::GetAllLoginsWithBlacklistSetting( |
698 bool blacklisted, std::vector<PasswordForm*>* forms) const { | 736 bool blacklisted, std::vector<PasswordForm*>* forms) const { |
699 DCHECK(forms); | 737 DCHECK(forms); |
700 // You *must* change LoginTableColumns if this query changes. | 738 // You *must* change LoginTableColumns if this query changes. |
701 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, | 739 sql::Statement s(db_.GetCachedStatement(SQL_FROM_HERE, |
702 "SELECT origin_url, action_url, " | 740 "SELECT origin_url, action_url, " |
703 "username_element, username_value, " | 741 "username_element, username_value, " |
704 "password_element, password_value, submit_element, " | 742 "password_element, password_value, submit_element, " |
705 "signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " | 743 "signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " |
706 "scheme, password_type, possible_usernames, times_used, form_data, " | 744 "scheme, password_type, possible_usernames, times_used, form_data, " |
707 "use_additional_auth, date_synced FROM logins " | 745 "use_additional_auth, date_synced, display_name, avatar_url, " |
746 "federation_url, is_zero_click FROM logins " | |
708 "WHERE blacklisted_by_user == ? ORDER BY origin_url")); | 747 "WHERE blacklisted_by_user == ? ORDER BY origin_url")); |
709 s.BindInt(0, blacklisted ? 1 : 0); | 748 s.BindInt(0, blacklisted ? 1 : 0); |
710 | 749 |
711 while (s.Step()) { | 750 while (s.Step()) { |
712 scoped_ptr<PasswordForm> new_form(new PasswordForm()); | 751 scoped_ptr<PasswordForm> new_form(new PasswordForm()); |
713 EncryptionResult result = InitPasswordFormFromStatement(new_form.get(), s); | 752 EncryptionResult result = InitPasswordFormFromStatement(new_form.get(), s); |
714 if (result == ENCRYPTION_RESULT_SERVICE_FAILURE) | 753 if (result == ENCRYPTION_RESULT_SERVICE_FAILURE) |
715 return false; | 754 return false; |
716 if (result == ENCRYPTION_RESULT_ITEM_FAILURE) | 755 if (result == ENCRYPTION_RESULT_ITEM_FAILURE) |
717 continue; | 756 continue; |
718 DCHECK(result == ENCRYPTION_RESULT_SUCCESS); | 757 DCHECK(result == ENCRYPTION_RESULT_SUCCESS); |
719 forms->push_back(new_form.release()); | 758 forms->push_back(new_form.release()); |
720 } | 759 } |
721 return s.Succeeded(); | 760 return s.Succeeded(); |
722 } | 761 } |
723 | 762 |
724 bool LoginDatabase::DeleteAndRecreateDatabaseFile() { | 763 bool LoginDatabase::DeleteAndRecreateDatabaseFile() { |
725 DCHECK(db_.is_open()); | 764 DCHECK(db_.is_open()); |
726 meta_table_.Reset(); | 765 meta_table_.Reset(); |
727 db_.Close(); | 766 db_.Close(); |
728 sql::Connection::Delete(db_path_); | 767 sql::Connection::Delete(db_path_); |
729 return Init(db_path_); | 768 return Init(db_path_); |
730 } | 769 } |
731 | 770 |
732 } // namespace password_manager | 771 } // namespace password_manager |
OLD | NEW |