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

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: Added comments to new css classes. Removed left align for rtl locales. 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..699c6c49c5d4918612e11e12aff755a6f4d93b64 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,23 @@ 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)
Evan Stade 2015/10/05 18:59:41 nit: comments should be formatted like sentences (
kolos1 2015/10/06 18:52:33 Done.
+ }
+ }
+
+ if (result.find('.') != std::string::npos) {
+ return result;
+ } else {
Evan Stade 2015/10/05 18:59:41 nit: ternary operator
kolos1 2015/10/06 18:52:33 Done.
+ return original;
+ }
+}
+
} // namespace password_manager

Powered by Google App Engine
This is Rietveld 408576698