OLD | NEW |
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/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/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/net/url_fixer_upper.h" | 10 #include "chrome/browser/net/url_fixer_upper.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 !LowerCaseEqualsASCII(parsed_scheme, chrome::kHttpScheme) && | 171 !LowerCaseEqualsASCII(parsed_scheme, chrome::kHttpScheme) && |
172 !LowerCaseEqualsASCII(parsed_scheme, chrome::kHttpsScheme)) { | 172 !LowerCaseEqualsASCII(parsed_scheme, chrome::kHttpsScheme)) { |
173 // See if we know how to handle the URL internally. | 173 // See if we know how to handle the URL internally. |
174 if (ProfileIOData::IsHandledProtocol(UTF16ToASCII(parsed_scheme))) | 174 if (ProfileIOData::IsHandledProtocol(UTF16ToASCII(parsed_scheme))) |
175 return URL; | 175 return URL; |
176 | 176 |
177 // There are also some schemes that we convert to other things before they | 177 // There are also some schemes that we convert to other things before they |
178 // reach the renderer or else the renderer handles internally without | 178 // reach the renderer or else the renderer handles internally without |
179 // reaching the net::URLRequest logic. We thus won't catch these above, but | 179 // reaching the net::URLRequest logic. We thus won't catch these above, but |
180 // we should still claim to handle them. | 180 // we should still claim to handle them. |
181 if (LowerCaseEqualsASCII(parsed_scheme, chrome::kViewSourceScheme) || | 181 if (LowerCaseEqualsASCII(parsed_scheme, content::kViewSourceScheme) || |
182 LowerCaseEqualsASCII(parsed_scheme, chrome::kJavaScriptScheme) || | 182 LowerCaseEqualsASCII(parsed_scheme, chrome::kJavaScriptScheme) || |
183 LowerCaseEqualsASCII(parsed_scheme, chrome::kDataScheme)) | 183 LowerCaseEqualsASCII(parsed_scheme, chrome::kDataScheme)) |
184 return URL; | 184 return URL; |
185 | 185 |
186 // Finally, check and see if the user has explicitly opened this scheme as | 186 // Finally, check and see if the user has explicitly opened this scheme as |
187 // a URL before, or if the "scheme" is actually a username. We need to do | 187 // a URL before, or if the "scheme" is actually a username. We need to do |
188 // this last because some schemes (e.g. "javascript") may be treated as | 188 // this last because some schemes (e.g. "javascript") may be treated as |
189 // "blocked" by the external protocol handler because we don't want pages to | 189 // "blocked" by the external protocol handler because we don't want pages to |
190 // open them, but users still can. | 190 // open them, but users still can. |
191 // TODO(viettrungluu): get rid of conversion. | 191 // TODO(viettrungluu): get rid of conversion. |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 url_parse::Parsed parts; | 424 url_parse::Parsed parts; |
425 string16 scheme_str; | 425 string16 scheme_str; |
426 Parse(text, string16(), &parts, &scheme_str, NULL); | 426 Parse(text, string16(), &parts, &scheme_str, NULL); |
427 | 427 |
428 *scheme = parts.scheme; | 428 *scheme = parts.scheme; |
429 *host = parts.host; | 429 *host = parts.host; |
430 | 430 |
431 int after_scheme_and_colon = parts.scheme.end() + 1; | 431 int after_scheme_and_colon = parts.scheme.end() + 1; |
432 // For the view-source scheme, we should emphasize the scheme and host of the | 432 // For the view-source scheme, we should emphasize the scheme and host of the |
433 // URL qualified by the view-source prefix. | 433 // URL qualified by the view-source prefix. |
434 if (LowerCaseEqualsASCII(scheme_str, chrome::kViewSourceScheme) && | 434 if (LowerCaseEqualsASCII(scheme_str, content::kViewSourceScheme) && |
435 (static_cast<int>(text.length()) > after_scheme_and_colon)) { | 435 (static_cast<int>(text.length()) > after_scheme_and_colon)) { |
436 // Obtain the URL prefixed by view-source and parse it. | 436 // Obtain the URL prefixed by view-source and parse it. |
437 string16 real_url(text.substr(after_scheme_and_colon)); | 437 string16 real_url(text.substr(after_scheme_and_colon)); |
438 url_parse::Parsed real_parts; | 438 url_parse::Parsed real_parts; |
439 AutocompleteInput::Parse(real_url, string16(), &real_parts, NULL, NULL); | 439 AutocompleteInput::Parse(real_url, string16(), &real_parts, NULL, NULL); |
440 if (real_parts.scheme.is_nonempty() || real_parts.host.is_nonempty()) { | 440 if (real_parts.scheme.is_nonempty() || real_parts.host.is_nonempty()) { |
441 if (real_parts.scheme.is_nonempty()) { | 441 if (real_parts.scheme.is_nonempty()) { |
442 *scheme = url_parse::Component( | 442 *scheme = url_parse::Component( |
443 after_scheme_and_colon + real_parts.scheme.begin, | 443 after_scheme_and_colon + real_parts.scheme.begin, |
444 real_parts.scheme.len); | 444 real_parts.scheme.len); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 current_url_ = GURL(); | 509 current_url_ = GURL(); |
510 type_ = INVALID; | 510 type_ = INVALID; |
511 parts_ = url_parse::Parsed(); | 511 parts_ = url_parse::Parsed(); |
512 scheme_.clear(); | 512 scheme_.clear(); |
513 canonicalized_url_ = GURL(); | 513 canonicalized_url_ = GURL(); |
514 prevent_inline_autocomplete_ = false; | 514 prevent_inline_autocomplete_ = false; |
515 prefer_keyword_ = false; | 515 prefer_keyword_ = false; |
516 allow_exact_keyword_match_ = false; | 516 allow_exact_keyword_match_ = false; |
517 matches_requested_ = ALL_MATCHES; | 517 matches_requested_ = ALL_MATCHES; |
518 } | 518 } |
OLD | NEW |