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

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

Issue 273193004: Move some content url constants to /url. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/autocomplete/search_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/autocomplete_input.h" 5 #include "chrome/browser/autocomplete/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 "chrome/browser/external_protocol/external_protocol_handler.h" 9 #include "chrome/browser/external_protocol/external_protocol_handler.h"
10 #include "chrome/browser/profiles/profile_io_data.h" 10 #include "chrome/browser/profiles/profile_io_data.h"
11 #include "chrome/common/net/url_fixer_upper.h" 11 #include "chrome/common/net/url_fixer_upper.h"
12 #include "content/public/common/url_constants.h" 12 #include "content/public/common/url_constants.h"
blundell 2014/05/27 09:39:34 Could you replace all of the includes of //content
Sungmann Cho 2014/05/28 09:10:51 Done.
13 #include "net/base/net_util.h" 13 #include "net/base/net_util.h"
14 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 14 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
15 #include "url/url_canon_ip.h" 15 #include "url/url_canon_ip.h"
16 #include "url/url_util.h" 16 #include "url/url_util.h"
17 17
18 namespace { 18 namespace {
19 19
20 void AdjustCursorPositionIfNecessary(size_t num_leading_chars_removed, 20 void AdjustCursorPositionIfNecessary(size_t num_leading_chars_removed,
21 size_t* cursor_position) { 21 size_t* cursor_position) {
22 if (*cursor_position == base::string16::npos) 22 if (*cursor_position == base::string16::npos)
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // system isn't going to be able to produce a navigable URL match for it. 154 // system isn't going to be able to produce a navigable URL match for it.
155 // So we just return QUERY immediately in these cases. 155 // So we just return QUERY immediately in these cases.
156 GURL placeholder_canonicalized_url; 156 GURL placeholder_canonicalized_url;
157 if (!canonicalized_url) 157 if (!canonicalized_url)
158 canonicalized_url = &placeholder_canonicalized_url; 158 canonicalized_url = &placeholder_canonicalized_url;
159 *canonicalized_url = URLFixerUpper::FixupURL(base::UTF16ToUTF8(text), 159 *canonicalized_url = URLFixerUpper::FixupURL(base::UTF16ToUTF8(text),
160 base::UTF16ToUTF8(desired_tld)); 160 base::UTF16ToUTF8(desired_tld));
161 if (!canonicalized_url->is_valid()) 161 if (!canonicalized_url->is_valid())
162 return QUERY; 162 return QUERY;
163 163
164 if (LowerCaseEqualsASCII(parsed_scheme, content::kFileScheme)) { 164 if (LowerCaseEqualsASCII(parsed_scheme, url::kFileScheme)) {
165 // A user might or might not type a scheme when entering a file URL. In 165 // A user might or might not type a scheme when entering a file URL. In
166 // either case, |parsed_scheme| will tell us that this is a file URL, but 166 // either case, |parsed_scheme| will tell us that this is a file URL, but
167 // |parts->scheme| might be empty, e.g. if the user typed "C:\foo". 167 // |parts->scheme| might be empty, e.g. if the user typed "C:\foo".
168 return URL; 168 return URL;
169 } 169 }
170 170
171 // If the user typed a scheme, and it's HTTP or HTTPS, we know how to parse it 171 // If the user typed a scheme, and it's HTTP or HTTPS, we know how to parse it
172 // well enough that we can fall through to the heuristics below. If it's 172 // well enough that we can fall through to the heuristics below. If it's
173 // something else, we can just determine our action based on what we do with 173 // something else, we can just determine our action based on what we do with
174 // any input of this scheme. In theory we could do better with some schemes 174 // any input of this scheme. In theory we could do better with some schemes
175 // (e.g. "ftp" or "view-source") but I'll wait to spend the effort on that 175 // (e.g. "ftp" or "view-source") but I'll wait to spend the effort on that
176 // until I run into some cases that really need it. 176 // until I run into some cases that really need it.
177 if (parts->scheme.is_nonempty() && 177 if (parts->scheme.is_nonempty() &&
178 !LowerCaseEqualsASCII(parsed_scheme, url::kHttpScheme) && 178 !LowerCaseEqualsASCII(parsed_scheme, url::kHttpScheme) &&
179 !LowerCaseEqualsASCII(parsed_scheme, url::kHttpsScheme)) { 179 !LowerCaseEqualsASCII(parsed_scheme, url::kHttpsScheme)) {
180 // See if we know how to handle the URL internally. There are some schemes 180 // See if we know how to handle the URL internally. There are some schemes
181 // that we convert to other things before they reach the renderer or else 181 // that we convert to other things before they reach the renderer or else
182 // the renderer handles internally without reaching the net::URLRequest 182 // the renderer handles internally without reaching the net::URLRequest
183 // logic. They thus won't be listed as "handled protocols", but we should 183 // logic. They thus won't be listed as "handled protocols", but we should
184 // still claim to handle them. 184 // still claim to handle them.
185 if (ProfileIOData::IsHandledProtocol(base::UTF16ToASCII(parsed_scheme)) || 185 if (ProfileIOData::IsHandledProtocol(base::UTF16ToASCII(parsed_scheme)) ||
186 LowerCaseEqualsASCII(parsed_scheme, content::kViewSourceScheme) || 186 LowerCaseEqualsASCII(parsed_scheme, content::kViewSourceScheme) ||
187 LowerCaseEqualsASCII(parsed_scheme, content::kJavaScriptScheme) || 187 LowerCaseEqualsASCII(parsed_scheme, url::kJavaScriptScheme) ||
188 LowerCaseEqualsASCII(parsed_scheme, content::kDataScheme)) 188 LowerCaseEqualsASCII(parsed_scheme, url::kDataScheme))
189 return URL; 189 return URL;
190 190
191 // Not an internal protocol. Check and see if the user has explicitly 191 // Not an internal protocol. Check and see if the user has explicitly
192 // opened this scheme as a URL before, or if the "scheme" is actually a 192 // opened this scheme as a URL before, or if the "scheme" is actually a
193 // username. We need to do this after the check above because some 193 // username. We need to do this after the check above because some
194 // handlable schemes (e.g. "javascript") may be treated as "blocked" by the 194 // handlable schemes (e.g. "javascript") may be treated as "blocked" by the
195 // external protocol handler because we don't want pages to open them, but 195 // external protocol handler because we don't want pages to open them, but
196 // users still can. 196 // users still can.
197 // Note that the protocol handler needs to be informed that omnibox input 197 // Note that the protocol handler needs to be informed that omnibox input
198 // should always be considered "user gesture-triggered", lest it always 198 // should always be considered "user gesture-triggered", lest it always
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 } else { 449 } else {
450 scheme->reset(); 450 scheme->reset();
451 } 451 }
452 if (real_parts.host.is_nonempty()) { 452 if (real_parts.host.is_nonempty()) {
453 *host = url::Component(after_scheme_and_colon + real_parts.host.begin, 453 *host = url::Component(after_scheme_and_colon + real_parts.host.begin,
454 real_parts.host.len); 454 real_parts.host.len);
455 } else { 455 } else {
456 host->reset(); 456 host->reset();
457 } 457 }
458 } 458 }
459 } else if (LowerCaseEqualsASCII(scheme_str, content::kFileSystemScheme) && 459 } else if (LowerCaseEqualsASCII(scheme_str, url::kFileSystemScheme) &&
460 parts.inner_parsed() && parts.inner_parsed()->scheme.is_valid()) { 460 parts.inner_parsed() && parts.inner_parsed()->scheme.is_valid()) {
461 *host = parts.inner_parsed()->host; 461 *host = parts.inner_parsed()->host;
462 } 462 }
463 } 463 }
464 464
465 // static 465 // static
466 base::string16 AutocompleteInput::FormattedStringWithEquivalentMeaning( 466 base::string16 AutocompleteInput::FormattedStringWithEquivalentMeaning(
467 const GURL& url, 467 const GURL& url,
468 const base::string16& formatted_url) { 468 const base::string16& formatted_url) {
469 if (!net::CanStripTrailingSlash(url)) 469 if (!net::CanStripTrailingSlash(url))
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 current_page_classification_ = AutocompleteInput::INVALID_SPEC; 525 current_page_classification_ = AutocompleteInput::INVALID_SPEC;
526 type_ = INVALID; 526 type_ = INVALID;
527 parts_ = url::Parsed(); 527 parts_ = url::Parsed();
528 scheme_.clear(); 528 scheme_.clear();
529 canonicalized_url_ = GURL(); 529 canonicalized_url_ = GURL();
530 prevent_inline_autocomplete_ = false; 530 prevent_inline_autocomplete_ = false;
531 prefer_keyword_ = false; 531 prefer_keyword_ = false;
532 allow_exact_keyword_match_ = false; 532 allow_exact_keyword_match_ = false;
533 want_asynchronous_matches_ = true; 533 want_asynchronous_matches_ = true;
534 } 534 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/autocomplete/search_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698