| 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" |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 "signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " | 583 "signon_realm, ssl_valid, preferred, date_created, blacklisted_by_user, " |
| 584 "scheme, password_type, possible_usernames, times_used, form_data, " | 584 "scheme, password_type, possible_usernames, times_used, form_data, " |
| 585 "use_additional_auth, date_synced, display_name, avatar_url, " | 585 "use_additional_auth, date_synced, display_name, avatar_url, " |
| 586 "federation_url, is_zero_click FROM logins WHERE signon_realm == ? "; | 586 "federation_url, is_zero_click FROM logins WHERE signon_realm == ? "; |
| 587 sql::Statement s; | 587 sql::Statement s; |
| 588 const GURL signon_realm(form.signon_realm); | 588 const GURL signon_realm(form.signon_realm); |
| 589 std::string registered_domain = | 589 std::string registered_domain = |
| 590 PSLMatchingHelper::GetRegistryControlledDomain(signon_realm); | 590 PSLMatchingHelper::GetRegistryControlledDomain(signon_realm); |
| 591 PSLMatchingHelper::PSLDomainMatchMetric psl_domain_match_metric = | 591 PSLMatchingHelper::PSLDomainMatchMetric psl_domain_match_metric = |
| 592 PSLMatchingHelper::PSL_DOMAIN_MATCH_NONE; | 592 PSLMatchingHelper::PSL_DOMAIN_MATCH_NONE; |
| 593 const bool should_PSL_matching_apply = |
| 594 psl_helper_.ShouldPSLDomainMatchingApply(registered_domain); |
| 593 // PSL matching only applies to HTML forms. | 595 // PSL matching only applies to HTML forms. |
| 594 if (form.scheme == PasswordForm::SCHEME_HTML && | 596 if (form.scheme == PasswordForm::SCHEME_HTML && should_PSL_matching_apply) { |
| 595 psl_helper_.ShouldPSLDomainMatchingApply(registered_domain)) { | |
| 596 // We are extending the original SQL query with one that includes more | 597 // We are extending the original SQL query with one that includes more |
| 597 // possible matches based on public suffix domain matching. Using a regexp | 598 // possible matches based on public suffix domain matching. Using a regexp |
| 598 // here is just an optimization to not have to parse all the stored entries | 599 // here is just an optimization to not have to parse all the stored entries |
| 599 // in the |logins| table. The result (scheme, domain and port) is verified | 600 // in the |logins| table. The result (scheme, domain and port) is verified |
| 600 // further down using GURL. See the functions SchemeMatches, | 601 // further down using GURL. See the functions SchemeMatches, |
| 601 // RegistryControlledDomainMatches and PortMatches. | 602 // RegistryControlledDomainMatches and PortMatches. |
| 602 const std::string extended_sql_query = | 603 const std::string extended_sql_query = |
| 603 sql_query + "OR signon_realm REGEXP ? "; | 604 sql_query + "OR signon_realm REGEXP ? "; |
| 604 // TODO(nyquist) Re-enable usage of GetCachedStatement when | 605 // TODO(nyquist) Re-enable usage of GetCachedStatement when |
| 605 // http://crbug.com/248608 is fixed. | 606 // http://crbug.com/248608 is fixed. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 628 } | 629 } |
| 629 | 630 |
| 630 while (s.Step()) { | 631 while (s.Step()) { |
| 631 scoped_ptr<PasswordForm> new_form(new PasswordForm()); | 632 scoped_ptr<PasswordForm> new_form(new PasswordForm()); |
| 632 EncryptionResult result = InitPasswordFormFromStatement(new_form.get(), s); | 633 EncryptionResult result = InitPasswordFormFromStatement(new_form.get(), s); |
| 633 if (result == ENCRYPTION_RESULT_SERVICE_FAILURE) | 634 if (result == ENCRYPTION_RESULT_SERVICE_FAILURE) |
| 634 return false; | 635 return false; |
| 635 if (result == ENCRYPTION_RESULT_ITEM_FAILURE) | 636 if (result == ENCRYPTION_RESULT_ITEM_FAILURE) |
| 636 continue; | 637 continue; |
| 637 DCHECK(result == ENCRYPTION_RESULT_SUCCESS); | 638 DCHECK(result == ENCRYPTION_RESULT_SUCCESS); |
| 638 if (psl_helper_.IsMatchingEnabled()) { | 639 if (should_PSL_matching_apply) { |
| 639 if (!PSLMatchingHelper::IsPublicSuffixDomainMatch(new_form->signon_realm, | 640 if (!PSLMatchingHelper::IsPublicSuffixDomainMatch(new_form->signon_realm, |
| 640 form.signon_realm)) { | 641 form.signon_realm)) { |
| 641 // The database returned results that should not match. Skipping result. | 642 // The database returned results that should not match. Skipping result. |
| 642 continue; | 643 continue; |
| 643 } | 644 } |
| 644 if (form.signon_realm != new_form->signon_realm) { | 645 if (form.signon_realm != new_form->signon_realm) { |
| 645 // Ignore non-HTML matches. | 646 // Ignore non-HTML matches. |
| 646 if (new_form->scheme != PasswordForm::SCHEME_HTML) | 647 if (new_form->scheme != PasswordForm::SCHEME_HTML) |
| 647 continue; | 648 continue; |
| 648 | 649 |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 | 773 |
| 773 bool LoginDatabase::DeleteAndRecreateDatabaseFile() { | 774 bool LoginDatabase::DeleteAndRecreateDatabaseFile() { |
| 774 DCHECK(db_.is_open()); | 775 DCHECK(db_.is_open()); |
| 775 meta_table_.Reset(); | 776 meta_table_.Reset(); |
| 776 db_.Close(); | 777 db_.Close(); |
| 777 sql::Connection::Delete(db_path_); | 778 sql::Connection::Delete(db_path_); |
| 778 return Init(db_path_); | 779 return Init(db_path_); |
| 779 } | 780 } |
| 780 | 781 |
| 781 } // namespace password_manager | 782 } // namespace password_manager |
| OLD | NEW |