| 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 b4c4bef165c9d022f57ded82296fe6f68a8b88a0..6cbb305c7645938e4d3249378d76395273d84e7d 100644
|
| --- a/components/password_manager/core/browser/psl_matching_helper.cc
|
| +++ b/components/password_manager/core/browser/psl_matching_helper.cc
|
| @@ -116,4 +116,28 @@ std::string GetRegistryControlledDomain(const GURL& signon_realm) {
|
| signon_realm,
|
| net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
|
| }
|
| +
|
| +std::string GetOrganizationIdentifyingName(const GURL& url) {
|
| + if (!url.is_valid())
|
| + return std::string();
|
| +
|
| + const std::string organization_and_registrar =
|
| + net::registry_controlled_domains::GetDomainAndRegistry(
|
| + url, net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
|
| + const size_t registrar_length =
|
| + net::registry_controlled_domains::GetRegistryLength(
|
| + url, net::registry_controlled_domains::INCLUDE_UNKNOWN_REGISTRIES,
|
| + net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES);
|
| +
|
| + if (organization_and_registrar.empty() || !registrar_length ||
|
| + registrar_length == std::string::npos) {
|
| + return std::string();
|
| + }
|
| +
|
| + // No CHECK, std::string::substr gracefully handles an underflow there.
|
| + DCHECK_LT(registrar_length, organization_and_registrar.size());
|
| + return organization_and_registrar.substr(
|
| + 0, organization_and_registrar.size() - registrar_length - 1);
|
| +}
|
| +
|
| } // namespace password_manager
|
|
|