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/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 // ContactProvider isn't used by the omnibox, so this icon is never | 167 // ContactProvider isn't used by the omnibox, so this icon is never |
168 // displayed. | 168 // displayed. |
169 IDR_OMNIBOX_SEARCH, | 169 IDR_OMNIBOX_SEARCH, |
170 }; | 170 }; |
171 COMPILE_ASSERT(arraysize(icons) == NUM_TYPES, | 171 COMPILE_ASSERT(arraysize(icons) == NUM_TYPES, |
172 icons_array_must_match_type_enum); | 172 icons_array_must_match_type_enum); |
173 return icons[type]; | 173 return icons[type]; |
174 } | 174 } |
175 | 175 |
176 // static | 176 // static |
| 177 int AutocompleteMatch::TypeToLocationBarIcon(Type type) { |
| 178 int id = TypeToIcon(type); |
| 179 if (id == IDR_OMNIBOX_HTTP) |
| 180 return IDR_LOCATION_BAR_HTTP; |
| 181 return id; |
| 182 } |
| 183 |
| 184 // static |
177 bool AutocompleteMatch::MoreRelevant(const AutocompleteMatch& elem1, | 185 bool AutocompleteMatch::MoreRelevant(const AutocompleteMatch& elem1, |
178 const AutocompleteMatch& elem2) { | 186 const AutocompleteMatch& elem2) { |
179 // For equal-relevance matches, we sort alphabetically, so that providers | 187 // For equal-relevance matches, we sort alphabetically, so that providers |
180 // who return multiple elements at the same priority get a "stable" sort | 188 // who return multiple elements at the same priority get a "stable" sort |
181 // across multiple updates. | 189 // across multiple updates. |
182 return (elem1.relevance == elem2.relevance) ? | 190 return (elem1.relevance == elem2.relevance) ? |
183 (elem1.contents < elem2.contents) : (elem1.relevance > elem2.relevance); | 191 (elem1.contents < elem2.contents) : (elem1.relevance > elem2.relevance); |
184 } | 192 } |
185 | 193 |
186 // static | 194 // static |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 << " is unsorted in relation to last offset of " << last_offset | 462 << " is unsorted in relation to last offset of " << last_offset |
455 << ". Provider: " << provider_name << "."; | 463 << ". Provider: " << provider_name << "."; |
456 DCHECK_LT(i->offset, text.length()) | 464 DCHECK_LT(i->offset, text.length()) |
457 << " Classification of [" << i->offset << "," << text.length() | 465 << " Classification of [" << i->offset << "," << text.length() |
458 << "] is out of bounds for \"" << text << "\". Provider: " | 466 << "] is out of bounds for \"" << text << "\". Provider: " |
459 << provider_name << "."; | 467 << provider_name << "."; |
460 last_offset = i->offset; | 468 last_offset = i->offset; |
461 } | 469 } |
462 } | 470 } |
463 #endif | 471 #endif |
OLD | NEW |