Chromium Code Reviews| 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..ca535bf36b1ae96506f7021db5cdb4f5b09e7af0 100644 |
| --- a/components/password_manager/core/browser/psl_matching_helper.cc |
| +++ b/components/password_manager/core/browser/psl_matching_helper.cc |
| @@ -5,18 +5,66 @@ |
| #include "components/password_manager/core/browser/psl_matching_helper.h" |
| #include <memory> |
| +#include <ostream> |
| #include "base/logging.h" |
| #include "base/strings/string_util.h" |
| #include "components/autofill/core/common/password_form.h" |
| #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| #include "url/gurl.h" |
| +#include "url/origin.h" |
|
vasilii
2017/01/26 13:35:17
unused.
jdoerrie
2017/01/26 14:47:56
Done.
|
| #include "url/url_constants.h" |
| 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; |
| + |
| + if (form_digest.scheme != PasswordForm::SCHEME_HTML || |
| + form.scheme != PasswordForm::SCHEME_HTML) |
|
vasilii
2017/01/26 13:35:17
You should add a comment that PSL and federations
jdoerrie
2017/01/26 14:47:56
Done.
|
| + 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() && |