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

Side by Side Diff: components/password_manager/core/browser/password_ui_utils.cc

Issue 2695883003: Change uses of base::JoinString to pass StringPieces where possible. (Closed)
Patch Set: Remove dependency CL. Created 3 years, 9 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/password_ui_utils.h" 5 #include "components/password_manager/core/browser/password_ui_utils.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/strings/string_piece.h"
11 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
12 #include "base/strings/string_util.h" 11 #include "base/strings/string_util.h"
13 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
14 #include "components/autofill/core/common/password_form.h" 13 #include "components/autofill/core/common/password_form.h"
15 #include "components/password_manager/core/browser/affiliation_utils.h" 14 #include "components/password_manager/core/browser/affiliation_utils.h"
16 #include "components/url_formatter/elide_url.h" 15 #include "components/url_formatter/elide_url.h"
17 16
18 namespace password_manager { 17 namespace password_manager {
19 18
20 namespace { 19 namespace {
21 20
22 // The URL prefixes that are removed from shown origin. 21 // The URL prefixes that are removed from shown origin.
23 const char* const kRemovedPrefixes[] = {"m.", "mobile.", "www."}; 22 const char* const kRemovedPrefixes[] = {"m.", "mobile.", "www."};
24 23
25 } // namespace 24 } // namespace
26 25
27 std::string SplitByDotAndReverse(base::StringPiece host) { 26 std::string SplitByDotAndReverse(base::StringPiece host) {
28 std::vector<std::string> parts = 27 std::vector<base::StringPiece> parts = base::SplitStringPiece(
29 base::SplitString(host, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 28 host, ".", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
30 std::reverse(parts.begin(), parts.end()); 29 std::reverse(parts.begin(), parts.end());
31 return base::JoinString(parts, "."); 30 return base::JoinString(parts, ".");
32 } 31 }
33 32
34 std::string StripAndroidAndReverse(const std::string& origin) { 33 std::string StripAndroidAndReverse(const std::string& origin) {
35 const int kAndroidAppSchemeAndDelimiterLength = sizeof("android://") - 1; 34 const int kAndroidAppSchemeAndDelimiterLength = sizeof("android://") - 1;
36 return SplitByDotAndReverse( 35 return SplitByDotAndReverse(
37 base::StringPiece(&origin[kAndroidAppSchemeAndDelimiterLength], 36 base::StringPiece(&origin[kAndroidAppSchemeAndDelimiterLength],
38 origin.length() - kAndroidAppSchemeAndDelimiterLength)); 37 origin.length() - kAndroidAppSchemeAndDelimiterLength));
39 } 38 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 result.remove_prefix(prefix.length()); 78 result.remove_prefix(prefix.length());
80 break; // Remove only one prefix (e.g. www.mobile.de). 79 break; // Remove only one prefix (e.g. www.mobile.de).
81 } 80 }
82 } 81 }
83 82
84 return result.find('.') != base::StringPiece::npos ? result.as_string() 83 return result.find('.') != base::StringPiece::npos ? result.as_string()
85 : original; 84 : original;
86 } 85 }
87 86
88 } // namespace password_manager 87 } // namespace password_manager
OLDNEW
« no previous file with comments | « components/nacl/renderer/platform_info.cc ('k') | components/policy/core/browser/policy_error_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698