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

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

Issue 2644903004: Move around more vector icons. (Closed)
Patch Set: fix comment Created 3 years, 11 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 "ui/gfx/vector_icons_public.h" 23 #include "ui/gfx/vector_icon_types.h"
24
25 #if !defined(OS_ANDROID) && !defined(OS_IOS)
26 #include "components/omnibox/browser/vector_icons.h" // nogncheck
27 #endif
24 28
25 namespace { 29 namespace {
26 30
27 bool IsTrivialClassification(const ACMatchClassifications& classifications) { 31 bool IsTrivialClassification(const ACMatchClassifications& classifications) {
28 return classifications.empty() || 32 return classifications.empty() ||
29 ((classifications.size() == 1) && 33 ((classifications.size() == 1) &&
30 (classifications.back().style == ACMatchClassification::NONE)); 34 (classifications.back().style == ACMatchClassification::NONE));
31 } 35 }
32 36
33 // Returns true if one of the |terms_prefixed_by_http_or_https| matches the 37 // Returns true if one of the |terms_prefixed_by_http_or_https| matches the
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 keyword = match.keyword; 163 keyword = match.keyword;
160 from_previous = match.from_previous; 164 from_previous = match.from_previous;
161 search_terms_args.reset(match.search_terms_args.get() ? 165 search_terms_args.reset(match.search_terms_args.get() ?
162 new TemplateURLRef::SearchTermsArgs(*match.search_terms_args) : NULL); 166 new TemplateURLRef::SearchTermsArgs(*match.search_terms_args) : NULL);
163 additional_info = match.additional_info; 167 additional_info = match.additional_info;
164 duplicate_matches = match.duplicate_matches; 168 duplicate_matches = match.duplicate_matches;
165 return *this; 169 return *this;
166 } 170 }
167 171
168 // static 172 // static
169 gfx::VectorIconId AutocompleteMatch::TypeToVectorIcon(Type type) { 173 const gfx::VectorIcon& AutocompleteMatch::TypeToVectorIcon(Type type) {
170 #if !defined(OS_ANDROID) && !defined(OS_IOS) 174 #if !defined(OS_ANDROID) && !defined(OS_IOS)
171 static const gfx::VectorIconId kIcons[] = { 175 switch (type) {
172 gfx::VectorIconId::OMNIBOX_HTTP, // URL_WHAT_YOU_TYPE 176 case Type::URL_WHAT_YOU_TYPED:
173 gfx::VectorIconId::OMNIBOX_HTTP, // HISTORY_URL 177 case Type::HISTORY_URL:
174 gfx::VectorIconId::OMNIBOX_HTTP, // HISTORY_TITLE 178 case Type::HISTORY_TITLE:
175 gfx::VectorIconId::OMNIBOX_HTTP, // HISTORY_BODY 179 case Type::HISTORY_BODY:
176 gfx::VectorIconId::OMNIBOX_HTTP, // HISTORY_KEYWORD 180 case Type::HISTORY_KEYWORD:
177 gfx::VectorIconId::OMNIBOX_HTTP, // NAVSUGGEST 181 case Type::NAVSUGGEST:
178 gfx::VectorIconId::OMNIBOX_SEARCH, // SEARCH_WHAT_YOU_TYPED 182 case Type::BOOKMARK_TITLE:
179 gfx::VectorIconId::OMNIBOX_SEARCH, // SEARCH_HISTORY 183 case Type::NAVSUGGEST_PERSONALIZED:
180 gfx::VectorIconId::OMNIBOX_SEARCH, // SEARCH_SUGGEST 184 case Type::CLIPBOARD:
181 gfx::VectorIconId::OMNIBOX_SEARCH, // SEARCH_SUGGEST_ENTITY 185 case Type::PHYSICAL_WEB:
182 gfx::VectorIconId::OMNIBOX_SEARCH, // SEARCH_SUGGEST_TAIL 186 case Type::PHYSICAL_WEB_OVERFLOW:
183 gfx::VectorIconId::OMNIBOX_SEARCH, // SEARCH_SUGGEST_PERSONALIZED 187 return omnibox::kHttpIcon;
184 gfx::VectorIconId::OMNIBOX_SEARCH, // SEARCH_SUGGEST_PROFILE 188
185 gfx::VectorIconId::OMNIBOX_SEARCH, // SEARCH_OTHER_ENGINE 189 case Type::SEARCH_WHAT_YOU_TYPED:
186 gfx::VectorIconId::OMNIBOX_EXTENSION_APP, // EXTENSION_APP 190 case Type::SEARCH_HISTORY:
187 gfx::VectorIconId::OMNIBOX_SEARCH, // CONTACT_DEPRECATED 191 case Type::SEARCH_SUGGEST:
188 gfx::VectorIconId::OMNIBOX_HTTP, // BOOKMARK_TITLE 192 case Type::SEARCH_SUGGEST_ENTITY:
189 gfx::VectorIconId::OMNIBOX_HTTP, // NAVSUGGEST_PERSONALIZED 193 case Type::SEARCH_SUGGEST_TAIL:
190 gfx::VectorIconId::OMNIBOX_CALCULATOR, // CALCULATOR 194 case Type::SEARCH_SUGGEST_PERSONALIZED:
191 gfx::VectorIconId::OMNIBOX_HTTP, // CLIPBOARD 195 case Type::SEARCH_SUGGEST_PROFILE:
192 gfx::VectorIconId::OMNIBOX_SEARCH, // VOICE_SEARCH 196 case Type::SEARCH_OTHER_ENGINE:
193 gfx::VectorIconId::OMNIBOX_HTTP, // PHYSICAL_WEB 197 case Type::CONTACT_DEPRECATED:
194 gfx::VectorIconId::OMNIBOX_HTTP, // PHYSICAL_WEB_OVERFLOW 198 case Type::VOICE_SUGGEST:
195 }; 199 return omnibox::kSearchIcon;
196 static_assert(arraysize(kIcons) == AutocompleteMatchType::NUM_TYPES, 200
197 "icons array must have NUM_TYPES elements"); 201 case Type::EXTENSION_APP:
198 return kIcons[type]; 202 return omnibox::kExtensionAppIcon;
203
204 case Type::CALCULATOR:
205 return omnibox::kCalculatorIcon;
206
207 case Type::NUM_TYPES:
208 NOTREACHED();
209 break;
210 }
211 NOTREACHED();
212 return omnibox::kHttpIcon;
199 #else 213 #else
200 NOTREACHED(); 214 NOTREACHED();
201 return gfx::VectorIconId::VECTOR_ICON_NONE; 215 static const gfx::VectorIcon dummy = {};
216 return dummy;
202 #endif 217 #endif
203 } 218 }
204 219
205 // static 220 // static
206 bool AutocompleteMatch::MoreRelevant(const AutocompleteMatch& elem1, 221 bool AutocompleteMatch::MoreRelevant(const AutocompleteMatch& elem1,
207 const AutocompleteMatch& elem2) { 222 const AutocompleteMatch& elem2) {
208 // For equal-relevance matches, we sort alphabetically, so that providers 223 // For equal-relevance matches, we sort alphabetically, so that providers
209 // who return multiple elements at the same priority get a "stable" sort 224 // who return multiple elements at the same priority get a "stable" sort
210 // across multiple updates. 225 // across multiple updates.
211 return (elem1.relevance == elem2.relevance) ? 226 return (elem1.relevance == elem2.relevance) ?
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 << " is unsorted in relation to last offset of " << last_offset 617 << " is unsorted in relation to last offset of " << last_offset
603 << ". Provider: " << provider_name << "."; 618 << ". Provider: " << provider_name << ".";
604 DCHECK_LT(i->offset, text.length()) 619 DCHECK_LT(i->offset, text.length())
605 << " Classification of [" << i->offset << "," << text.length() 620 << " Classification of [" << i->offset << "," << text.length()
606 << "] is out of bounds for \"" << text << "\". Provider: " 621 << "] is out of bounds for \"" << text << "\". Provider: "
607 << provider_name << "."; 622 << provider_name << ".";
608 last_offset = i->offset; 623 last_offset = i->offset;
609 } 624 }
610 } 625 }
611 #endif 626 #endif
OLDNEW
« no previous file with comments | « components/omnibox/browser/autocomplete_match.h ('k') | components/omnibox/browser/omnibox_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698