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 ff01008aee6796b43937a0b3ebd615c117fc1926..e1470c7f94389922b1aeff4ed20a13815d698076 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,23 @@ 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; |
| + |
| + 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(), |
|
jdoerrie
2017/01/16 18:04:14
Should we create an overload of |IsPublicSuffixDom
vasilii
2017/01/17 12:41:24
Probably in a separate patch. It makes sense to ma
jdoerrie
2017/01/17 13:37:18
Acknowledged.
|
| + origin.GetOrigin().spec()); |
| +} |
| } // namespace password_manager |