Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Unified Diff: components/password_manager/core/browser/psl_matching_helper.cc

Issue 2652243002: Implement Federated PSL Matches in Native Backends (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..f5f20c6766056bf1eb2877dbc60c9a0f0fc346a5 100644
--- a/components/password_manager/core/browser/psl_matching_helper.cc
+++ b/components/password_manager/core/browser/psl_matching_helper.cc
@@ -5,18 +5,63 @@
#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"
#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";
+ }
+}
+
+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)
+ 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() &&

Powered by Google App Engine
This is Rietveld 408576698