Chromium Code Reviews| 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_match.h" | 5 #include "chrome/browser/autocomplete/autocomplete_match.h" |
| 6 | 6 |
| 7 #include "base/i18n/time_formatting.h" | 7 #include "base/i18n/time_formatting.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 IDR_OMNIBOX_SEARCH, | 150 IDR_OMNIBOX_SEARCH, |
| 151 IDR_OMNIBOX_SEARCH, | 151 IDR_OMNIBOX_SEARCH, |
| 152 IDR_OMNIBOX_SEARCH, | 152 IDR_OMNIBOX_SEARCH, |
| 153 IDR_OMNIBOX_SEARCH, | 153 IDR_OMNIBOX_SEARCH, |
| 154 IDR_OMNIBOX_SEARCH, | 154 IDR_OMNIBOX_SEARCH, |
| 155 IDR_OMNIBOX_SEARCH, | 155 IDR_OMNIBOX_SEARCH, |
| 156 IDR_OMNIBOX_EXTENSION_APP, | 156 IDR_OMNIBOX_EXTENSION_APP, |
| 157 IDR_OMNIBOX_SEARCH, | 157 IDR_OMNIBOX_SEARCH, |
| 158 IDR_OMNIBOX_HTTP, | 158 IDR_OMNIBOX_HTTP, |
| 159 IDR_OMNIBOX_HTTP, | 159 IDR_OMNIBOX_HTTP, |
| 160 IDR_OMNIBOX_SEARCH, | |
| 160 }; | 161 }; |
| 161 COMPILE_ASSERT(arraysize(icons) == AutocompleteMatchType::NUM_TYPES, | 162 COMPILE_ASSERT(arraysize(icons) == AutocompleteMatchType::NUM_TYPES, |
| 162 icons_array_must_match_type_enum); | 163 icons_array_must_match_type_enum); |
| 163 return icons[type]; | 164 return icons[type]; |
| 164 } | 165 } |
| 165 | 166 |
| 166 // static | 167 // static |
| 167 int AutocompleteMatch::TypeToLocationBarIcon(Type type) { | 168 int AutocompleteMatch::TypeToLocationBarIcon(Type type) { |
| 168 int id = TypeToIcon(type); | 169 int id = TypeToIcon(type); |
| 169 if (id == IDR_OMNIBOX_HTTP) | 170 if (id == IDR_OMNIBOX_HTTP) |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 332 type == AutocompleteMatchType::SEARCH_SUGGEST || | 333 type == AutocompleteMatchType::SEARCH_SUGGEST || |
| 333 type == AutocompleteMatchType::SEARCH_OTHER_ENGINE || | 334 type == AutocompleteMatchType::SEARCH_OTHER_ENGINE || |
| 334 IsSpecializedSearchType(type); | 335 IsSpecializedSearchType(type); |
| 335 } | 336 } |
| 336 | 337 |
| 337 // static | 338 // static |
| 338 bool AutocompleteMatch::IsSpecializedSearchType(Type type) { | 339 bool AutocompleteMatch::IsSpecializedSearchType(Type type) { |
| 339 return type == AutocompleteMatchType::SEARCH_SUGGEST_ENTITY || | 340 return type == AutocompleteMatchType::SEARCH_SUGGEST_ENTITY || |
| 340 type == AutocompleteMatchType::SEARCH_SUGGEST_INFINITE || | 341 type == AutocompleteMatchType::SEARCH_SUGGEST_INFINITE || |
| 341 type == AutocompleteMatchType::SEARCH_SUGGEST_PERSONALIZED || | 342 type == AutocompleteMatchType::SEARCH_SUGGEST_PERSONALIZED || |
| 342 type == AutocompleteMatchType::SEARCH_SUGGEST_PROFILE; | 343 type == AutocompleteMatchType::SEARCH_SUGGEST_PROFILE || |
| 344 type == AutocompleteMatchType::SEARCH_SUGGEST_ANSWER; | |
|
Peter Kasting
2014/06/10 21:49:46
The effect of putting this here will be that the S
Justin Donnelly
2014/06/11 15:51:53
Well, hitting enter on an Answer for "foo" will, i
Peter Kasting
2014/06/11 17:02:02
The alternative is that you get back a match exact
| |
| 343 } | 345 } |
| 344 | 346 |
| 345 void AutocompleteMatch::ComputeStrippedDestinationURL(Profile* profile) { | 347 void AutocompleteMatch::ComputeStrippedDestinationURL(Profile* profile) { |
| 346 stripped_destination_url = destination_url; | 348 stripped_destination_url = destination_url; |
| 347 if (!stripped_destination_url.is_valid()) | 349 if (!stripped_destination_url.is_valid()) |
| 348 return; | 350 return; |
| 349 | 351 |
| 350 // If the destination URL looks like it was generated from a TemplateURL, | 352 // If the destination URL looks like it was generated from a TemplateURL, |
| 351 // remove all substitutions other than the search terms. This allows us | 353 // remove all substitutions other than the search terms. This allows us |
| 352 // to eliminate cases like past search URLs from history that differ only | 354 // to eliminate cases like past search URLs from history that differ only |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 502 << " is unsorted in relation to last offset of " << last_offset | 504 << " is unsorted in relation to last offset of " << last_offset |
| 503 << ". Provider: " << provider_name << "."; | 505 << ". Provider: " << provider_name << "."; |
| 504 DCHECK_LT(i->offset, text.length()) | 506 DCHECK_LT(i->offset, text.length()) |
| 505 << " Classification of [" << i->offset << "," << text.length() | 507 << " Classification of [" << i->offset << "," << text.length() |
| 506 << "] is out of bounds for \"" << text << "\". Provider: " | 508 << "] is out of bounds for \"" << text << "\". Provider: " |
| 507 << provider_name << "."; | 509 << provider_name << "."; |
| 508 last_offset = i->offset; | 510 last_offset = i->offset; |
| 509 } | 511 } |
| 510 } | 512 } |
| 511 #endif | 513 #endif |
| OLD | NEW |