| Index: components/password_manager/core/browser/psl_matching_helper.cc
|
| diff --git a/components/password_manager/core/browser/psl_matching_helper.cc b/components/password_manager/core/browser/psl_matching_helper.cc
|
| index 8790e8a7c6411aefa0efacc1ae0547d0fe92991a..02bccbe4b97a11dd755ef61f5326d64b2c5e8cff 100644
|
| --- a/components/password_manager/core/browser/psl_matching_helper.cc
|
| +++ b/components/password_manager/core/browser/psl_matching_helper.cc
|
| @@ -5,6 +5,7 @@
|
| #include "components/password_manager/core/browser/psl_matching_helper.h"
|
|
|
| #include <memory>
|
| +#include <ostream>
|
|
|
| #include "base/logging.h"
|
| #include "base/strings/string_util.h"
|
| @@ -17,6 +18,53 @@ using autofill::PasswordForm;
|
|
|
| namespace password_manager {
|
|
|
| +std::ostream& operator<<(std::ostream& out, MatchResult result) {
|
| + switch (result) {
|
| + case MatchResult::NO_MATCH:
|
| + return out << "No Match";
|
| + case MatchResult::EXACT_MATCH:
|
| + return out << "Exact Match";
|
| + case MatchResult::PSL_MATCH:
|
| + return out << "PSL Match";
|
| + case MatchResult::FEDERATED_MATCH:
|
| + return out << "Federated Match";
|
| + case MatchResult::FEDERATED_PSL_MATCH:
|
| + return out << "Federated PSL Match";
|
| + }
|
| + // This should never be reached, it is simply here to suppress compiler
|
| + // warnings.
|
| + return out;
|
| +}
|
| +
|
| +MatchResult GetMatchResult(const PasswordForm& form,
|
| + const PasswordStore::FormDigest& form_digest) {
|
| + if (form.signon_realm == form_digest.signon_realm)
|
| + return MatchResult::EXACT_MATCH;
|
| +
|
| + // PSL and federated matches only apply to HTML forms.
|
| + if (form_digest.scheme != PasswordForm::SCHEME_HTML ||
|
| + form.scheme != PasswordForm::SCHEME_HTML)
|
| + return MatchResult::NO_MATCH;
|
| +
|
| + const bool allow_psl_match = ShouldPSLDomainMatchingApply(
|
| + GetRegistryControlledDomain(GURL(form_digest.signon_realm)));
|
| + const bool allow_federated_match = !form.federation_origin.unique();
|
| +
|
| + if (allow_psl_match &&
|
| + IsPublicSuffixDomainMatch(form.signon_realm, form_digest.signon_realm))
|
| + return MatchResult::PSL_MATCH;
|
| +
|
| + if (allow_federated_match &&
|
| + IsFederatedMatch(form.signon_realm, form_digest.origin))
|
| + return MatchResult::FEDERATED_MATCH;
|
| +
|
| + if (allow_psl_match && allow_federated_match &&
|
| + IsFederatedPSLMatch(form.signon_realm, form_digest.origin))
|
| + return MatchResult::FEDERATED_PSL_MATCH;
|
| +
|
| + return MatchResult::NO_MATCH;
|
| +}
|
| +
|
| bool ShouldPSLDomainMatchingApply(
|
| const std::string& registry_controlled_domain) {
|
| return !registry_controlled_domain.empty() &&
|
|
|