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/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 "password_element, password_value, submit_element, " | 429 "password_element, password_value, submit_element, " |
430 "signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " | 430 "signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " |
431 "scheme, password_type, possible_usernames, times_used, form_data, " | 431 "scheme, password_type, possible_usernames, times_used, form_data, " |
432 "use_additional_auth FROM logins WHERE signon_realm == ? "; | 432 "use_additional_auth FROM logins WHERE signon_realm == ? "; |
433 sql::Statement s; | 433 sql::Statement s; |
434 const GURL signon_realm(form.signon_realm); | 434 const GURL signon_realm(form.signon_realm); |
435 std::string registered_domain = | 435 std::string registered_domain = |
436 PSLMatchingHelper::GetRegistryControlledDomain(signon_realm); | 436 PSLMatchingHelper::GetRegistryControlledDomain(signon_realm); |
437 PSLMatchingHelper::PSLDomainMatchMetric psl_domain_match_metric = | 437 PSLMatchingHelper::PSLDomainMatchMetric psl_domain_match_metric = |
438 PSLMatchingHelper::PSL_DOMAIN_MATCH_NONE; | 438 PSLMatchingHelper::PSL_DOMAIN_MATCH_NONE; |
439 if (psl_helper_.ShouldPSLDomainMatchingApply(registered_domain)) { | 439 if (form.scheme == PasswordForm::SCHEME_HTML && |
| 440 psl_helper_.ShouldPSLDomainMatchingApply(registered_domain)) { |
440 // We are extending the original SQL query with one that includes more | 441 // We are extending the original SQL query with one that includes more |
441 // possible matches based on public suffix domain matching. Using a regexp | 442 // possible matches based on public suffix domain matching. Using a regexp |
442 // here is just an optimization to not have to parse all the stored entries | 443 // here is just an optimization to not have to parse all the stored entries |
443 // in the |logins| table. The result (scheme, domain and port) is verified | 444 // in the |logins| table. The result (scheme, domain and port) is verified |
444 // further down using GURL. See the functions SchemeMatches, | 445 // further down using GURL. See the functions SchemeMatches, |
445 // RegistryControlledDomainMatches and PortMatches. | 446 // RegistryControlledDomainMatches and PortMatches. |
446 const std::string extended_sql_query = | 447 const std::string extended_sql_query = |
447 sql_query + "OR signon_realm REGEXP ? "; | 448 sql_query + "OR signon_realm REGEXP ? "; |
448 // TODO(nyquist) Re-enable usage of GetCachedStatement when | 449 // TODO(nyquist) Re-enable usage of GetCachedStatement when |
449 // http://crbug.com/248608 is fixed. | 450 // http://crbug.com/248608 is fixed. |
(...skipping 23 matching lines...) Expand all Loading... |
473 | 474 |
474 while (s.Step()) { | 475 while (s.Step()) { |
475 scoped_ptr<PasswordForm> new_form(new PasswordForm()); | 476 scoped_ptr<PasswordForm> new_form(new PasswordForm()); |
476 EncryptionResult result = InitPasswordFormFromStatement(new_form.get(), s); | 477 EncryptionResult result = InitPasswordFormFromStatement(new_form.get(), s); |
477 if (result == ENCRYPTION_RESULT_SERVICE_FAILURE) | 478 if (result == ENCRYPTION_RESULT_SERVICE_FAILURE) |
478 return false; | 479 return false; |
479 if (result == ENCRYPTION_RESULT_ITEM_FAILURE) | 480 if (result == ENCRYPTION_RESULT_ITEM_FAILURE) |
480 continue; | 481 continue; |
481 DCHECK(result == ENCRYPTION_RESULT_SUCCESS); | 482 DCHECK(result == ENCRYPTION_RESULT_SUCCESS); |
482 if (psl_helper_.IsMatchingEnabled()) { | 483 if (psl_helper_.IsMatchingEnabled()) { |
483 if (!PSLMatchingHelper::IsPublicSuffixDomainMatch(new_form->signon_realm, | 484 if (new_form->scheme != PasswordForm::SCHEME_HTML || |
484 form.signon_realm)) { | 485 !PSLMatchingHelper::IsPublicSuffixDomainMatch(new_form->signon_realm, |
| 486 form.signon_realm)) { |
485 // The database returned results that should not match. Skipping result. | 487 // The database returned results that should not match. Skipping result. |
486 continue; | 488 continue; |
487 } | 489 } |
488 if (form.signon_realm != new_form->signon_realm) { | 490 if (form.signon_realm != new_form->signon_realm) { |
489 psl_domain_match_metric = PSLMatchingHelper::PSL_DOMAIN_MATCH_FOUND; | 491 psl_domain_match_metric = PSLMatchingHelper::PSL_DOMAIN_MATCH_FOUND; |
490 // This is not a perfect match, so we need to create a new valid result. | 492 // This is not a perfect match, so we need to create a new valid result. |
491 // We do this by copying over origin, signon realm and action from the | 493 // We do this by copying over origin, signon realm and action from the |
492 // observed form and setting the original signon realm to what we found | 494 // observed form and setting the original signon realm to what we found |
493 // in the database. We use the fact that |original_signon_realm| is | 495 // in the database. We use the fact that |original_signon_realm| is |
494 // non-empty to communicate that this match was found using public | 496 // non-empty to communicate that this match was found using public |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 base::string16 str; | 600 base::string16 str; |
599 | 601 |
600 PickleIterator iterator(p); | 602 PickleIterator iterator(p); |
601 while (iterator.ReadString16(&str)) { | 603 while (iterator.ReadString16(&str)) { |
602 ret.push_back(str); | 604 ret.push_back(str); |
603 } | 605 } |
604 return ret; | 606 return ret; |
605 } | 607 } |
606 | 608 |
607 } // namespace password_manager | 609 } // namespace password_manager |
OLD | NEW |