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/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" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 return URL; | 165 return URL; |
166 } | 166 } |
167 | 167 |
168 // If the user typed a scheme, and it's HTTP or HTTPS, we know how to parse it | 168 // If the user typed a scheme, and it's HTTP or HTTPS, we know how to parse it |
169 // well enough that we can fall through to the heuristics below. If it's | 169 // well enough that we can fall through to the heuristics below. If it's |
170 // something else, we can just determine our action based on what we do with | 170 // something else, we can just determine our action based on what we do with |
171 // any input of this scheme. In theory we could do better with some schemes | 171 // any input of this scheme. In theory we could do better with some schemes |
172 // (e.g. "ftp" or "view-source") but I'll wait to spend the effort on that | 172 // (e.g. "ftp" or "view-source") but I'll wait to spend the effort on that |
173 // until I run into some cases that really need it. | 173 // until I run into some cases that really need it. |
174 if (parts->scheme.is_nonempty() && | 174 if (parts->scheme.is_nonempty() && |
175 !LowerCaseEqualsASCII(parsed_scheme, chrome::kHttpScheme) && | 175 !LowerCaseEqualsASCII(parsed_scheme, content::kHttpScheme) && |
176 !LowerCaseEqualsASCII(parsed_scheme, content::kHttpsScheme)) { | 176 !LowerCaseEqualsASCII(parsed_scheme, content::kHttpsScheme)) { |
177 // See if we know how to handle the URL internally. | 177 // See if we know how to handle the URL internally. |
178 if (ProfileIOData::IsHandledProtocol(UTF16ToASCII(parsed_scheme))) | 178 if (ProfileIOData::IsHandledProtocol(UTF16ToASCII(parsed_scheme))) |
179 return URL; | 179 return URL; |
180 | 180 |
181 // There are also some schemes that we convert to other things before they | 181 // There are also some schemes that we convert to other things before they |
182 // reach the renderer or else the renderer handles internally without | 182 // reach the renderer or else the renderer handles internally without |
183 // reaching the net::URLRequest logic. We thus won't catch these above, but | 183 // reaching the net::URLRequest logic. We thus won't catch these above, but |
184 // we should still claim to handle them. | 184 // we should still claim to handle them. |
185 if (LowerCaseEqualsASCII(parsed_scheme, content::kViewSourceScheme) || | 185 if (LowerCaseEqualsASCII(parsed_scheme, content::kViewSourceScheme) || |
(...skipping 15 matching lines...) Expand all Loading... |
201 | 201 |
202 case ExternalProtocolHandler::BLOCK: | 202 case ExternalProtocolHandler::BLOCK: |
203 // If we don't want the user to open the URL, don't let it be navigated | 203 // If we don't want the user to open the URL, don't let it be navigated |
204 // to at all. | 204 // to at all. |
205 return QUERY; | 205 return QUERY; |
206 | 206 |
207 default: { | 207 default: { |
208 // We don't know about this scheme. It might be that the user typed a | 208 // We don't know about this scheme. It might be that the user typed a |
209 // URL of the form "username:password@foo.com". | 209 // URL of the form "username:password@foo.com". |
210 const string16 http_scheme_prefix = | 210 const string16 http_scheme_prefix = |
211 ASCIIToUTF16(std::string(chrome::kHttpScheme) + | 211 ASCIIToUTF16(std::string(content::kHttpScheme) + |
212 content::kStandardSchemeSeparator); | 212 content::kStandardSchemeSeparator); |
213 url_parse::Parsed http_parts; | 213 url_parse::Parsed http_parts; |
214 string16 http_scheme; | 214 string16 http_scheme; |
215 GURL http_canonicalized_url; | 215 GURL http_canonicalized_url; |
216 Type http_type = Parse(http_scheme_prefix + text, desired_tld, | 216 Type http_type = Parse(http_scheme_prefix + text, desired_tld, |
217 &http_parts, &http_scheme, | 217 &http_parts, &http_scheme, |
218 &http_canonicalized_url); | 218 &http_canonicalized_url); |
219 DCHECK_EQ(std::string(chrome::kHttpScheme), UTF16ToUTF8(http_scheme)); | 219 DCHECK_EQ(std::string(content::kHttpScheme), UTF16ToUTF8(http_scheme)); |
220 | 220 |
221 if (http_type == URL && | 221 if (http_type == URL && |
222 http_parts.username.is_nonempty() && | 222 http_parts.username.is_nonempty() && |
223 http_parts.password.is_nonempty()) { | 223 http_parts.password.is_nonempty()) { |
224 // Manually re-jigger the parsed parts to match |text| (without the | 224 // Manually re-jigger the parsed parts to match |text| (without the |
225 // http scheme added). | 225 // http scheme added). |
226 http_parts.scheme.reset(); | 226 http_parts.scheme.reset(); |
227 url_parse::Component* components[] = { | 227 url_parse::Component* components[] = { |
228 &http_parts.username, | 228 &http_parts.username, |
229 &http_parts.password, | 229 &http_parts.password, |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 current_page_classification_ = AutocompleteInput::INVALID_SPEC; | 514 current_page_classification_ = AutocompleteInput::INVALID_SPEC; |
515 type_ = INVALID; | 515 type_ = INVALID; |
516 parts_ = url_parse::Parsed(); | 516 parts_ = url_parse::Parsed(); |
517 scheme_.clear(); | 517 scheme_.clear(); |
518 canonicalized_url_ = GURL(); | 518 canonicalized_url_ = GURL(); |
519 prevent_inline_autocomplete_ = false; | 519 prevent_inline_autocomplete_ = false; |
520 prefer_keyword_ = false; | 520 prefer_keyword_ = false; |
521 allow_exact_keyword_match_ = false; | 521 allow_exact_keyword_match_ = false; |
522 matches_requested_ = ALL_MATCHES; | 522 matches_requested_ = ALL_MATCHES; |
523 } | 523 } |
OLD | NEW |