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 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(); |
| + } |
|
vasilii
2017/05/26 12:47:55
Optional: you can omit {}
engedy
2017/05/29 08:41:09
Let me keep these, I like them a lot.
|
| + |
| + // 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); |
|
vasilii
2017/05/26 12:47:55
I suppose that "1" is for ".". Are we sure that it
engedy
2017/05/29 08:41:09
Yes, '.' is one of the characters that will always
|
| +} |
| + |
| } // namespace password_manager |