OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/omnibox/autocomplete_match.h" | 5 #include "components/omnibox/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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST | 148 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST |
149 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_ENTITY | 149 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_ENTITY |
150 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_INFINITE | 150 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_INFINITE |
151 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_PERSONALIZED | 151 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_PERSONALIZED |
152 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_PROFILE | 152 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_PROFILE |
153 IDR_OMNIBOX_SEARCH, // SEARCH_OTHER_ENGINE | 153 IDR_OMNIBOX_SEARCH, // SEARCH_OTHER_ENGINE |
154 IDR_OMNIBOX_EXTENSION_APP, // EXTENSION_APP | 154 IDR_OMNIBOX_EXTENSION_APP, // EXTENSION_APP |
155 IDR_OMNIBOX_SEARCH, // CONTACT_DEPRECATED | 155 IDR_OMNIBOX_SEARCH, // CONTACT_DEPRECATED |
156 IDR_OMNIBOX_HTTP, // BOOKMARK_TITLE | 156 IDR_OMNIBOX_HTTP, // BOOKMARK_TITLE |
157 IDR_OMNIBOX_HTTP, // NAVSUGGEST_PERSONALIZED | 157 IDR_OMNIBOX_HTTP, // NAVSUGGEST_PERSONALIZED |
158 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_ANSWER | |
159 }; | 158 }; |
160 #else | 159 #else |
161 static const int kIcons[] = { | 160 static const int kIcons[] = { |
162 IDR_OMNIBOX_HTTP, // URL_WHAT_YOU_TYPE | 161 IDR_OMNIBOX_HTTP, // URL_WHAT_YOU_TYPE |
163 IDR_OMNIBOX_HISTORY, // HISTORY_URL | 162 IDR_OMNIBOX_HISTORY, // HISTORY_URL |
164 IDR_OMNIBOX_HISTORY, // HISTORY_TITLE | 163 IDR_OMNIBOX_HISTORY, // HISTORY_TITLE |
165 IDR_OMNIBOX_HISTORY, // HISTORY_BODY | 164 IDR_OMNIBOX_HISTORY, // HISTORY_BODY |
166 IDR_OMNIBOX_HISTORY, // HISTORY_KEYWORD | 165 IDR_OMNIBOX_HISTORY, // HISTORY_KEYWORD |
167 IDR_OMNIBOX_HTTP, // NAVSUGGEST | 166 IDR_OMNIBOX_HTTP, // NAVSUGGEST |
168 IDR_OMNIBOX_SEARCH, // SEARCH_WHAT_YOU_TYPED | 167 IDR_OMNIBOX_SEARCH, // SEARCH_WHAT_YOU_TYPED |
169 IDR_OMNIBOX_HISTORY, // SEARCH_HISTORY | 168 IDR_OMNIBOX_HISTORY, // SEARCH_HISTORY |
170 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST | 169 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST |
171 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_ENTITY | 170 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_ENTITY |
172 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_INFINITE | 171 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_INFINITE |
173 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_PERSONALIZED | 172 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_PERSONALIZED |
174 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_PROFILE | 173 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_PROFILE |
175 IDR_OMNIBOX_SEARCH, // SEARCH_OTHER_ENGINE | 174 IDR_OMNIBOX_SEARCH, // SEARCH_OTHER_ENGINE |
176 IDR_OMNIBOX_EXTENSION_APP, // EXTENSION_APP | 175 IDR_OMNIBOX_EXTENSION_APP, // EXTENSION_APP |
177 IDR_OMNIBOX_SEARCH, // CONTACT_DEPRECATED | 176 IDR_OMNIBOX_SEARCH, // CONTACT_DEPRECATED |
178 IDR_OMNIBOX_HTTP, // BOOKMARK_TITLE | 177 IDR_OMNIBOX_HTTP, // BOOKMARK_TITLE |
179 IDR_OMNIBOX_HTTP, // NAVSUGGEST_PERSONALIZED | 178 IDR_OMNIBOX_HTTP, // NAVSUGGEST_PERSONALIZED |
180 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_ANSWER | |
181 }; | 179 }; |
182 #endif | 180 #endif |
183 static_assert(arraysize(kIcons) == AutocompleteMatchType::NUM_TYPES, | 181 static_assert(arraysize(kIcons) == AutocompleteMatchType::NUM_TYPES, |
184 "icons array must have NUM_TYPES elements"); | 182 "icons array must have NUM_TYPES elements"); |
185 return kIcons[type]; | 183 return kIcons[type]; |
186 } | 184 } |
187 | 185 |
188 // static | 186 // static |
189 bool AutocompleteMatch::MoreRelevant(const AutocompleteMatch& elem1, | 187 bool AutocompleteMatch::MoreRelevant(const AutocompleteMatch& elem1, |
190 const AutocompleteMatch& elem2) { | 188 const AutocompleteMatch& elem2) { |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 type == AutocompleteMatchType::SEARCH_SUGGEST || | 344 type == AutocompleteMatchType::SEARCH_SUGGEST || |
347 type == AutocompleteMatchType::SEARCH_OTHER_ENGINE || | 345 type == AutocompleteMatchType::SEARCH_OTHER_ENGINE || |
348 IsSpecializedSearchType(type); | 346 IsSpecializedSearchType(type); |
349 } | 347 } |
350 | 348 |
351 // static | 349 // static |
352 bool AutocompleteMatch::IsSpecializedSearchType(Type type) { | 350 bool AutocompleteMatch::IsSpecializedSearchType(Type type) { |
353 return type == AutocompleteMatchType::SEARCH_SUGGEST_ENTITY || | 351 return type == AutocompleteMatchType::SEARCH_SUGGEST_ENTITY || |
354 type == AutocompleteMatchType::SEARCH_SUGGEST_INFINITE || | 352 type == AutocompleteMatchType::SEARCH_SUGGEST_INFINITE || |
355 type == AutocompleteMatchType::SEARCH_SUGGEST_PERSONALIZED || | 353 type == AutocompleteMatchType::SEARCH_SUGGEST_PERSONALIZED || |
356 type == AutocompleteMatchType::SEARCH_SUGGEST_PROFILE || | 354 type == AutocompleteMatchType::SEARCH_SUGGEST_PROFILE; |
357 type == AutocompleteMatchType::SEARCH_SUGGEST_ANSWER; | |
358 } | 355 } |
359 | 356 |
360 // static | 357 // static |
361 TemplateURL* AutocompleteMatch::GetTemplateURLWithKeyword( | 358 TemplateURL* AutocompleteMatch::GetTemplateURLWithKeyword( |
362 TemplateURLService* template_url_service, | 359 TemplateURLService* template_url_service, |
363 const base::string16& keyword, | 360 const base::string16& keyword, |
364 const std::string& host) { | 361 const std::string& host) { |
365 if (template_url_service == NULL) | 362 if (template_url_service == NULL) |
366 return NULL; | 363 return NULL; |
367 TemplateURL* template_url = keyword.empty() ? | 364 TemplateURL* template_url = keyword.empty() ? |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 << " is unsorted in relation to last offset of " << last_offset | 558 << " is unsorted in relation to last offset of " << last_offset |
562 << ". Provider: " << provider_name << "."; | 559 << ". Provider: " << provider_name << "."; |
563 DCHECK_LT(i->offset, text.length()) | 560 DCHECK_LT(i->offset, text.length()) |
564 << " Classification of [" << i->offset << "," << text.length() | 561 << " Classification of [" << i->offset << "," << text.length() |
565 << "] is out of bounds for \"" << text << "\". Provider: " | 562 << "] is out of bounds for \"" << text << "\". Provider: " |
566 << provider_name << "."; | 563 << provider_name << "."; |
567 last_offset = i->offset; | 564 last_offset = i->offset; |
568 } | 565 } |
569 } | 566 } |
570 #endif | 567 #endif |
OLD | NEW |