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

Side by Side Diff: chrome/browser/autocomplete/search_provider.cc

Issue 23164011: Omnibox: Reduce Bolding Flicker in SearchProvider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Mike's comments Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/search_provider.h" 5 #include "chrome/browser/autocomplete/search_provider.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 if (i.IsWord()) { 95 if (i.IsWord()) {
96 if (found_word) 96 if (found_word)
97 return true; 97 return true;
98 found_word = true; 98 found_word = true;
99 } 99 }
100 } 100 }
101 } 101 }
102 return false; 102 return false;
103 } 103 }
104 104
105 // Builds the match contents and classification for the contents, and updates
106 // the given |AutocompleteMatch|.
107 void SetAndClassifyMatchContents(const base::string16& query_string,
108 const base::string16& input_text,
109 const base::string16& match_contents,
110 AutocompleteMatch* match) {
111 match->contents = match_contents.empty() ? query_string : match_contents;
112
113 // We do intra-string highlighting for suggestions - the suggested segment
114 // will be highlighted, e.g. for input_text = "you" the suggestion may be
115 // "youtube", so we'll bold the "tube" section: you*tube*.
116 if (input_text != match_contents) {
117 size_t input_position = match->contents.find(input_text);
118 if (input_position == base::string16::npos) {
119 // The input text is not a substring of the query string, e.g. input
120 // text is "slasdot" and the query string is "slashdot", so we bold the
121 // whole thing.
122 match->contents_class.push_back(ACMatchClassification(
123 0, ACMatchClassification::MATCH));
124 } else {
125 // TODO(beng): ACMatchClassification::MATCH now seems to just mean
126 // "bold" this. Consider modifying the terminology.
127 // We don't iterate over the string here annotating all matches because
128 // it looks odd to have every occurrence of a substring that may be as
129 // short as a single character highlighted in a query suggestion result,
130 // e.g. for input text "s" and query string "southwest airlines", it
131 // looks odd if both the first and last s are highlighted.
132 if (input_position != 0) {
133 match->contents_class.push_back(ACMatchClassification(
134 0, ACMatchClassification::MATCH));
135 }
136 match->contents_class.push_back(
137 ACMatchClassification(input_position, ACMatchClassification::NONE));
138 size_t next_fragment_position = input_position + input_text.length();
139 if (next_fragment_position < query_string.length()) {
140 match->contents_class.push_back(ACMatchClassification(
141 next_fragment_position, ACMatchClassification::MATCH));
142 }
143 }
144 } else {
145 // Otherwise, |match| is a verbatim (what-you-typed) match, either for the
146 // default provider or a keyword search provider.
147 match->contents_class.push_back(ACMatchClassification(
148 0, ACMatchClassification::NONE));
149 }
150 }
151
152 AutocompleteMatchType::Type GetAutocompleteMatchType(const std::string& type) { 105 AutocompleteMatchType::Type GetAutocompleteMatchType(const std::string& type) {
153 if (type == "ENTITY") 106 if (type == "ENTITY")
154 return AutocompleteMatchType::SEARCH_SUGGEST_ENTITY; 107 return AutocompleteMatchType::SEARCH_SUGGEST_ENTITY;
155 if (type == "INFINITE") 108 if (type == "INFINITE")
156 return AutocompleteMatchType::SEARCH_SUGGEST_INFINITE; 109 return AutocompleteMatchType::SEARCH_SUGGEST_INFINITE;
157 if (type == "PERSONALIZED") 110 if (type == "PERSONALIZED")
158 return AutocompleteMatchType::SEARCH_SUGGEST_PERSONALIZED; 111 return AutocompleteMatchType::SEARCH_SUGGEST_PERSONALIZED;
159 if (type == "PROFILE") 112 if (type == "PROFILE")
160 return AutocompleteMatchType::SEARCH_SUGGEST_PROFILE; 113 return AutocompleteMatchType::SEARCH_SUGGEST_PROFILE;
161 return AutocompleteMatchType::SEARCH_SUGGEST; 114 return AutocompleteMatchType::SEARCH_SUGGEST;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 SearchProvider::SuggestResult::SuggestResult( 208 SearchProvider::SuggestResult::SuggestResult(
256 const base::string16& suggestion, 209 const base::string16& suggestion,
257 AutocompleteMatchType::Type type, 210 AutocompleteMatchType::Type type,
258 const base::string16& match_contents, 211 const base::string16& match_contents,
259 const base::string16& annotation, 212 const base::string16& annotation,
260 const std::string& suggest_query_params, 213 const std::string& suggest_query_params,
261 const std::string& deletion_url, 214 const std::string& deletion_url,
262 bool from_keyword_provider, 215 bool from_keyword_provider,
263 int relevance, 216 int relevance,
264 bool relevance_from_server, 217 bool relevance_from_server,
265 bool should_prefetch) 218 bool should_prefetch,
219 const base::string16& input_text)
266 : Result(from_keyword_provider, relevance, relevance_from_server), 220 : Result(from_keyword_provider, relevance, relevance_from_server),
267 suggestion_(suggestion), 221 suggestion_(suggestion),
268 type_(type), 222 type_(type),
269 match_contents_(match_contents), 223 match_contents_(match_contents),
270 annotation_(annotation), 224 annotation_(annotation),
271 suggest_query_params_(suggest_query_params), 225 suggest_query_params_(suggest_query_params),
272 deletion_url_(deletion_url), 226 deletion_url_(deletion_url),
273 should_prefetch_(should_prefetch) { 227 should_prefetch_(should_prefetch) {
228 DCHECK(!match_contents_.empty());
229 CalculateContentsClass(true, input_text);
274 } 230 }
275 231
276 SearchProvider::SuggestResult::~SuggestResult() { 232 SearchProvider::SuggestResult::~SuggestResult() {
277 } 233 }
278 234
235 void SearchProvider::SuggestResult::CalculateContentsClass(
236 const bool allow_bolding_all,
237 const base::string16& input_text) {
238 size_t input_position = match_contents_.find(input_text);
239 if (!allow_bolding_all && (input_position == base::string16::npos)) {
240 // Bail if the code below to update the bolding would bold the whole
241 // string. Note that the string may already be entirely bolded; if
242 // so, leave it as is.
243 return;
244 }
245 match_contents_class_.clear();
246 // We do intra-string highlighting for suggestions - the suggested segment
247 // will be highlighted, e.g. for input_text = "you" the suggestion may be
248 // "youtube", so we'll bold the "tube" section: you*tube*.
249 if (input_text != match_contents_) {
250 if (input_position == base::string16::npos) {
251 // The input text is not a substring of the query string, e.g. input
252 // text is "slasdot" and the query string is "slashdot", so we bold the
253 // whole thing.
254 match_contents_class_.push_back(ACMatchClassification(
255 0, ACMatchClassification::MATCH));
256 } else {
257 // TODO(beng): ACMatchClassification::MATCH now seems to just mean
258 // "bold" this. Consider modifying the terminology.
Anuj 2014/01/06 23:23:38 I think we can remove this TODO. Although it seems
Mark P 2014/01/07 19:10:31 I agree we can remove it. Removed.
259 // We don't iterate over the string here annotating all matches because
260 // it looks odd to have every occurrence of a substring that may be as
261 // short as a single character highlighted in a query suggestion result,
262 // e.g. for input text "s" and query string "southwest airlines", it
263 // looks odd if both the first and last s are highlighted.
264 if (input_position != 0) {
265 match_contents_class_.push_back(ACMatchClassification(
266 0, ACMatchClassification::MATCH));
267 }
268 match_contents_class_.push_back(
269 ACMatchClassification(input_position, ACMatchClassification::NONE));
270 size_t next_fragment_position = input_position + input_text.length();
271 if (next_fragment_position < match_contents_.length()) {
272 match_contents_class_.push_back(ACMatchClassification(
273 next_fragment_position, ACMatchClassification::MATCH));
274 }
275 }
276 } else {
277 // Otherwise, match_contents_ is a verbatim (what-you-typed) match, either
278 // for the default provider or a keyword search provider.
279 match_contents_class_.push_back(ACMatchClassification(
280 0, ACMatchClassification::NONE));
281 }
282 }
283
279 bool SearchProvider::SuggestResult::IsInlineable( 284 bool SearchProvider::SuggestResult::IsInlineable(
280 const base::string16& input) const { 285 const base::string16& input) const {
281 return StartsWith(suggestion_, input, false); 286 return StartsWith(suggestion_, input, false);
282 } 287 }
283 288
284 int SearchProvider::SuggestResult::CalculateRelevance( 289 int SearchProvider::SuggestResult::CalculateRelevance(
285 const AutocompleteInput& input, 290 const AutocompleteInput& input,
286 bool keyword_provider_requested) const { 291 bool keyword_provider_requested) const {
287 if (!from_keyword_provider_ && keyword_provider_requested) 292 if (!from_keyword_provider_ && keyword_provider_requested)
288 return 100; 293 return 100;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 const TemplateURL* template_url, 408 const TemplateURL* template_url,
404 int accepted_suggestion, 409 int accepted_suggestion,
405 int omnibox_start_margin, 410 int omnibox_start_margin,
406 bool append_extra_query_params) { 411 bool append_extra_query_params) {
407 AutocompleteMatch match(autocomplete_provider, suggestion.relevance(), false, 412 AutocompleteMatch match(autocomplete_provider, suggestion.relevance(), false,
408 suggestion.type()); 413 suggestion.type());
409 414
410 if (!template_url) 415 if (!template_url)
411 return match; 416 return match;
412 match.keyword = template_url->keyword(); 417 match.keyword = template_url->keyword();
413 418 match.contents = suggestion.match_contents();
414 SetAndClassifyMatchContents(suggestion.suggestion(), input_text, 419 match.contents_class = suggestion.match_contents_class();
415 suggestion.match_contents(), &match);
416 420
417 if (!suggestion.annotation().empty()) 421 if (!suggestion.annotation().empty())
418 match.description = suggestion.annotation(); 422 match.description = suggestion.annotation();
419 423
420 match.allowed_to_be_default_match = 424 match.allowed_to_be_default_match =
421 (input_text == suggestion.match_contents()); 425 (input_text == suggestion.match_contents());
422 426
423 // When the user forced a query, we need to make sure all the fill_into_edit 427 // When the user forced a query, we need to make sure all the fill_into_edit
424 // values preserve that property. Otherwise, if the user starts editing a 428 // values preserve that property. Otherwise, if the user starts editing a
425 // suggestion, non-Search results will suddenly appear. 429 // suggestion, non-Search results will suddenly appear.
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 } else { 567 } else {
564 // The current top result is a navigational suggestion. 568 // The current top result is a navigational suggestion.
565 if (nav_it->IsInlineable(input)) 569 if (nav_it->IsInlineable(input))
566 break; 570 break;
567 nav_it = navigation_results->erase(nav_it); 571 nav_it = navigation_results->erase(nav_it);
568 } 572 }
569 } 573 }
570 } 574 }
571 575
572 // static 576 // static
577 void SearchProvider::RecalculateMatchContentsClass(
578 const base::string16& input_text,
579 SuggestResults* suggest_results) {
580 for (SuggestResults::iterator sug_it = suggest_results->begin();
581 sug_it != suggest_results->end(); ++sug_it) {
582 sug_it->CalculateContentsClass(false, input_text);
583 }
584 }
585
586 // static
573 int SearchProvider::CalculateRelevanceForKeywordVerbatim( 587 int SearchProvider::CalculateRelevanceForKeywordVerbatim(
574 AutocompleteInput::Type type, 588 AutocompleteInput::Type type,
575 bool prefer_keyword) { 589 bool prefer_keyword) {
576 // This function is responsible for scoring verbatim query matches 590 // This function is responsible for scoring verbatim query matches
577 // for non-extension keywords. KeywordProvider::CalculateRelevance() 591 // for non-extension keywords. KeywordProvider::CalculateRelevance()
578 // scores verbatim query matches for extension keywords, as well as 592 // scores verbatim query matches for extension keywords, as well as
579 // for keyword matches (i.e., suggestions of a keyword itself, not a 593 // for keyword matches (i.e., suggestions of a keyword itself, not a
580 // suggestion of a query on a keyword search engine). These two 594 // suggestion of a query on a keyword search engine). These two
581 // functions are currently in sync, but there's no reason we 595 // functions are currently in sync, but there's no reason we
582 // couldn't decide in the future to score verbatim matches 596 // couldn't decide in the future to score verbatim matches
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
868 (!done_ && 882 (!done_ &&
869 input_.matches_requested() == AutocompleteInput::ALL_MATCHES))) 883 input_.matches_requested() == AutocompleteInput::ALL_MATCHES)))
870 return; 884 return;
871 885
872 // We can't keep running any previous query, so halt it. 886 // We can't keep running any previous query, so halt it.
873 StopSuggest(); 887 StopSuggest();
874 888
875 // Remove existing results that cannot inline autocomplete the new input. 889 // Remove existing results that cannot inline autocomplete the new input.
876 RemoveAllStaleResults(); 890 RemoveAllStaleResults();
877 891
892 // Update the content classifications of remaining results so they look good
893 // against the current input.
894 RecalculateMatchContentsClass(
895 input_.text(), &default_results_.suggest_results);
896 if (!keyword_input_.text().empty()) {
897 RecalculateMatchContentsClass(keyword_input_.text(),
898 &keyword_results_.suggest_results);
899 }
900
878 // We can't start a new query if we're only allowed synchronous results. 901 // We can't start a new query if we're only allowed synchronous results.
879 if (input_.matches_requested() != AutocompleteInput::ALL_MATCHES) 902 if (input_.matches_requested() != AutocompleteInput::ALL_MATCHES)
880 return; 903 return;
881 904
882 // To avoid flooding the suggest server, don't send a query until at 905 // To avoid flooding the suggest server, don't send a query until at
883 // least 100 ms since the last query. 906 // least 100 ms since the last query.
884 base::TimeTicks next_suggest_time(time_suggest_request_sent_ + 907 base::TimeTicks next_suggest_time(time_suggest_request_sent_ +
885 base::TimeDelta::FromMilliseconds(kMinimumTimeBetweenSuggestQueriesMs)); 908 base::TimeDelta::FromMilliseconds(kMinimumTimeBetweenSuggestQueriesMs));
886 base::TimeTicks now(base::TimeTicks::Now()); 909 base::TimeTicks now(base::TimeTicks::Now());
887 if (now >= next_suggest_time) { 910 if (now >= next_suggest_time) {
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 base::string16 title; 1201 base::string16 title;
1179 if (descriptions != NULL) 1202 if (descriptions != NULL)
1180 descriptions->GetString(index, &title); 1203 descriptions->GetString(index, &title);
1181 results->navigation_results.push_back(NavigationResult( 1204 results->navigation_results.push_back(NavigationResult(
1182 *this, url, title, is_keyword, relevance, true)); 1205 *this, url, title, is_keyword, relevance, true));
1183 } 1206 }
1184 } else { 1207 } else {
1185 AutocompleteMatchType::Type match_type = GetAutocompleteMatchType(type); 1208 AutocompleteMatchType::Type match_type = GetAutocompleteMatchType(type);
1186 bool should_prefetch = static_cast<int>(index) == prefetch_index; 1209 bool should_prefetch = static_cast<int>(index) == prefetch_index;
1187 base::DictionaryValue* suggestion_detail = NULL; 1210 base::DictionaryValue* suggestion_detail = NULL;
1188 base::string16 match_contents = suggestion; 1211 base::string16 match_contents = suggestion;
Anuj 2014/01/06 23:23:38 Probably omit this assignment given the check you
Mark P 2014/01/07 19:10:31 I left the assignment because I moved the check in
1189 base::string16 annotation; 1212 base::string16 annotation;
1190 std::string suggest_query_params; 1213 std::string suggest_query_params;
1191 std::string deletion_url; 1214 std::string deletion_url;
1192 1215
1193 if (suggestion_details) { 1216 if (suggestion_details) {
1194 suggestion_details->GetDictionary(index, &suggestion_detail); 1217 suggestion_details->GetDictionary(index, &suggestion_detail);
1195 if (suggestion_detail) { 1218 if (suggestion_detail) {
1196 suggestion_detail->GetString("du", &deletion_url); 1219 suggestion_detail->GetString("du", &deletion_url);
1197 suggestion_detail->GetString("title", &match_contents) || 1220 suggestion_detail->GetString("title", &match_contents) ||
1198 suggestion_detail->GetString("t", &match_contents); 1221 suggestion_detail->GetString("t", &match_contents);
1199 suggestion_detail->GetString("annotation", &annotation) || 1222 suggestion_detail->GetString("annotation", &annotation) ||
1200 suggestion_detail->GetString("a", &annotation); 1223 suggestion_detail->GetString("a", &annotation);
1201 suggestion_detail->GetString("query_params", &suggest_query_params) || 1224 suggestion_detail->GetString("query_params", &suggest_query_params) ||
1202 suggestion_detail->GetString("q", &suggest_query_params); 1225 suggestion_detail->GetString("q", &suggest_query_params);
1203 } 1226 }
1204 } 1227 }
1228 // Error correction for bad data from server.
1229 if (match_contents.empty())
1230 match_contents = suggestion;
1205 1231
1206 // TODO(kochi): Improve calculator suggestion presentation. 1232 // TODO(kochi): Improve calculator suggestion presentation.
1207 results->suggest_results.push_back(SuggestResult( 1233 results->suggest_results.push_back(SuggestResult(
1208 suggestion, match_type, match_contents, annotation, 1234 suggestion, match_type, match_contents, annotation,
1209 suggest_query_params, deletion_url, is_keyword, relevance, true, 1235 suggest_query_params, deletion_url, is_keyword, relevance, true,
1210 should_prefetch)); 1236 should_prefetch, input_text));
1211 } 1237 }
1212 } 1238 }
1213 1239
1214 // Ignore suggested scores for non-keyword matches in keyword mode; if the 1240 // Ignore suggested scores for non-keyword matches in keyword mode; if the
1215 // server is allowed to score these, it could interfere with the user's 1241 // server is allowed to score these, it could interfere with the user's
1216 // ability to get good keyword results. 1242 // ability to get good keyword results.
1217 const bool abandon_suggested_scores = 1243 const bool abandon_suggested_scores =
1218 !is_keyword && !providers_.keyword_provider().empty(); 1244 !is_keyword && !providers_.keyword_provider().empty();
1219 // Apply calculated relevance scores to suggestions if a valid list was 1245 // Apply calculated relevance scores to suggestions if a valid list was
1220 // not provided or we're abandoning suggested scores entirely. 1246 // not provided or we're abandoning suggested scores entirely.
(...skipping 29 matching lines...) Expand all
1250 1276
1251 bool relevance_from_server; 1277 bool relevance_from_server;
1252 int verbatim_relevance = GetVerbatimRelevance(&relevance_from_server); 1278 int verbatim_relevance = GetVerbatimRelevance(&relevance_from_server);
1253 int did_not_accept_default_suggestion = 1279 int did_not_accept_default_suggestion =
1254 default_results_.suggest_results.empty() ? 1280 default_results_.suggest_results.empty() ?
1255 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE : 1281 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE :
1256 TemplateURLRef::NO_SUGGESTION_CHOSEN; 1282 TemplateURLRef::NO_SUGGESTION_CHOSEN;
1257 if (verbatim_relevance > 0) { 1283 if (verbatim_relevance > 0) {
1258 SuggestResult verbatim( 1284 SuggestResult verbatim(
1259 input_.text(), AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED, 1285 input_.text(), AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED,
1260 input_.text(), base::string16(), std::string(), std::string(), 1286 input_.text(), base::string16(), std::string(), std::string(), false,
1261 false, verbatim_relevance, relevance_from_server, false); 1287 verbatim_relevance, relevance_from_server, false, input_.text());
1262 AddMatchToMap(verbatim, input_.text(), std::string(), 1288 AddMatchToMap(verbatim, input_.text(), std::string(),
1263 did_not_accept_default_suggestion, &map); 1289 did_not_accept_default_suggestion, &map);
1264 } 1290 }
1265 if (!keyword_input_.text().empty()) { 1291 if (!keyword_input_.text().empty()) {
1266 const TemplateURL* keyword_url = providers_.GetKeywordProviderURL(); 1292 const TemplateURL* keyword_url = providers_.GetKeywordProviderURL();
1267 // We only create the verbatim search query match for a keyword 1293 // We only create the verbatim search query match for a keyword
1268 // if it's not an extension keyword. Extension keywords are handled 1294 // if it's not an extension keyword. Extension keywords are handled
1269 // in KeywordProvider::Start(). (Extensions are complicated...) 1295 // in KeywordProvider::Start(). (Extensions are complicated...)
1270 // Note: in this provider, SEARCH_OTHER_ENGINE must correspond 1296 // Note: in this provider, SEARCH_OTHER_ENGINE must correspond
1271 // to the keyword verbatim search query. Do not create other matches 1297 // to the keyword verbatim search query. Do not create other matches
1272 // of type SEARCH_OTHER_ENGINE. 1298 // of type SEARCH_OTHER_ENGINE.
1273 if (keyword_url && 1299 if (keyword_url &&
1274 (keyword_url->GetType() != TemplateURL::OMNIBOX_API_EXTENSION)) { 1300 (keyword_url->GetType() != TemplateURL::OMNIBOX_API_EXTENSION)) {
1275 bool keyword_relevance_from_server; 1301 bool keyword_relevance_from_server;
1276 const int keyword_verbatim_relevance = 1302 const int keyword_verbatim_relevance =
1277 GetKeywordVerbatimRelevance(&keyword_relevance_from_server); 1303 GetKeywordVerbatimRelevance(&keyword_relevance_from_server);
1278 if (keyword_verbatim_relevance > 0) { 1304 if (keyword_verbatim_relevance > 0) {
1279 SuggestResult verbatim( 1305 SuggestResult verbatim(
1280 keyword_input_.text(), AutocompleteMatchType::SEARCH_OTHER_ENGINE, 1306 keyword_input_.text(), AutocompleteMatchType::SEARCH_OTHER_ENGINE,
1281 keyword_input_.text(), base::string16(), std::string(), 1307 keyword_input_.text(), base::string16(), std::string(),
1282 std::string(), true, keyword_verbatim_relevance, 1308 std::string(), true, keyword_verbatim_relevance,
1283 keyword_relevance_from_server, false); 1309 keyword_relevance_from_server, false, keyword_input_.text());
1284 AddMatchToMap(verbatim, keyword_input_.text(), std::string(), 1310 AddMatchToMap(verbatim, keyword_input_.text(), std::string(),
1285 did_not_accept_keyword_suggestion, &map); 1311 did_not_accept_keyword_suggestion, &map);
1286 } 1312 }
1287 } 1313 }
1288 } 1314 }
1289 AddHistoryResultsToMap(keyword_history_results_, true, 1315 AddHistoryResultsToMap(keyword_history_results_, true,
1290 did_not_accept_keyword_suggestion, &map); 1316 did_not_accept_keyword_suggestion, &map);
1291 AddHistoryResultsToMap(default_history_results_, false, 1317 AddHistoryResultsToMap(default_history_results_, false,
1292 did_not_accept_default_suggestion, &map); 1318 did_not_accept_default_suggestion, &map);
1293 1319
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1623 prevent_inline_autocomplete = 1649 prevent_inline_autocomplete =
1624 !AutocompleteMatch::IsSearchType(match.type); 1650 !AutocompleteMatch::IsSearchType(match.type);
1625 } 1651 }
1626 1652
1627 int relevance = CalculateRelevanceForHistory( 1653 int relevance = CalculateRelevanceForHistory(
1628 i->time, is_keyword, !prevent_inline_autocomplete, 1654 i->time, is_keyword, !prevent_inline_autocomplete,
1629 prevent_search_history_inlining); 1655 prevent_search_history_inlining);
1630 scored_results.push_back(SuggestResult( 1656 scored_results.push_back(SuggestResult(
1631 i->term, AutocompleteMatchType::SEARCH_HISTORY, i->term, 1657 i->term, AutocompleteMatchType::SEARCH_HISTORY, i->term,
1632 base::string16(), std::string(), std::string(), is_keyword, relevance, 1658 base::string16(), std::string(), std::string(), is_keyword, relevance,
1633 false, false)); 1659 false, false, input_text));
1634 } 1660 }
1635 1661
1636 // History returns results sorted for us. However, we may have docked some 1662 // History returns results sorted for us. However, we may have docked some
1637 // results' scores, so things are no longer in order. Do a stable sort to get 1663 // results' scores, so things are no longer in order. Do a stable sort to get
1638 // things back in order without otherwise disturbing results with equal 1664 // things back in order without otherwise disturbing results with equal
1639 // scores, then force the scores to be unique, so that the order in which 1665 // scores, then force the scores to be unique, so that the order in which
1640 // they're shown is deterministic. 1666 // they're shown is deterministic.
1641 std::stable_sort(scored_results.begin(), scored_results.end(), 1667 std::stable_sort(scored_results.begin(), scored_results.end(),
1642 CompareScoredResults()); 1668 CompareScoredResults());
1643 int last_relevance = 0; 1669 int last_relevance = 0;
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
2035 if (!OmniboxFieldTrial::InZeroSuggestFieldTrial() || 2061 if (!OmniboxFieldTrial::InZeroSuggestFieldTrial() ||
2036 service == NULL || 2062 service == NULL ||
2037 !service->IsSyncEnabledAndLoggedIn() || 2063 !service->IsSyncEnabledAndLoggedIn() ||
2038 !sync_prefs.GetPreferredDataTypes(syncer::UserTypes()).Has( 2064 !sync_prefs.GetPreferredDataTypes(syncer::UserTypes()).Has(
2039 syncer::PROXY_TABS) || 2065 syncer::PROXY_TABS) ||
2040 service->GetEncryptedDataTypes().Has(syncer::SESSIONS)) 2066 service->GetEncryptedDataTypes().Has(syncer::SESSIONS))
2041 return false; 2067 return false;
2042 2068
2043 return true; 2069 return true;
2044 } 2070 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698