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

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

Issue 1318523011: [Password Manager] Copiable username and origin. Linkable origin elided from the left. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Icons appearance fixed Created 5 years, 2 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/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

Powered by Google App Engine
This is Rietveld 408576698