| Index: components/password_manager/core/browser/affiliation_utils.cc
|
| diff --git a/components/password_manager/core/browser/affiliation_utils.cc b/components/password_manager/core/browser/affiliation_utils.cc
|
| index 8018ec4e879e367a83f5a946063072eaebc33565..87f99136fdef94a418bc9768c028f5e6df03eb8e 100644
|
| --- a/components/password_manager/core/browser/affiliation_utils.cc
|
| +++ b/components/password_manager/core/browser/affiliation_utils.cc
|
| @@ -30,6 +30,9 @@ const char kAndroidAppScheme[] = "android";
|
| // The name of the field trial controlling affiliation-based matching.
|
| const char kFieldTrialName[] = "AffiliationBasedMatching";
|
|
|
| +// The URL prefixes that are removed from shown origin.
|
| +const std::string kRemovedPrefixes[] = {"m.", "mobile.", "www."};
|
| +
|
| // Returns a StringPiece corresponding to |component| in |uri|, or the empty
|
| // string in case there is no such component.
|
| base::StringPiece ComponentString(const std::string& uri,
|
| @@ -347,4 +350,19 @@ std::string GetHumanReadableOrigin(const autofill::PasswordForm& password_form,
|
| password_form.origin, languages));
|
| }
|
|
|
| +std::string GetShownOrigin(const GURL& url, const std::string& languages) {
|
| + std::string original = base::UTF16ToUTF8(
|
| + url_formatter::FormatUrlForSecurityDisplayOmitScheme(url, languages));
|
| + std::string result = original;
|
| + for (std::string prefix : kRemovedPrefixes) {
|
| + if (base::StartsWith(result, prefix,
|
| + base::CompareCase::INSENSITIVE_ASCII)) {
|
| + result = result.substr(prefix.length());
|
| + break; // Remove only one prefix (e.g. www.mobile.de).
|
| + }
|
| + }
|
| +
|
| + return result.find('.') != std::string::npos ? result : original;
|
| +}
|
| +
|
| } // namespace password_manager
|
|
|