| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 // distinguish this case from: | 229 // distinguish this case from: |
| 230 // * A "URL-like" string that's not really a URL (like | 230 // * A "URL-like" string that's not really a URL (like |
| 231 // "browser.tabs.closeButtons" or "java.awt.event.*"). This is ideally a | 231 // "browser.tabs.closeButtons" or "java.awt.event.*"). This is ideally a |
| 232 // QUERY. Since the above case and this one are indistinguishable, and this | 232 // QUERY. Since the above case and this one are indistinguishable, and this |
| 233 // case is likely to be much more common, just say these are both UNKNOWN, | 233 // case is likely to be much more common, just say these are both UNKNOWN, |
| 234 // which should default to the right thing and let users correct us on a | 234 // which should default to the right thing and let users correct us on a |
| 235 // case-by-case basis. | 235 // case-by-case basis. |
| 236 return desired_tld.empty() ? UNKNOWN : REQUESTED_URL; | 236 return desired_tld.empty() ? UNKNOWN : REQUESTED_URL; |
| 237 } | 237 } |
| 238 | 238 |
| 239 // static |
| 240 void AutocompleteInput::ParseForEmphasizeComponents( |
| 241 const std::wstring& text, |
| 242 const std::wstring& desired_tld, |
| 243 url_parse::Component* scheme, |
| 244 url_parse::Component* host) { |
| 245 url_parse::Parsed parts; |
| 246 std::wstring scheme_str; |
| 247 Parse(text, desired_tld, &parts, &scheme_str); |
| 248 |
| 249 *scheme = parts.scheme; |
| 250 *host = parts.host; |
| 251 |
| 252 int after_scheme_and_colon = parts.scheme.end() + 1; |
| 253 // For the view-source scheme, we should emphasize the scheme and host of |
| 254 // the URL qualified by the view-source prefix. |
| 255 if (LowerCaseEqualsASCII(scheme_str, chrome::kViewSourceScheme) && |
| 256 (static_cast<int>(text.length()) > after_scheme_and_colon)) { |
| 257 // Obtain the URL prefixed by view-source and parse it. |
| 258 std::wstring real_url(text.substr(after_scheme_and_colon)); |
| 259 url_parse::Parsed real_parts; |
| 260 AutocompleteInput::Parse(real_url, desired_tld, &real_parts, NULL); |
| 261 if (real_parts.scheme.is_nonempty() || real_parts.host.is_nonempty()) { |
| 262 if (real_parts.scheme.is_nonempty()) { |
| 263 *scheme = url_parse::Component( |
| 264 after_scheme_and_colon + real_parts.scheme.begin, |
| 265 real_parts.scheme.len); |
| 266 } else { |
| 267 scheme->reset(); |
| 268 } |
| 269 if (real_parts.host.is_nonempty()) { |
| 270 *host = url_parse::Component( |
| 271 after_scheme_and_colon + real_parts.host.begin, |
| 272 real_parts.host.len); |
| 273 } else { |
| 274 host->reset(); |
| 275 } |
| 276 } |
| 277 } |
| 278 } |
| 279 |
| 239 bool AutocompleteInput::Equals(const AutocompleteInput& other) const { | 280 bool AutocompleteInput::Equals(const AutocompleteInput& other) const { |
| 240 return (text_ == other.text_) && | 281 return (text_ == other.text_) && |
| 241 (type_ == other.type_) && | 282 (type_ == other.type_) && |
| 242 (desired_tld_ == other.desired_tld_) && | 283 (desired_tld_ == other.desired_tld_) && |
| 243 (scheme_ == other.scheme_) && | 284 (scheme_ == other.scheme_) && |
| 244 (prevent_inline_autocomplete_ == other.prevent_inline_autocomplete_) && | 285 (prevent_inline_autocomplete_ == other.prevent_inline_autocomplete_) && |
| 245 (prefer_keyword_ == other.prefer_keyword_) && | 286 (prefer_keyword_ == other.prefer_keyword_) && |
| 246 (synchronous_only_ == other.synchronous_only_); | 287 (synchronous_only_ == other.synchronous_only_); |
| 247 } | 288 } |
| 248 | 289 |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 match.contents_class.push_back( | 866 match.contents_class.push_back( |
| 826 ACMatchClassification(keyword_offset + input_.text().size(), | 867 ACMatchClassification(keyword_offset + input_.text().size(), |
| 827 ACMatchClassification::NONE)); | 868 ACMatchClassification::NONE)); |
| 828 } | 869 } |
| 829 match.destination_url = | 870 match.destination_url = |
| 830 HistoryUI::GetHistoryURLWithSearchText(input_.text()); | 871 HistoryUI::GetHistoryURLWithSearchText(input_.text()); |
| 831 match.transition = PageTransition::AUTO_BOOKMARK; | 872 match.transition = PageTransition::AUTO_BOOKMARK; |
| 832 match.provider = history_contents_provider_; | 873 match.provider = history_contents_provider_; |
| 833 latest_result_.AddMatch(match); | 874 latest_result_.AddMatch(match); |
| 834 } | 875 } |
| OLD | NEW |