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

Side by Side Diff: components/omnibox/browser/autocomplete_input.cc

Issue 1234973004: Update SplitString calls in components (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixes Created 5 years, 5 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/omnibox/browser/autocomplete_input.h" 5 #include "components/omnibox/browser/autocomplete_input.h"
6 6
7 #include "base/strings/string_split.h" 7 #include "base/strings/string_split.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "components/metrics/proto/omnibox_event.pb.h" 10 #include "components/metrics/proto/omnibox_event.pb.h"
(...skipping 19 matching lines...) Expand all
30 else 30 else
31 *cursor_position = 0; 31 *cursor_position = 0;
32 } 32 }
33 33
34 // Finds all terms in |text| that start with http:// or https:// plus at least 34 // Finds all terms in |text| that start with http:// or https:// plus at least
35 // one more character and puts the text after the prefix in 35 // one more character and puts the text after the prefix in
36 // |terms_prefixed_by_http_or_https|. 36 // |terms_prefixed_by_http_or_https|.
37 void PopulateTermsPrefixedByHttpOrHttps( 37 void PopulateTermsPrefixedByHttpOrHttps(
38 const base::string16& text, 38 const base::string16& text,
39 std::vector<base::string16>* terms_prefixed_by_http_or_https) { 39 std::vector<base::string16>* terms_prefixed_by_http_or_https) {
40 std::vector<base::string16> terms;
41 // Split on whitespace rather than use ICU's word iterator because, for 40 // Split on whitespace rather than use ICU's word iterator because, for
42 // example, ICU's iterator may break on punctuation (such as ://) or decide 41 // example, ICU's iterator may break on punctuation (such as ://) or decide
43 // to split a single term in a hostname (if it seems to think that the 42 // to split a single term in a hostname (if it seems to think that the
44 // hostname is multiple words). Neither of these behaviors is desirable. 43 // hostname is multiple words). Neither of these behaviors is desirable.
45 base::SplitString(text, ' ', &terms);
46 const std::string separator(url::kStandardSchemeSeparator); 44 const std::string separator(url::kStandardSchemeSeparator);
47 for (const auto& term : terms) { 45 for (const auto& term :
46 base::SplitString(text, base::ASCIIToUTF16(" "),
47 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL)) {
48 const std::string term_utf8(base::UTF16ToUTF8(term)); 48 const std::string term_utf8(base::UTF16ToUTF8(term));
49 static const char* kSchemes[2] = { url::kHttpScheme, url::kHttpsScheme }; 49 static const char* kSchemes[2] = { url::kHttpScheme, url::kHttpsScheme };
50 for (const char* scheme : kSchemes) { 50 for (const char* scheme : kSchemes) {
51 const std::string prefix(scheme + separator); 51 const std::string prefix(scheme + separator);
52 // Doing an ASCII comparison is okay because prefix is ASCII. 52 // Doing an ASCII comparison is okay because prefix is ASCII.
53 if (base::StartsWith(term_utf8, prefix, 53 if (base::StartsWith(term_utf8, prefix,
54 base::CompareCase::INSENSITIVE_ASCII) && 54 base::CompareCase::INSENSITIVE_ASCII) &&
55 (term_utf8.length() > prefix.length())) { 55 (term_utf8.length() > prefix.length())) {
56 terms_prefixed_by_http_or_https->push_back( 56 terms_prefixed_by_http_or_https->push_back(
57 term.substr(prefix.length())); 57 term.substr(prefix.length()));
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 parts_ = url::Parsed(); 564 parts_ = url::Parsed();
565 scheme_.clear(); 565 scheme_.clear();
566 canonicalized_url_ = GURL(); 566 canonicalized_url_ = GURL();
567 prevent_inline_autocomplete_ = false; 567 prevent_inline_autocomplete_ = false;
568 prefer_keyword_ = false; 568 prefer_keyword_ = false;
569 allow_exact_keyword_match_ = false; 569 allow_exact_keyword_match_ = false;
570 want_asynchronous_matches_ = true; 570 want_asynchronous_matches_ = true;
571 from_omnibox_focus_ = false; 571 from_omnibox_focus_ = false;
572 terms_prefixed_by_http_or_https_.clear(); 572 terms_prefixed_by_http_or_https_.clear();
573 } 573 }
OLDNEW
« no previous file with comments | « components/nacl/zygote/nacl_fork_delegate_linux.cc ('k') | components/password_manager/core/browser/password_form_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698