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 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 88 |
89 GURL canonicalized_url; | 89 GURL canonicalized_url; |
90 type_ = Parse(text_, desired_tld, &parts_, &scheme_, &canonicalized_url); | 90 type_ = Parse(text_, desired_tld, &parts_, &scheme_, &canonicalized_url); |
91 | 91 |
92 if (type_ == INVALID) | 92 if (type_ == INVALID) |
93 return; | 93 return; |
94 | 94 |
95 if (((type_ == UNKNOWN) || (type_ == REQUESTED_URL) || (type_ == URL)) && | 95 if (((type_ == UNKNOWN) || (type_ == REQUESTED_URL) || (type_ == URL)) && |
96 canonicalized_url.is_valid() && | 96 canonicalized_url.is_valid() && |
97 (!canonicalized_url.IsStandard() || canonicalized_url.SchemeIsFile() || | 97 (!canonicalized_url.IsStandard() || canonicalized_url.SchemeIsFile() || |
| 98 canonicalized_url.SchemeIsFileSystem() || |
98 !canonicalized_url.host().empty())) | 99 !canonicalized_url.host().empty())) |
99 canonicalized_url_ = canonicalized_url; | 100 canonicalized_url_ = canonicalized_url; |
100 | 101 |
101 RemoveForcedQueryStringIfNecessary(type_, &text_); | 102 RemoveForcedQueryStringIfNecessary(type_, &text_); |
102 } | 103 } |
103 | 104 |
104 AutocompleteInput::~AutocompleteInput() { | 105 AutocompleteInput::~AutocompleteInput() { |
105 } | 106 } |
106 | 107 |
107 // static | 108 // static |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 UTF16ToUTF8(desired_tld)); | 160 UTF16ToUTF8(desired_tld)); |
160 } | 161 } |
161 | 162 |
162 if (LowerCaseEqualsASCII(parsed_scheme, chrome::kFileScheme)) { | 163 if (LowerCaseEqualsASCII(parsed_scheme, chrome::kFileScheme)) { |
163 // A user might or might not type a scheme when entering a file URL. In | 164 // A user might or might not type a scheme when entering a file URL. In |
164 // either case, |parsed_scheme| will tell us that this is a file URL, but | 165 // either case, |parsed_scheme| will tell us that this is a file URL, but |
165 // |parts->scheme| might be empty, e.g. if the user typed "C:\foo". | 166 // |parts->scheme| might be empty, e.g. if the user typed "C:\foo". |
166 return URL; | 167 return URL; |
167 } | 168 } |
168 | 169 |
| 170 if (LowerCaseEqualsASCII(parsed_scheme, chrome::kFileSystemScheme)) { |
| 171 // This could theoretically be a strange search, but let's check. |
| 172 // If it's got an inner_url with a scheme, it's a URL, whether it's valid or |
| 173 // not. |
| 174 if (parts->inner_parsed() && parts->inner_parsed()->scheme.is_valid()) |
| 175 return URL; |
| 176 } |
| 177 |
169 // If the user typed a scheme, and it's HTTP or HTTPS, we know how to parse it | 178 // If the user typed a scheme, and it's HTTP or HTTPS, we know how to parse it |
170 // well enough that we can fall through to the heuristics below. If it's | 179 // well enough that we can fall through to the heuristics below. If it's |
171 // something else, we can just determine our action based on what we do with | 180 // something else, we can just determine our action based on what we do with |
172 // any input of this scheme. In theory we could do better with some schemes | 181 // any input of this scheme. In theory we could do better with some schemes |
173 // (e.g. "ftp" or "view-source") but I'll wait to spend the effort on that | 182 // (e.g. "ftp" or "view-source") but I'll wait to spend the effort on that |
174 // until I run into some cases that really need it. | 183 // until I run into some cases that really need it. |
175 if (parts->scheme.is_nonempty() && | 184 if (parts->scheme.is_nonempty() && |
176 !LowerCaseEqualsASCII(parsed_scheme, chrome::kHttpScheme) && | 185 !LowerCaseEqualsASCII(parsed_scheme, chrome::kHttpScheme) && |
177 !LowerCaseEqualsASCII(parsed_scheme, chrome::kHttpsScheme)) { | 186 !LowerCaseEqualsASCII(parsed_scheme, chrome::kHttpsScheme)) { |
178 // See if we know how to handle the URL internally. | 187 // See if we know how to handle the URL internally. |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 scheme->reset(); | 457 scheme->reset(); |
449 } | 458 } |
450 if (real_parts.host.is_nonempty()) { | 459 if (real_parts.host.is_nonempty()) { |
451 *host = url_parse::Component( | 460 *host = url_parse::Component( |
452 after_scheme_and_colon + real_parts.host.begin, | 461 after_scheme_and_colon + real_parts.host.begin, |
453 real_parts.host.len); | 462 real_parts.host.len); |
454 } else { | 463 } else { |
455 host->reset(); | 464 host->reset(); |
456 } | 465 } |
457 } | 466 } |
| 467 } else if (LowerCaseEqualsASCII(scheme_str, chrome::kFileSystemScheme) && |
| 468 parts.inner_parsed() && parts.inner_parsed()->scheme.is_valid()) { |
| 469 *host = parts.inner_parsed()->host; |
458 } | 470 } |
459 } | 471 } |
460 | 472 |
461 // static | 473 // static |
462 string16 AutocompleteInput::FormattedStringWithEquivalentMeaning( | 474 string16 AutocompleteInput::FormattedStringWithEquivalentMeaning( |
463 const GURL& url, | 475 const GURL& url, |
464 const string16& formatted_url) { | 476 const string16& formatted_url) { |
465 if (!net::CanStripTrailingSlash(url)) | 477 if (!net::CanStripTrailingSlash(url)) |
466 return formatted_url; | 478 return formatted_url; |
467 const string16 url_with_path(formatted_url + char16('/')); | 479 const string16 url_with_path(formatted_url + char16('/')); |
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1124 const AutocompleteResult& result) | 1136 const AutocompleteResult& result) |
1125 : text(text), | 1137 : text(text), |
1126 input_type(input_type), | 1138 input_type(input_type), |
1127 selected_index(selected_index), | 1139 selected_index(selected_index), |
1128 tab_id(tab_id), | 1140 tab_id(tab_id), |
1129 elapsed_time_since_user_first_modified_omnibox( | 1141 elapsed_time_since_user_first_modified_omnibox( |
1130 elapsed_time_since_user_first_modified_omnibox), | 1142 elapsed_time_since_user_first_modified_omnibox), |
1131 inline_autocompleted_length(inline_autocompleted_length), | 1143 inline_autocompleted_length(inline_autocompleted_length), |
1132 result(result) { | 1144 result(result) { |
1133 } | 1145 } |
OLD | NEW |