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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/password_manager/core/browser/affiliation_utils.h" 5 #include "components/password_manager/core/browser/affiliation_utils.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <ostream> 8 #include <ostream>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 12 matching lines...) Expand all
23 namespace password_manager { 23 namespace password_manager {
24 24
25 namespace { 25 namespace {
26 26
27 // The scheme used for identifying Android applications. 27 // The scheme used for identifying Android applications.
28 const char kAndroidAppScheme[] = "android"; 28 const char kAndroidAppScheme[] = "android";
29 29
30 // The name of the field trial controlling affiliation-based matching. 30 // The name of the field trial controlling affiliation-based matching.
31 const char kFieldTrialName[] = "AffiliationBasedMatching"; 31 const char kFieldTrialName[] = "AffiliationBasedMatching";
32 32
33 // The URL prefixes that are removed from shown origin.
34 const std::string kRemovedPrefixes[] = {"m.", "mobile.", "www."};
35
33 // Returns a StringPiece corresponding to |component| in |uri|, or the empty 36 // Returns a StringPiece corresponding to |component| in |uri|, or the empty
34 // string in case there is no such component. 37 // string in case there is no such component.
35 base::StringPiece ComponentString(const std::string& uri, 38 base::StringPiece ComponentString(const std::string& uri,
36 const url::Component& component) { 39 const url::Component& component) {
37 if (!component.is_valid()) 40 if (!component.is_valid())
38 return base::StringPiece(); 41 return base::StringPiece();
39 return base::StringPiece(uri.c_str() + component.begin, component.len); 42 return base::StringPiece(uri.c_str() + component.begin, component.len);
40 } 43 }
41 44
42 // Returns true if the passed ASCII |input| string contains nothing else than 45 // Returns true if the passed ASCII |input| string contains nothing else than
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 const std::string& languages) { 343 const std::string& languages) {
341 password_manager::FacetURI facet_uri = 344 password_manager::FacetURI facet_uri =
342 password_manager::FacetURI::FromPotentiallyInvalidSpec( 345 password_manager::FacetURI::FromPotentiallyInvalidSpec(
343 password_form.signon_realm); 346 password_form.signon_realm);
344 if (facet_uri.IsValidAndroidFacetURI()) 347 if (facet_uri.IsValidAndroidFacetURI())
345 return facet_uri.scheme() + "://" + facet_uri.android_package_name(); 348 return facet_uri.scheme() + "://" + facet_uri.android_package_name();
346 return base::UTF16ToUTF8(url_formatter::FormatUrlForSecurityDisplay( 349 return base::UTF16ToUTF8(url_formatter::FormatUrlForSecurityDisplay(
347 password_form.origin, languages)); 350 password_form.origin, languages));
348 } 351 }
349 352
353 std::string GetShownOrigin(const GURL& url, const std::string& languages) {
354 std::string original = base::UTF16ToUTF8(
355 url_formatter::FormatUrlForSecurityDisplayOmitScheme(url, languages));
356 std::string result = original;
357 for (std::string prefix : kRemovedPrefixes) {
358 if (base::StartsWith(result, prefix,
359 base::CompareCase::INSENSITIVE_ASCII)) {
360 result = result.substr(prefix.length());
361 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.
362 }
363 }
364
365 if (result.find('.') != std::string::npos) {
366 return result;
367 } else {
Evan Stade 2015/10/05 18:59:41 nit: ternary operator
kolos1 2015/10/06 18:52:33 Done.
368 return original;
369 }
370 }
371
350 } // namespace password_manager 372 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698