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

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

Issue 448143008: Move StringToUpperASCII and LowerCaseEqualsASCII to the base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
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/autocomplete_input.h" 5 #include "components/omnibox/autocomplete_input.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "components/metrics/proto/omnibox_event.pb.h" 9 #include "components/metrics/proto/omnibox_event.pb.h"
10 #include "components/omnibox/autocomplete_scheme_classifier.h" 10 #include "components/omnibox/autocomplete_scheme_classifier.h"
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 // system isn't going to be able to produce a navigable URL match for it. 162 // system isn't going to be able to produce a navigable URL match for it.
163 // So we just return QUERY immediately in these cases. 163 // So we just return QUERY immediately in these cases.
164 GURL placeholder_canonicalized_url; 164 GURL placeholder_canonicalized_url;
165 if (!canonicalized_url) 165 if (!canonicalized_url)
166 canonicalized_url = &placeholder_canonicalized_url; 166 canonicalized_url = &placeholder_canonicalized_url;
167 *canonicalized_url = url_fixer::FixupURL(base::UTF16ToUTF8(text), 167 *canonicalized_url = url_fixer::FixupURL(base::UTF16ToUTF8(text),
168 base::UTF16ToUTF8(desired_tld)); 168 base::UTF16ToUTF8(desired_tld));
169 if (!canonicalized_url->is_valid()) 169 if (!canonicalized_url->is_valid())
170 return metrics::OmniboxInputType::QUERY; 170 return metrics::OmniboxInputType::QUERY;
171 171
172 if (LowerCaseEqualsASCII(parsed_scheme_utf8, url::kFileScheme)) { 172 if (base::LowerCaseEqualsASCII(parsed_scheme_utf8, url::kFileScheme)) {
173 // A user might or might not type a scheme when entering a file URL. In 173 // A user might or might not type a scheme when entering a file URL. In
174 // either case, |parsed_scheme_utf8| will tell us that this is a file URL, 174 // either case, |parsed_scheme_utf8| will tell us that this is a file URL,
175 // but |parts->scheme| might be empty, e.g. if the user typed "C:\foo". 175 // but |parts->scheme| might be empty, e.g. if the user typed "C:\foo".
176 return metrics::OmniboxInputType::URL; 176 return metrics::OmniboxInputType::URL;
177 } 177 }
178 178
179 // If the user typed a scheme, and it's HTTP or HTTPS, we know how to parse it 179 // If the user typed a scheme, and it's HTTP or HTTPS, we know how to parse it
180 // well enough that we can fall through to the heuristics below. If it's 180 // well enough that we can fall through to the heuristics below. If it's
181 // something else, we can just determine our action based on what we do with 181 // something else, we can just determine our action based on what we do with
182 // any input of this scheme. In theory we could do better with some schemes 182 // any input of this scheme. In theory we could do better with some schemes
183 // (e.g. "ftp" or "view-source") but I'll wait to spend the effort on that 183 // (e.g. "ftp" or "view-source") but I'll wait to spend the effort on that
184 // until I run into some cases that really need it. 184 // until I run into some cases that really need it.
185 if (parts->scheme.is_nonempty() && 185 if (parts->scheme.is_nonempty() &&
186 !LowerCaseEqualsASCII(parsed_scheme_utf8, url::kHttpScheme) && 186 !base::LowerCaseEqualsASCII(parsed_scheme_utf8, url::kHttpScheme) &&
187 !LowerCaseEqualsASCII(parsed_scheme_utf8, url::kHttpsScheme)) { 187 !base::LowerCaseEqualsASCII(parsed_scheme_utf8, url::kHttpsScheme)) {
188 metrics::OmniboxInputType::Type type = 188 metrics::OmniboxInputType::Type type =
189 scheme_classifier.GetInputTypeForScheme(parsed_scheme_utf8); 189 scheme_classifier.GetInputTypeForScheme(parsed_scheme_utf8);
190 if (type != metrics::OmniboxInputType::INVALID) 190 if (type != metrics::OmniboxInputType::INVALID)
191 return type; 191 return type;
192 192
193 // We don't know about this scheme. It might be that the user typed a 193 // We don't know about this scheme. It might be that the user typed a
194 // URL of the form "username:password@foo.com". 194 // URL of the form "username:password@foo.com".
195 const base::string16 http_scheme_prefix = 195 const base::string16 http_scheme_prefix =
196 base::ASCIIToUTF16(std::string(url::kHttpScheme) + 196 base::ASCIIToUTF16(std::string(url::kHttpScheme) +
197 url::kStandardSchemeSeparator); 197 url::kStandardSchemeSeparator);
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 url::Parsed parts; 415 url::Parsed parts;
416 base::string16 scheme_str; 416 base::string16 scheme_str;
417 Parse(text, base::string16(), scheme_classifier, &parts, &scheme_str, NULL); 417 Parse(text, base::string16(), scheme_classifier, &parts, &scheme_str, NULL);
418 418
419 *scheme = parts.scheme; 419 *scheme = parts.scheme;
420 *host = parts.host; 420 *host = parts.host;
421 421
422 int after_scheme_and_colon = parts.scheme.end() + 1; 422 int after_scheme_and_colon = parts.scheme.end() + 1;
423 // For the view-source scheme, we should emphasize the scheme and host of the 423 // For the view-source scheme, we should emphasize the scheme and host of the
424 // URL qualified by the view-source prefix. 424 // URL qualified by the view-source prefix.
425 if (LowerCaseEqualsASCII(scheme_str, kViewSourceScheme) && 425 if (base::LowerCaseEqualsASCII(scheme_str, kViewSourceScheme) &&
426 (static_cast<int>(text.length()) > after_scheme_and_colon)) { 426 (static_cast<int>(text.length()) > after_scheme_and_colon)) {
427 // Obtain the URL prefixed by view-source and parse it. 427 // Obtain the URL prefixed by view-source and parse it.
428 base::string16 real_url(text.substr(after_scheme_and_colon)); 428 base::string16 real_url(text.substr(after_scheme_and_colon));
429 url::Parsed real_parts; 429 url::Parsed real_parts;
430 AutocompleteInput::Parse(real_url, base::string16(), scheme_classifier, 430 AutocompleteInput::Parse(real_url, base::string16(), scheme_classifier,
431 &real_parts, NULL, NULL); 431 &real_parts, NULL, NULL);
432 if (real_parts.scheme.is_nonempty() || real_parts.host.is_nonempty()) { 432 if (real_parts.scheme.is_nonempty() || real_parts.host.is_nonempty()) {
433 if (real_parts.scheme.is_nonempty()) { 433 if (real_parts.scheme.is_nonempty()) {
434 *scheme = url::Component( 434 *scheme = url::Component(
435 after_scheme_and_colon + real_parts.scheme.begin, 435 after_scheme_and_colon + real_parts.scheme.begin,
436 real_parts.scheme.len); 436 real_parts.scheme.len);
437 } else { 437 } else {
438 scheme->reset(); 438 scheme->reset();
439 } 439 }
440 if (real_parts.host.is_nonempty()) { 440 if (real_parts.host.is_nonempty()) {
441 *host = url::Component(after_scheme_and_colon + real_parts.host.begin, 441 *host = url::Component(after_scheme_and_colon + real_parts.host.begin,
442 real_parts.host.len); 442 real_parts.host.len);
443 } else { 443 } else {
444 host->reset(); 444 host->reset();
445 } 445 }
446 } 446 }
447 } else if (LowerCaseEqualsASCII(scheme_str, url::kFileSystemScheme) && 447 } else if (base::LowerCaseEqualsASCII(scheme_str, url::kFileSystemScheme) &&
448 parts.inner_parsed() && parts.inner_parsed()->scheme.is_valid()) { 448 parts.inner_parsed() && parts.inner_parsed()->scheme.is_valid()) {
449 *host = parts.inner_parsed()->host; 449 *host = parts.inner_parsed()->host;
450 } 450 }
451 } 451 }
452 452
453 // static 453 // static
454 base::string16 AutocompleteInput::FormattedStringWithEquivalentMeaning( 454 base::string16 AutocompleteInput::FormattedStringWithEquivalentMeaning(
455 const GURL& url, 455 const GURL& url,
456 const base::string16& formatted_url, 456 const base::string16& formatted_url,
457 const AutocompleteSchemeClassifier& scheme_classifier) { 457 const AutocompleteSchemeClassifier& scheme_classifier) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 current_page_classification_ = metrics::OmniboxEventProto::INVALID_SPEC; 513 current_page_classification_ = metrics::OmniboxEventProto::INVALID_SPEC;
514 type_ = metrics::OmniboxInputType::INVALID; 514 type_ = metrics::OmniboxInputType::INVALID;
515 parts_ = url::Parsed(); 515 parts_ = url::Parsed();
516 scheme_.clear(); 516 scheme_.clear();
517 canonicalized_url_ = GURL(); 517 canonicalized_url_ = GURL();
518 prevent_inline_autocomplete_ = false; 518 prevent_inline_autocomplete_ = false;
519 prefer_keyword_ = false; 519 prefer_keyword_ = false;
520 allow_exact_keyword_match_ = false; 520 allow_exact_keyword_match_ = false;
521 want_asynchronous_matches_ = true; 521 want_asynchronous_matches_ = true;
522 } 522 }
OLDNEW
« no previous file with comments | « components/metrics/serialization/serialization_utils.cc ('k') | components/plugins/renderer/mobile_youtube_plugin.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698