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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 IDR_OMNIBOX_HTTP, | 156 IDR_OMNIBOX_HTTP, |
157 IDR_OMNIBOX_HTTP, | 157 IDR_OMNIBOX_HTTP, |
158 IDR_OMNIBOX_SEARCH, | 158 IDR_OMNIBOX_SEARCH, |
159 }; | 159 }; |
160 COMPILE_ASSERT(arraysize(icons) == AutocompleteMatchType::NUM_TYPES, | 160 COMPILE_ASSERT(arraysize(icons) == AutocompleteMatchType::NUM_TYPES, |
161 icons_array_must_match_type_enum); | 161 icons_array_must_match_type_enum); |
162 return icons[type]; | 162 return icons[type]; |
163 } | 163 } |
164 | 164 |
165 // static | 165 // static |
166 int AutocompleteMatch::TypeToLocationBarIcon(Type type) { | |
167 int id = TypeToIcon(type); | |
168 if (id == IDR_OMNIBOX_HTTP) | |
169 return IDR_LOCATION_BAR_HTTP; | |
170 return id; | |
171 } | |
172 | |
173 // static | |
174 bool AutocompleteMatch::MoreRelevant(const AutocompleteMatch& elem1, | 166 bool AutocompleteMatch::MoreRelevant(const AutocompleteMatch& elem1, |
175 const AutocompleteMatch& elem2) { | 167 const AutocompleteMatch& elem2) { |
176 // For equal-relevance matches, we sort alphabetically, so that providers | 168 // For equal-relevance matches, we sort alphabetically, so that providers |
177 // who return multiple elements at the same priority get a "stable" sort | 169 // who return multiple elements at the same priority get a "stable" sort |
178 // across multiple updates. | 170 // across multiple updates. |
179 return (elem1.relevance == elem2.relevance) ? | 171 return (elem1.relevance == elem2.relevance) ? |
180 (elem1.contents < elem2.contents) : (elem1.relevance > elem2.relevance); | 172 (elem1.contents < elem2.contents) : (elem1.relevance > elem2.relevance); |
181 } | 173 } |
182 | 174 |
183 // static | 175 // static |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 << " is unsorted in relation to last offset of " << last_offset | 538 << " is unsorted in relation to last offset of " << last_offset |
547 << ". Provider: " << provider_name << "."; | 539 << ". Provider: " << provider_name << "."; |
548 DCHECK_LT(i->offset, text.length()) | 540 DCHECK_LT(i->offset, text.length()) |
549 << " Classification of [" << i->offset << "," << text.length() | 541 << " Classification of [" << i->offset << "," << text.length() |
550 << "] is out of bounds for \"" << text << "\". Provider: " | 542 << "] is out of bounds for \"" << text << "\". Provider: " |
551 << provider_name << "."; | 543 << provider_name << "."; |
552 last_offset = i->offset; | 544 last_offset = i->offset; |
553 } | 545 } |
554 } | 546 } |
555 #endif | 547 #endif |
OLD | NEW |