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.h" | 5 #include "chrome/browser/autocomplete/autocomplete.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 83 |
84 GURL canonicalized_url; | 84 GURL canonicalized_url; |
85 type_ = Parse(text_, desired_tld, &parts_, &scheme_, &canonicalized_url); | 85 type_ = Parse(text_, desired_tld, &parts_, &scheme_, &canonicalized_url); |
86 | 86 |
87 if (type_ == INVALID) | 87 if (type_ == INVALID) |
88 return; | 88 return; |
89 | 89 |
90 if (((type_ == UNKNOWN) || (type_ == REQUESTED_URL) || (type_ == URL)) && | 90 if (((type_ == UNKNOWN) || (type_ == REQUESTED_URL) || (type_ == URL)) && |
91 canonicalized_url.is_valid() && | 91 canonicalized_url.is_valid() && |
92 (!canonicalized_url.IsStandard() || canonicalized_url.SchemeIsFile() || | 92 (!canonicalized_url.IsStandard() || canonicalized_url.SchemeIsFile() || |
| 93 canonicalized_url.SchemeIsFileSystem() || |
93 !canonicalized_url.host().empty())) | 94 !canonicalized_url.host().empty())) |
94 canonicalized_url_ = canonicalized_url; | 95 canonicalized_url_ = canonicalized_url; |
95 | 96 |
96 RemoveForcedQueryStringIfNecessary(type_, &text_); | 97 RemoveForcedQueryStringIfNecessary(type_, &text_); |
97 } | 98 } |
98 | 99 |
99 AutocompleteInput::~AutocompleteInput() { | 100 AutocompleteInput::~AutocompleteInput() { |
100 } | 101 } |
101 | 102 |
102 // static | 103 // static |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 UTF16ToUTF8(desired_tld)); | 155 UTF16ToUTF8(desired_tld)); |
155 } | 156 } |
156 | 157 |
157 if (LowerCaseEqualsASCII(parsed_scheme, chrome::kFileScheme)) { | 158 if (LowerCaseEqualsASCII(parsed_scheme, chrome::kFileScheme)) { |
158 // A user might or might not type a scheme when entering a file URL. In | 159 // A user might or might not type a scheme when entering a file URL. In |
159 // either case, |parsed_scheme| will tell us that this is a file URL, but | 160 // either case, |parsed_scheme| will tell us that this is a file URL, but |
160 // |parts->scheme| might be empty, e.g. if the user typed "C:\foo". | 161 // |parts->scheme| might be empty, e.g. if the user typed "C:\foo". |
161 return URL; | 162 return URL; |
162 } | 163 } |
163 | 164 |
| 165 if (LowerCaseEqualsASCII(parsed_scheme, chrome::kFileSystemScheme)) { |
| 166 // This could theoretically be a strange search, but let's check. |
| 167 // If it's got an inner_url with a scheme, it's a URL, whether it's valid or |
| 168 // not. |
| 169 if (parts->inner_parsed() && parts->inner_parsed()->scheme.is_valid()) |
| 170 return URL; |
| 171 } |
| 172 |
164 // If the user typed a scheme, and it's HTTP or HTTPS, we know how to parse it | 173 // If the user typed a scheme, and it's HTTP or HTTPS, we know how to parse it |
165 // well enough that we can fall through to the heuristics below. If it's | 174 // well enough that we can fall through to the heuristics below. If it's |
166 // something else, we can just determine our action based on what we do with | 175 // something else, we can just determine our action based on what we do with |
167 // any input of this scheme. In theory we could do better with some schemes | 176 // any input of this scheme. In theory we could do better with some schemes |
168 // (e.g. "ftp" or "view-source") but I'll wait to spend the effort on that | 177 // (e.g. "ftp" or "view-source") but I'll wait to spend the effort on that |
169 // until I run into some cases that really need it. | 178 // until I run into some cases that really need it. |
170 if (parts->scheme.is_nonempty() && | 179 if (parts->scheme.is_nonempty() && |
171 !LowerCaseEqualsASCII(parsed_scheme, chrome::kHttpScheme) && | 180 !LowerCaseEqualsASCII(parsed_scheme, chrome::kHttpScheme) && |
172 !LowerCaseEqualsASCII(parsed_scheme, chrome::kHttpsScheme)) { | 181 !LowerCaseEqualsASCII(parsed_scheme, chrome::kHttpsScheme)) { |
173 // See if we know how to handle the URL internally. | 182 // See if we know how to handle the URL internally. |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 scheme->reset(); | 452 scheme->reset(); |
444 } | 453 } |
445 if (real_parts.host.is_nonempty()) { | 454 if (real_parts.host.is_nonempty()) { |
446 *host = url_parse::Component( | 455 *host = url_parse::Component( |
447 after_scheme_and_colon + real_parts.host.begin, | 456 after_scheme_and_colon + real_parts.host.begin, |
448 real_parts.host.len); | 457 real_parts.host.len); |
449 } else { | 458 } else { |
450 host->reset(); | 459 host->reset(); |
451 } | 460 } |
452 } | 461 } |
| 462 } else if (LowerCaseEqualsASCII(scheme_str, chrome::kFileSystemScheme) && |
| 463 parts.inner_parsed() && parts.inner_parsed()->scheme.is_valid()) { |
| 464 *host = parts.inner_parsed()->host; |
453 } | 465 } |
454 } | 466 } |
455 | 467 |
456 // static | 468 // static |
457 string16 AutocompleteInput::FormattedStringWithEquivalentMeaning( | 469 string16 AutocompleteInput::FormattedStringWithEquivalentMeaning( |
458 const GURL& url, | 470 const GURL& url, |
459 const string16& formatted_url) { | 471 const string16& formatted_url) { |
460 if (!net::CanStripTrailingSlash(url)) | 472 if (!net::CanStripTrailingSlash(url)) |
461 return formatted_url; | 473 return formatted_url; |
462 const string16 url_with_path(formatted_url + char16('/')); | 474 const string16 url_with_path(formatted_url + char16('/')); |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1079 const AutocompleteResult& result) | 1091 const AutocompleteResult& result) |
1080 : text(text), | 1092 : text(text), |
1081 input_type(input_type), | 1093 input_type(input_type), |
1082 selected_index(selected_index), | 1094 selected_index(selected_index), |
1083 tab_id(tab_id), | 1095 tab_id(tab_id), |
1084 elapsed_time_since_user_first_modified_omnibox( | 1096 elapsed_time_since_user_first_modified_omnibox( |
1085 elapsed_time_since_user_first_modified_omnibox), | 1097 elapsed_time_since_user_first_modified_omnibox), |
1086 inline_autocompleted_length(inline_autocompleted_length), | 1098 inline_autocompleted_length(inline_autocompleted_length), |
1087 result(result) { | 1099 result(result) { |
1088 } | 1100 } |
OLD | NEW |