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

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

Issue 1182183003: Move EndsWith to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 (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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 if (url.SchemeIs(content::kChromeUIScheme) && url.has_host() && 108 if (url.SchemeIs(content::kChromeUIScheme) && url.has_host() &&
109 !url.has_query() && !url.has_ref()) { 109 !url.has_query() && !url.has_ref()) {
110 // Suggest about:blank for substrings, taking URL fixup into account. 110 // Suggest about:blank for substrings, taking URL fixup into account.
111 // Chrome does not support trailing slashes or paths for about:blank. 111 // Chrome does not support trailing slashes or paths for about:blank.
112 const base::string16 blank_host = base::ASCIIToUTF16("blank"); 112 const base::string16 blank_host = base::ASCIIToUTF16("blank");
113 const base::string16 host = base::UTF8ToUTF16(url.host()); 113 const base::string16 host = base::UTF8ToUTF16(url.host());
114 if (base::StartsWith(text, base::ASCIIToUTF16(url::kAboutScheme), 114 if (base::StartsWith(text, base::ASCIIToUTF16(url::kAboutScheme),
115 false) && 115 false) &&
116 base::StartsWith(blank_host, host, false) && 116 base::StartsWith(blank_host, host, false) &&
117 (url.path().length() <= 1) && 117 (url.path().length() <= 1) &&
118 !EndsWith(text, base::ASCIIToUTF16("/"), false)) { 118 !base::EndsWith(text, base::ASCIIToUTF16("/"), false)) {
119 ACMatchClassifications styles; 119 ACMatchClassifications styles;
120 styles.push_back(ACMatchClassification(0, kMatch)); 120 styles.push_back(ACMatchClassification(0, kMatch));
121 base::string16 match = base::ASCIIToUTF16(url::kAboutBlankURL); 121 base::string16 match = base::ASCIIToUTF16(url::kAboutBlankURL);
122 // Measure the length of the matching host after the "about:" scheme. 122 // Measure the length of the matching host after the "about:" scheme.
123 const size_t corrected_length = kAboutSchemeLength + 1 + host.length(); 123 const size_t corrected_length = kAboutSchemeLength + 1 + host.length();
124 if (blank_host.length() > host.length()) 124 if (blank_host.length() > host.length())
125 styles.push_back(ACMatchClassification(corrected_length, kUrl)); 125 styles.push_back(ACMatchClassification(corrected_length, kUrl));
126 AddMatch(match, match.substr(corrected_length), styles); 126 AddMatch(match, match.substr(corrected_length), styles);
127 } 127 }
128 128
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 const ACMatchClassifications& styles) { 164 const ACMatchClassifications& styles) {
165 AutocompleteMatch match(this, kRelevance, false, 165 AutocompleteMatch match(this, kRelevance, false,
166 AutocompleteMatchType::NAVSUGGEST); 166 AutocompleteMatchType::NAVSUGGEST);
167 match.fill_into_edit = match_string; 167 match.fill_into_edit = match_string;
168 match.inline_autocompletion = inline_completion; 168 match.inline_autocompletion = inline_completion;
169 match.destination_url = GURL(match_string); 169 match.destination_url = GURL(match_string);
170 match.contents = match_string; 170 match.contents = match_string;
171 match.contents_class = styles; 171 match.contents_class = styles;
172 matches_.push_back(match); 172 matches_.push_back(match);
173 } 173 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698