Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(465)

Side by Side Diff: components/omnibox/browser/autocomplete_match.cc

Issue 2365263006: Delete pre-MD code from OmniboxResultView (Closed)
Patch Set: update references to constant (merge resolution) Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/browser/autocomplete_match.h" 5 #include "components/omnibox/browser/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/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/string_piece.h" 12 #include "base/strings/string_piece.h"
13 #include "base/strings/string_split.h" 13 #include "base/strings/string_split.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "components/omnibox/browser/autocomplete_provider.h" 18 #include "components/omnibox/browser/autocomplete_provider.h"
19 #include "components/omnibox/browser/suggestion_answer.h" 19 #include "components/omnibox/browser/suggestion_answer.h"
20 #include "components/search_engines/template_url.h" 20 #include "components/search_engines/template_url.h"
21 #include "components/search_engines/template_url_service.h" 21 #include "components/search_engines/template_url_service.h"
22 #include "components/url_formatter/url_formatter.h" 22 #include "components/url_formatter/url_formatter.h"
23 #include "grit/components_scaled_resources.h"
24 #include "ui/gfx/vector_icons_public.h" 23 #include "ui/gfx/vector_icons_public.h"
25 24
26 namespace { 25 namespace {
27 26
28 bool IsTrivialClassification(const ACMatchClassifications& classifications) { 27 bool IsTrivialClassification(const ACMatchClassifications& classifications) {
29 return classifications.empty() || 28 return classifications.empty() ||
30 ((classifications.size() == 1) && 29 ((classifications.size() == 1) &&
31 (classifications.back().style == ACMatchClassification::NONE)); 30 (classifications.back().style == ACMatchClassification::NONE));
32 } 31 }
33 32
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 keyword = match.keyword; 159 keyword = match.keyword;
161 from_previous = match.from_previous; 160 from_previous = match.from_previous;
162 search_terms_args.reset(match.search_terms_args.get() ? 161 search_terms_args.reset(match.search_terms_args.get() ?
163 new TemplateURLRef::SearchTermsArgs(*match.search_terms_args) : NULL); 162 new TemplateURLRef::SearchTermsArgs(*match.search_terms_args) : NULL);
164 additional_info = match.additional_info; 163 additional_info = match.additional_info;
165 duplicate_matches = match.duplicate_matches; 164 duplicate_matches = match.duplicate_matches;
166 return *this; 165 return *this;
167 } 166 }
168 167
169 // static 168 // static
170 int AutocompleteMatch::TypeToIcon(Type type) {
171 #if !defined(OS_IOS)
172 static const int kIcons[] = {
173 IDR_OMNIBOX_HTTP, // URL_WHAT_YOU_TYPE
174 IDR_OMNIBOX_HTTP, // HISTORY_URL
175 IDR_OMNIBOX_HTTP, // HISTORY_TITLE
176 IDR_OMNIBOX_HTTP, // HISTORY_BODY
177 IDR_OMNIBOX_HTTP, // HISTORY_KEYWORD
178 IDR_OMNIBOX_HTTP, // NAVSUGGEST
179 IDR_OMNIBOX_SEARCH, // SEARCH_WHAT_YOU_TYPED
180 IDR_OMNIBOX_SEARCH, // SEARCH_HISTORY
181 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST
182 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_ENTITY
183 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_TAIL
184 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_PERSONALIZED
185 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_PROFILE
186 IDR_OMNIBOX_SEARCH, // SEARCH_OTHER_ENGINE
187 IDR_OMNIBOX_EXTENSION_APP, // EXTENSION_APP
188 IDR_OMNIBOX_SEARCH, // CONTACT_DEPRECATED
189 IDR_OMNIBOX_HTTP, // BOOKMARK_TITLE
190 IDR_OMNIBOX_HTTP, // NAVSUGGEST_PERSONALIZED
191 IDR_OMNIBOX_CALCULATOR, // CALCULATOR
192 IDR_OMNIBOX_HTTP, // CLIPBOARD
193 IDR_OMNIBOX_SEARCH, // VOICE_SEARCH
194 IDR_OMNIBOX_HTTP, // PHYSICAL_WEB
195 IDR_OMNIBOX_HTTP, // PHYSICAL_WEB_OVERFLOW
196 };
197 #else
198 static const int kIcons[] = {
199 IDR_OMNIBOX_HTTP, // URL_WHAT_YOU_TYPE
200 IDR_OMNIBOX_HISTORY, // HISTORY_URL
201 IDR_OMNIBOX_HISTORY, // HISTORY_TITLE
202 IDR_OMNIBOX_HISTORY, // HISTORY_BODY
203 IDR_OMNIBOX_HISTORY, // HISTORY_KEYWORD
204 IDR_OMNIBOX_HTTP, // NAVSUGGEST
205 IDR_OMNIBOX_SEARCH, // SEARCH_WHAT_YOU_TYPED
206 IDR_OMNIBOX_HISTORY, // SEARCH_HISTORY
207 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST
208 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_ENTITY
209 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_TAIL
210 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_PERSONALIZED
211 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_PROFILE
212 IDR_OMNIBOX_SEARCH, // SEARCH_OTHER_ENGINE
213 IDR_OMNIBOX_EXTENSION_APP, // EXTENSION_APP
214 IDR_OMNIBOX_SEARCH, // CONTACT_DEPRECATED
215 IDR_OMNIBOX_HTTP, // BOOKMARK_TITLE
216 IDR_OMNIBOX_HTTP, // NAVSUGGEST_PERSONALIZED
217 IDR_OMNIBOX_CALCULATOR, // CALCULATOR
218 IDR_OMNIBOX_HTTP, // CLIPBOARD
219 IDR_OMNIBOX_SEARCH, // VOICE_SEARCH
220 IDR_OMNIBOX_HTTP, // PHYSICAL_WEB
221 IDR_OMNIBOX_HTTP, // PHYSICAL_WEB_OVERFLOW
222 };
223 #endif
224 static_assert(arraysize(kIcons) == AutocompleteMatchType::NUM_TYPES,
225 "icons array must have NUM_TYPES elements");
226 return kIcons[type];
227 }
228
229 // static
230 gfx::VectorIconId AutocompleteMatch::TypeToVectorIcon(Type type) { 169 gfx::VectorIconId AutocompleteMatch::TypeToVectorIcon(Type type) {
231 #if !defined(OS_ANDROID) && !defined(OS_IOS) 170 #if !defined(OS_ANDROID) && !defined(OS_IOS)
232 static const gfx::VectorIconId kIcons[] = { 171 static const gfx::VectorIconId kIcons[] = {
233 gfx::VectorIconId::OMNIBOX_HTTP, // URL_WHAT_YOU_TYPE 172 gfx::VectorIconId::OMNIBOX_HTTP, // URL_WHAT_YOU_TYPE
234 gfx::VectorIconId::OMNIBOX_HTTP, // HISTORY_URL 173 gfx::VectorIconId::OMNIBOX_HTTP, // HISTORY_URL
235 gfx::VectorIconId::OMNIBOX_HTTP, // HISTORY_TITLE 174 gfx::VectorIconId::OMNIBOX_HTTP, // HISTORY_TITLE
236 gfx::VectorIconId::OMNIBOX_HTTP, // HISTORY_BODY 175 gfx::VectorIconId::OMNIBOX_HTTP, // HISTORY_BODY
237 gfx::VectorIconId::OMNIBOX_HTTP, // HISTORY_KEYWORD 176 gfx::VectorIconId::OMNIBOX_HTTP, // HISTORY_KEYWORD
238 gfx::VectorIconId::OMNIBOX_HTTP, // NAVSUGGEST 177 gfx::VectorIconId::OMNIBOX_HTTP, // NAVSUGGEST
239 gfx::VectorIconId::OMNIBOX_SEARCH, // SEARCH_WHAT_YOU_TYPED 178 gfx::VectorIconId::OMNIBOX_SEARCH, // SEARCH_WHAT_YOU_TYPED
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 << " is unsorted in relation to last offset of " << last_offset 602 << " is unsorted in relation to last offset of " << last_offset
664 << ". Provider: " << provider_name << "."; 603 << ". Provider: " << provider_name << ".";
665 DCHECK_LT(i->offset, text.length()) 604 DCHECK_LT(i->offset, text.length())
666 << " Classification of [" << i->offset << "," << text.length() 605 << " Classification of [" << i->offset << "," << text.length()
667 << "] is out of bounds for \"" << text << "\". Provider: " 606 << "] is out of bounds for \"" << text << "\". Provider: "
668 << provider_name << "."; 607 << provider_name << ".";
669 last_offset = i->offset; 608 last_offset = i->offset;
670 } 609 }
671 } 610 }
672 #endif 611 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698