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

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

Issue 2634163002: Fetch federated PSL-matches from the password store. (Closed)
Patch Set: Updated Histogram. 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 ff01008aee6796b43937a0b3ebd615c117fc1926..8790e8a7c6411aefa0efacc1ae0547d0fe92991a 100644
--- a/components/password_manager/core/browser/psl_matching_helper.cc
+++ b/components/password_manager/core/browser/psl_matching_helper.cc
@@ -11,6 +11,7 @@
#include "components/autofill/core/common/password_form.h"
#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
#include "url/gurl.h"
+#include "url/url_constants.h"
using autofill::PasswordForm;
@@ -57,4 +58,26 @@ bool IsFederatedMatch(const std::string& signon_realm, const GURL& origin) {
base::CompareCase::INSENSITIVE_ASCII);
}
+bool IsFederatedPSLMatch(const std::string& signon_realm, const GURL& origin) {
+ // The format should be "federation://origin.host/federation.host;
+ // Check for presence of "federation://" prefix.
+ static constexpr char federation_prefix[] = "federation://";
+ if (!base::StartsWith(signon_realm, federation_prefix,
+ base::CompareCase::INSENSITIVE_ASCII))
+ return false;
+
+ // Replace federation scheme with HTTPS. This results in correct parsing of
+ // host and path, and forces origin to have a HTTPS scheme in order to return
+ // true.
+ GURL::Replacements replacements;
+ replacements.SetSchemeStr(url::kHttpsScheme);
+ GURL https_signon_realm = GURL(signon_realm).ReplaceComponents(replacements);
+
+ // Check for non-empty federation.host.
+ if (!https_signon_realm.has_path() || https_signon_realm.path_piece() == "/")
+ return false;
+
+ return IsPublicSuffixDomainMatch(https_signon_realm.GetOrigin().spec(),
+ origin.GetOrigin().spec());
+}
} // namespace password_manager

Powered by Google App Engine
This is Rietveld 408576698