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

Side by Side Diff: chrome/browser/autocomplete/builtin_provider.cc

Issue 102843002: Move RemoveChars, ReplaceChars, TrimString, and TruncateUTF8ToByteSize to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/autocomplete/builtin_provider.h" 5 #include "chrome/browser/autocomplete/builtin_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 AddMatch(ASCIIToUTF16(chrome::kChromeUIVersionURL), string16(), styles); 86 AddMatch(ASCIIToUTF16(chrome::kChromeUIVersionURL), string16(), styles);
87 } else { 87 } else {
88 // Match input about: or chrome: URL input against builtin chrome URLs. 88 // Match input about: or chrome: URL input against builtin chrome URLs.
89 GURL url = URLFixerUpper::FixupURL(UTF16ToUTF8(text), std::string()); 89 GURL url = URLFixerUpper::FixupURL(UTF16ToUTF8(text), std::string());
90 // BuiltinProvider doesn't know how to suggest valid ?query or #fragment 90 // BuiltinProvider doesn't know how to suggest valid ?query or #fragment
91 // extensions to chrome: URLs. 91 // extensions to chrome: URLs.
92 if (url.SchemeIs(chrome::kChromeUIScheme) && url.has_host() && 92 if (url.SchemeIs(chrome::kChromeUIScheme) && url.has_host() &&
93 !url.has_query() && !url.has_ref()) { 93 !url.has_query() && !url.has_ref()) {
94 // Include the path for sub-pages (e.g. "chrome://settings/browser"). 94 // Include the path for sub-pages (e.g. "chrome://settings/browser").
95 string16 host_and_path = UTF8ToUTF16(url.host() + url.path()); 95 string16 host_and_path = UTF8ToUTF16(url.host() + url.path());
96 TrimString(host_and_path, ASCIIToUTF16("/").c_str(), &host_and_path); 96 base::TrimString(host_and_path, ASCIIToUTF16("/").c_str(),
97 &host_and_path);
97 size_t match_length = kChrome.length() + host_and_path.length(); 98 size_t match_length = kChrome.length() + host_and_path.length();
98 for (Builtins::const_iterator i(builtins_.begin()); 99 for (Builtins::const_iterator i(builtins_.begin());
99 (i != builtins_.end()) && (matches_.size() < kMaxMatches); ++i) { 100 (i != builtins_.end()) && (matches_.size() < kMaxMatches); ++i) {
100 if (StartsWith(*i, host_and_path, false)) { 101 if (StartsWith(*i, host_and_path, false)) {
101 ACMatchClassifications styles; 102 ACMatchClassifications styles;
102 // Highlight the "chrome://" scheme, even for input "about:foo". 103 // Highlight the "chrome://" scheme, even for input "about:foo".
103 styles.push_back(ACMatchClassification(0, kMatch)); 104 styles.push_back(ACMatchClassification(0, kMatch));
104 string16 match_string = kChrome + *i; 105 string16 match_string = kChrome + *i;
105 if (match_string.length() > match_length) 106 if (match_string.length() > match_length)
106 styles.push_back(ACMatchClassification(match_length, kUrl)); 107 styles.push_back(ACMatchClassification(match_length, kUrl));
(...skipping 21 matching lines...) Expand all
128 const ACMatchClassifications& styles) { 129 const ACMatchClassifications& styles) {
129 AutocompleteMatch match(this, kRelevance, false, 130 AutocompleteMatch match(this, kRelevance, false,
130 AutocompleteMatchType::NAVSUGGEST); 131 AutocompleteMatchType::NAVSUGGEST);
131 match.fill_into_edit = match_string; 132 match.fill_into_edit = match_string;
132 match.inline_autocompletion = inline_completion; 133 match.inline_autocompletion = inline_completion;
133 match.destination_url = GURL(match_string); 134 match.destination_url = GURL(match_string);
134 match.contents = match_string; 135 match.contents = match_string;
135 match.contents_class = styles; 136 match.contents_class = styles;
136 matches_.push_back(match); 137 matches_.push_back(match);
137 } 138 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698