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

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

Issue 847833002: Upstream iOS specific design for omnibox (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove common/ subdirectory Created 5 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
« no previous file with comments | « no previous file | components/resources/autofill_scaled_resources.grdp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 from_previous = match.from_previous; 128 from_previous = match.from_previous;
129 search_terms_args.reset(match.search_terms_args.get() ? 129 search_terms_args.reset(match.search_terms_args.get() ?
130 new TemplateURLRef::SearchTermsArgs(*match.search_terms_args) : NULL); 130 new TemplateURLRef::SearchTermsArgs(*match.search_terms_args) : NULL);
131 additional_info = match.additional_info; 131 additional_info = match.additional_info;
132 duplicate_matches = match.duplicate_matches; 132 duplicate_matches = match.duplicate_matches;
133 return *this; 133 return *this;
134 } 134 }
135 135
136 // static 136 // static
137 int AutocompleteMatch::TypeToIcon(Type type) { 137 int AutocompleteMatch::TypeToIcon(Type type) {
138 int icons[] = { 138 #if !defined(OS_IOS)
139 IDR_OMNIBOX_HTTP, 139 static const int kIcons[] = {
140 IDR_OMNIBOX_HTTP, 140 IDR_OMNIBOX_HTTP, // URL_WHAT_YOU_TYPE
141 IDR_OMNIBOX_HTTP, 141 IDR_OMNIBOX_HTTP, // HISTORY_URL
142 IDR_OMNIBOX_HTTP, 142 IDR_OMNIBOX_HTTP, // HISTORY_TITLE
143 IDR_OMNIBOX_HTTP, 143 IDR_OMNIBOX_HTTP, // HISTORY_BODY
144 IDR_OMNIBOX_HTTP, 144 IDR_OMNIBOX_HTTP, // HISTORY_KEYWORD
145 IDR_OMNIBOX_SEARCH, 145 IDR_OMNIBOX_HTTP, // NAVSUGGEST
146 IDR_OMNIBOX_SEARCH, 146 IDR_OMNIBOX_SEARCH, // SEARCH_WHAT_YOU_TYPED
147 IDR_OMNIBOX_SEARCH, 147 IDR_OMNIBOX_SEARCH, // SEARCH_HISTORY
148 IDR_OMNIBOX_SEARCH, 148 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST
149 IDR_OMNIBOX_SEARCH, 149 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_ENTITY
150 IDR_OMNIBOX_SEARCH, 150 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_INFINITE
151 IDR_OMNIBOX_SEARCH, 151 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_PERSONALIZED
152 IDR_OMNIBOX_SEARCH, 152 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_PROFILE
153 IDR_OMNIBOX_EXTENSION_APP, 153 IDR_OMNIBOX_SEARCH, // SEARCH_OTHER_ENGINE
154 IDR_OMNIBOX_SEARCH, 154 IDR_OMNIBOX_EXTENSION_APP, // EXTENSION_APP
155 IDR_OMNIBOX_HTTP, 155 IDR_OMNIBOX_SEARCH, // CONTACT_DEPRECATED
156 IDR_OMNIBOX_HTTP, 156 IDR_OMNIBOX_HTTP, // BOOKMARK_TITLE
157 IDR_OMNIBOX_SEARCH, 157 IDR_OMNIBOX_HTTP, // NAVSUGGEST_PERSONALIZED
158 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_ANSWER
158 }; 159 };
159 static_assert(arraysize(icons) == AutocompleteMatchType::NUM_TYPES, 160 #else
161 static const int kIcons[] = {
162 IDR_OMNIBOX_HTTP, // URL_WHAT_YOU_TYPE
163 IDR_OMNIBOX_HISTORY, // HISTORY_URL
164 IDR_OMNIBOX_HISTORY, // HISTORY_TITLE
165 IDR_OMNIBOX_HISTORY, // HISTORY_BODY
166 IDR_OMNIBOX_HISTORY, // HISTORY_KEYWORD
167 IDR_OMNIBOX_HTTP, // NAVSUGGEST
168 IDR_OMNIBOX_SEARCH, // SEARCH_WHAT_YOU_TYPED
169 IDR_OMNIBOX_HISTORY, // SEARCH_HISTORY
170 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST
171 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_ENTITY
172 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_INFINITE
173 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_PERSONALIZED
174 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_PROFILE
175 IDR_OMNIBOX_SEARCH, // SEARCH_OTHER_ENGINE
176 IDR_OMNIBOX_EXTENSION_APP, // EXTENSION_APP
177 IDR_OMNIBOX_SEARCH, // CONTACT_DEPRECATED
178 IDR_OMNIBOX_HTTP, // BOOKMARK_TITLE
179 IDR_OMNIBOX_HTTP, // NAVSUGGEST_PERSONALIZED
180 IDR_OMNIBOX_SEARCH, // SEARCH_SUGGEST_ANSWER
181 };
182 #endif
183 static_assert(arraysize(kIcons) == AutocompleteMatchType::NUM_TYPES,
160 "icons array must have NUM_TYPES elements"); 184 "icons array must have NUM_TYPES elements");
161 return icons[type]; 185 return kIcons[type];
162 } 186 }
163 187
164 // static 188 // static
165 bool AutocompleteMatch::MoreRelevant(const AutocompleteMatch& elem1, 189 bool AutocompleteMatch::MoreRelevant(const AutocompleteMatch& elem1,
166 const AutocompleteMatch& elem2) { 190 const AutocompleteMatch& elem2) {
167 // For equal-relevance matches, we sort alphabetically, so that providers 191 // For equal-relevance matches, we sort alphabetically, so that providers
168 // who return multiple elements at the same priority get a "stable" sort 192 // who return multiple elements at the same priority get a "stable" sort
169 // across multiple updates. 193 // across multiple updates.
170 return (elem1.relevance == elem2.relevance) ? 194 return (elem1.relevance == elem2.relevance) ?
171 (elem1.contents < elem2.contents) : (elem1.relevance > elem2.relevance); 195 (elem1.contents < elem2.contents) : (elem1.relevance > elem2.relevance);
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 << " is unsorted in relation to last offset of " << last_offset 561 << " is unsorted in relation to last offset of " << last_offset
538 << ". Provider: " << provider_name << "."; 562 << ". Provider: " << provider_name << ".";
539 DCHECK_LT(i->offset, text.length()) 563 DCHECK_LT(i->offset, text.length())
540 << " Classification of [" << i->offset << "," << text.length() 564 << " Classification of [" << i->offset << "," << text.length()
541 << "] is out of bounds for \"" << text << "\". Provider: " 565 << "] is out of bounds for \"" << text << "\". Provider: "
542 << provider_name << "."; 566 << provider_name << ".";
543 last_offset = i->offset; 567 last_offset = i->offset;
544 } 568 }
545 } 569 }
546 #endif 570 #endif
OLDNEW
« no previous file with comments | « no previous file | components/resources/autofill_scaled_resources.grdp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698