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

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

Issue 471673002: Omnibox: Prevent Asynchronous Suggestions from Changing Default Match (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: retore dropped comment Created 6 years, 4 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/base64.h" 10 #include "base/base64.h"
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 // functions are currently in sync, but there's no reason we 163 // functions are currently in sync, but there's no reason we
164 // couldn't decide in the future to score verbatim matches 164 // couldn't decide in the future to score verbatim matches
165 // differently for extension and non-extension keywords. If you 165 // differently for extension and non-extension keywords. If you
166 // make such a change, however, you should update this comment to 166 // make such a change, however, you should update this comment to
167 // describe it, so it's clear why the functions diverge. 167 // describe it, so it's clear why the functions diverge.
168 if (prefer_keyword) 168 if (prefer_keyword)
169 return 1500; 169 return 1500;
170 return (type == metrics::OmniboxInputType::QUERY) ? 1450 : 1100; 170 return (type == metrics::OmniboxInputType::QUERY) ? 1450 : 1100;
171 } 171 }
172 172
173 // static
174 void SearchProvider::UpdateOldResults(
175 bool minimal_changes,
176 SearchSuggestionParser::Results* results) {
177 // When called without |minimal_changes|, it likely means the user has
178 // pressed a key. Revise the cached results appropriately.
179 if (!minimal_changes) {
180 for (SearchSuggestionParser::SuggestResults::iterator sug_it =
181 results->suggest_results.begin();
182 sug_it != results->suggest_results.end(); ++sug_it) {
183 sug_it->set_received_after_last_keystroke(false);
184 }
185 for (SearchSuggestionParser::NavigationResults::iterator nav_it =
186 results->navigation_results.begin();
187 nav_it != results->navigation_results.end(); ++nav_it) {
188 nav_it->set_received_after_last_keystroke(false);
189 }
190 }
191 }
192
193 // static
194 ACMatches::iterator SearchProvider::FindTopMatch(ACMatches* matches) {
195 ACMatches::iterator it = matches->begin();
196 while ((it != matches->end()) && !it->allowed_to_be_default_match)
197 ++it;
198 return it;
199 }
200
173 void SearchProvider::Start(const AutocompleteInput& input, 201 void SearchProvider::Start(const AutocompleteInput& input,
174 bool minimal_changes) { 202 bool minimal_changes) {
175 // Do our best to load the model as early as possible. This will reduce 203 // Do our best to load the model as early as possible. This will reduce
176 // odds of having the model not ready when really needed (a non-empty input). 204 // odds of having the model not ready when really needed (a non-empty input).
177 TemplateURLService* model = providers_.template_url_service(); 205 TemplateURLService* model = providers_.template_url_service();
178 DCHECK(model); 206 DCHECK(model);
179 model->Load(); 207 model->Load();
180 208
181 matches_.clear(); 209 matches_.clear();
182 field_trial_triggered_ = false; 210 field_trial_triggered_ = false;
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 UMA_HISTOGRAM_TIMES("Omnibox.SuggestRequest.Success.GoogleResponseTime", 413 UMA_HISTOGRAM_TIMES("Omnibox.SuggestRequest.Success.GoogleResponseTime",
386 elapsed_time); 414 elapsed_time);
387 } else { 415 } else {
388 UMA_HISTOGRAM_TIMES("Omnibox.SuggestRequest.Failure.GoogleResponseTime", 416 UMA_HISTOGRAM_TIMES("Omnibox.SuggestRequest.Failure.GoogleResponseTime",
389 elapsed_time); 417 elapsed_time);
390 } 418 }
391 } 419 }
392 } 420 }
393 421
394 void SearchProvider::UpdateMatches() { 422 void SearchProvider::UpdateMatches() {
423 PersistInlineSuggestions(&default_results_);
424 PersistInlineSuggestions(&keyword_results_);
395 ConvertResultsToAutocompleteMatches(); 425 ConvertResultsToAutocompleteMatches();
396 426
397 // Check constraints that may be violated by suggested relevances. 427 // Check constraints that may be violated by suggested relevances.
398 if (!matches_.empty() && 428 if (!matches_.empty() &&
399 (default_results_.HasServerProvidedScores() || 429 (default_results_.HasServerProvidedScores() ||
400 keyword_results_.HasServerProvidedScores())) { 430 keyword_results_.HasServerProvidedScores())) {
401 // These blocks attempt to repair undesirable behavior by suggested 431 // These blocks attempt to repair undesirable behavior by suggested
402 // relevances with minimal impact, preserving other suggested relevances. 432 // relevances with minimal impact, preserving other suggested relevances.
403 433
404 if ((providers_.GetKeywordProviderURL() != NULL) && 434 if ((providers_.GetKeywordProviderURL() != NULL) &&
405 (FindTopMatch() == matches_.end())) { 435 (FindTopMatch() == matches_.end())) {
406 // In keyword mode, disregard the keyword verbatim suggested relevance 436 // In keyword mode, disregard the keyword verbatim suggested relevance
407 // if necessary, so at least one match is allowed to be default. 437 // if necessary, so at least one match is allowed to be default. (This
408 keyword_results_.verbatim_relevance = -1; 438 // is only necessary if we were told to suppress keyword verbatim and
439 // hence have no default keyword match.) Give keyword verbatim the
440 // lowest non-zero score to best reflect what the server desired.
441 DCHECK_EQ(0, keyword_results_.verbatim_relevance);
442 keyword_results_.verbatim_relevance = 1;
409 ConvertResultsToAutocompleteMatches(); 443 ConvertResultsToAutocompleteMatches();
410 } 444 }
411 if (IsTopMatchSearchWithURLInput()) { 445 if (IsTopMatchSearchWithURLInput()) {
412 // Disregard the suggested search and verbatim relevances if the input 446 // Disregard the suggested search and verbatim relevances if the input
413 // type is URL and the top match is a highly-ranked search suggestion. 447 // type is URL and the top match is a highly-ranked search suggestion.
414 // For example, prevent a search for "foo.com" from outranking another 448 // For example, prevent a search for "foo.com" from outranking another
415 // provider's navigation for "foo.com" or "foo.com/url_from_history". 449 // provider's navigation for "foo.com" or "foo.com/url_from_history".
416 ApplyCalculatedSuggestRelevance(&keyword_results_.suggest_results); 450 ApplyCalculatedSuggestRelevance(&keyword_results_.suggest_results);
417 ApplyCalculatedSuggestRelevance(&default_results_.suggest_results); 451 ApplyCalculatedSuggestRelevance(&default_results_.suggest_results);
418 default_results_.verbatim_relevance = -1; 452 default_results_.verbatim_relevance = -1;
419 keyword_results_.verbatim_relevance = -1; 453 keyword_results_.verbatim_relevance = -1;
420 ConvertResultsToAutocompleteMatches(); 454 ConvertResultsToAutocompleteMatches();
421 } 455 }
422 if (FindTopMatch() == matches_.end()) { 456 if (FindTopMatch() == matches_.end()) {
423 // Guarantee that SearchProvider returns a legal default match. (The 457 // Guarantee that SearchProvider returns a legal default match. (The
424 // omnibox always needs at least one legal default match, and it relies 458 // omnibox always needs at least one legal default match, and it relies
425 // on SearchProvider to always return one.) 459 // on SearchProvider to always return one.) Give the verbatim suggestion
426 ApplyCalculatedRelevance(); 460 // the lowest non-zero scores to best reflect what the server desired.
461 DCHECK_EQ(0, default_results_.verbatim_relevance);
462 default_results_.verbatim_relevance = 1;
463 // We do not have to alter keyword_results_.verbatim_relevance here.
464 // If the user is in keyword mode, we already reverted (earlier in this
465 // function) the instructions to suppress keyword verbatim.
427 ConvertResultsToAutocompleteMatches(); 466 ConvertResultsToAutocompleteMatches();
428 } 467 }
429 DCHECK(!IsTopMatchSearchWithURLInput()); 468 DCHECK(!IsTopMatchSearchWithURLInput());
430 DCHECK(FindTopMatch() != matches_.end()); 469 DCHECK(FindTopMatch() != matches_.end());
431 } 470 }
432 UMA_HISTOGRAM_CUSTOM_COUNTS( 471 UMA_HISTOGRAM_CUSTOM_COUNTS(
433 "Omnibox.SearchProviderMatches", matches_.size(), 1, 6, 7); 472 "Omnibox.SearchProviderMatches", matches_.size(), 1, 6, 7);
473
474 // Record the inlined suggestion (if any) for future use.
475 inlined_query_suggestion_match_contents_ = base::string16();
476 inlined_navigation_suggestion_ = GURL();
477 ACMatches::const_iterator first_match = FindTopMatch();
478 if ((first_match != matches_.end()) &&
479 !first_match->inline_autocompletion.empty()) {
480 // Identify if this match came from a query suggestion or a navsuggestion.
481 // In either case, extracts the identifying feature of the suggestion
482 // (query string or navigation url).
483 if (AutocompleteMatch::IsSearchType(first_match->type)) {
484 inlined_query_suggestion_match_contents_ = first_match->contents;
485 } else {
486 inlined_navigation_suggestion_ = first_match->destination_url;
487 }
488 }
489
434 UpdateDone(); 490 UpdateDone();
435 } 491 }
436 492
437 void SearchProvider::Run() { 493 void SearchProvider::Run() {
438 // Start a new request with the current input. 494 // Start a new request with the current input.
439 suggest_results_pending_ = 0; 495 suggest_results_pending_ = 0;
440 time_suggest_request_sent_ = base::TimeTicks::Now(); 496 time_suggest_request_sent_ = base::TimeTicks::Now();
441 497
442 default_fetcher_.reset(CreateSuggestFetcher(kDefaultProviderURLFetcherID, 498 default_fetcher_.reset(CreateSuggestFetcher(kDefaultProviderURLFetcherID,
443 providers_.GetDefaultProviderURL(), input_)); 499 providers_.GetDefaultProviderURL(), input_));
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 (!default_results_.suggest_results.empty() || 570 (!default_results_.suggest_results.empty() ||
515 !default_results_.navigation_results.empty() || 571 !default_results_.navigation_results.empty() ||
516 !keyword_results_.suggest_results.empty() || 572 !keyword_results_.suggest_results.empty() ||
517 !keyword_results_.navigation_results.empty() || 573 !keyword_results_.navigation_results.empty() ||
518 (!done_ && input_.want_asynchronous_matches()))) 574 (!done_ && input_.want_asynchronous_matches())))
519 return; 575 return;
520 576
521 // We can't keep running any previous query, so halt it. 577 // We can't keep running any previous query, so halt it.
522 StopSuggest(); 578 StopSuggest();
523 579
524 // Remove existing results that cannot inline autocomplete the new input. 580 UpdateAllOldResults(minimal_changes);
525 RemoveAllStaleResults();
526 581
527 // Update the content classifications of remaining results so they look good 582 // Update the content classifications of remaining results so they look good
528 // against the current input. 583 // against the current input.
529 UpdateMatchContentsClass(input_.text(), &default_results_); 584 UpdateMatchContentsClass(input_.text(), &default_results_);
530 if (!keyword_input_.text().empty()) 585 if (!keyword_input_.text().empty())
531 UpdateMatchContentsClass(keyword_input_.text(), &keyword_results_); 586 UpdateMatchContentsClass(keyword_input_.text(), &keyword_results_);
532 587
533 // We can't start a new query if we're only allowed synchronous results. 588 // We can't start a new query if we're only allowed synchronous results.
534 if (!input_.want_asynchronous_matches()) 589 if (!input_.want_asynchronous_matches())
535 return; 590 return;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
599 // Don't send anything for https except the hostname. Hostnames are OK 654 // Don't send anything for https except the hostname. Hostnames are OK
600 // because they are visible when the TCP connection is established, but the 655 // because they are visible when the TCP connection is established, but the
601 // specific path may reveal private information. 656 // specific path may reveal private information.
602 if (LowerCaseEqualsASCII(input_.scheme(), url::kHttpsScheme) && 657 if (LowerCaseEqualsASCII(input_.scheme(), url::kHttpsScheme) &&
603 parts.path.is_nonempty()) 658 parts.path.is_nonempty())
604 return false; 659 return false;
605 660
606 return true; 661 return true;
607 } 662 }
608 663
609 void SearchProvider::RemoveAllStaleResults() { 664 void SearchProvider::UpdateAllOldResults(bool minimal_changes) {
610 if (keyword_input_.text().empty()) { 665 if (keyword_input_.text().empty()) {
611 // User is either in keyword mode with a blank input or out of 666 // User is either in keyword mode with a blank input or out of
612 // keyword mode entirely. 667 // keyword mode entirely.
613 keyword_results_.Clear(); 668 keyword_results_.Clear();
614 } 669 }
670 UpdateOldResults(minimal_changes, &default_results_);
671 UpdateOldResults(minimal_changes, &keyword_results_);
615 } 672 }
616 673
617 void SearchProvider::ApplyCalculatedRelevance() { 674 void SearchProvider::PersistInlineSuggestions(
618 ApplyCalculatedSuggestRelevance(&keyword_results_.suggest_results); 675 SearchSuggestionParser::Results* results) {
619 ApplyCalculatedSuggestRelevance(&default_results_.suggest_results); 676 if (!inlined_query_suggestion_match_contents_.empty()) {
620 ApplyCalculatedNavigationRelevance(&keyword_results_.navigation_results); 677 for (SearchSuggestionParser::SuggestResults::iterator sug_it =
621 ApplyCalculatedNavigationRelevance(&default_results_.navigation_results); 678 results->suggest_results.begin();
622 default_results_.verbatim_relevance = -1; 679 sug_it != results->suggest_results.end(); ++sug_it) {
623 keyword_results_.verbatim_relevance = -1; 680 if (sug_it->match_contents() ==
681 inlined_query_suggestion_match_contents_)
682 sug_it->set_received_after_last_keystroke(false);
683 }
684 }
685 if (inlined_navigation_suggestion_.is_valid()) {
686 for (SearchSuggestionParser::NavigationResults::iterator nav_it =
687 results->navigation_results.begin();
688 nav_it != results->navigation_results.end(); ++nav_it) {
689 if (nav_it->url() == inlined_navigation_suggestion_)
690 nav_it->set_received_after_last_keystroke(false);
691 }
692 }
624 } 693 }
625 694
626 void SearchProvider::ApplyCalculatedSuggestRelevance( 695 void SearchProvider::ApplyCalculatedSuggestRelevance(
627 SearchSuggestionParser::SuggestResults* list) { 696 SearchSuggestionParser::SuggestResults* list) {
628 for (size_t i = 0; i < list->size(); ++i) { 697 for (size_t i = 0; i < list->size(); ++i) {
629 SearchSuggestionParser::SuggestResult& result = (*list)[i]; 698 SearchSuggestionParser::SuggestResult& result = (*list)[i];
630 result.set_relevance( 699 result.set_relevance(
631 result.CalculateRelevance(input_, providers_.has_keyword_provider()) + 700 result.CalculateRelevance(input_, providers_.has_keyword_provider()) +
632 (list->size() - i - 1)); 701 (list->size() - i - 1));
633 result.set_relevance_from_server(false); 702 result.set_relevance_from_server(false);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
782 default_results_.metadata, &map); 851 default_results_.metadata, &map);
783 852
784 ACMatches matches; 853 ACMatches matches;
785 for (MatchMap::const_iterator i(map.begin()); i != map.end(); ++i) 854 for (MatchMap::const_iterator i(map.begin()); i != map.end(); ++i)
786 matches.push_back(i->second); 855 matches.push_back(i->second);
787 856
788 AddNavigationResultsToMatches(keyword_results_.navigation_results, &matches); 857 AddNavigationResultsToMatches(keyword_results_.navigation_results, &matches);
789 AddNavigationResultsToMatches(default_results_.navigation_results, &matches); 858 AddNavigationResultsToMatches(default_results_.navigation_results, &matches);
790 859
791 // Now add the most relevant matches to |matches_|. We take up to kMaxMatches 860 // Now add the most relevant matches to |matches_|. We take up to kMaxMatches
792 // suggest/navsuggest matches, regardless of origin. If Instant Extended is 861 // suggest/navsuggest matches, regardless of origin. We always include in
793 // enabled and we have server-provided (and thus hopefully more accurate) 862 // that set a legal default match if possible. If Instant Extended is enabled
794 // scores for some suggestions, we allow more of those, until we reach 863 // and we have server-provided (and thus hopefully more accurate) scores for
864 // some suggestions, we allow more of those, until we reach
795 // AutocompleteResult::kMaxMatches total matches (that is, enough to fill the 865 // AutocompleteResult::kMaxMatches total matches (that is, enough to fill the
796 // whole popup). 866 // whole popup).
797 // 867 //
798 // We will always return any verbatim matches, no matter how we obtained their 868 // We will always return any verbatim matches, no matter how we obtained their
799 // scores, unless we have already accepted AutocompleteResult::kMaxMatches 869 // scores, unless we have already accepted AutocompleteResult::kMaxMatches
800 // higher-scoring matches under the conditions above. 870 // higher-scoring matches under the conditions above.
801 std::sort(matches.begin(), matches.end(), &AutocompleteMatch::MoreRelevant); 871 std::sort(matches.begin(), matches.end(), &AutocompleteMatch::MoreRelevant);
802 matches_.clear(); 872 matches_.clear();
873 // Guarantee that if there's a legal default match anywhere in the result
874 // set that it'll get returned by moving the default match to the front
875 // of the list.
876 ACMatches::iterator default_match = FindTopMatch(&matches);
877 if (default_match != matches.end())
878 std::rotate(matches.begin(), default_match, default_match + 1);
803 879
804 size_t num_suggestions = 0; 880 size_t num_suggestions = 0;
805 for (ACMatches::const_iterator i(matches.begin()); 881 for (ACMatches::const_iterator i(matches.begin());
806 (i != matches.end()) && 882 (i != matches.end()) &&
807 (matches_.size() < AutocompleteResult::kMaxMatches); 883 (matches_.size() < AutocompleteResult::kMaxMatches);
808 ++i) { 884 ++i) {
809 // SEARCH_OTHER_ENGINE is only used in the SearchProvider for the keyword 885 // SEARCH_OTHER_ENGINE is only used in the SearchProvider for the keyword
810 // verbatim result, so this condition basically means "if this match is a 886 // verbatim result, so this condition basically means "if this match is a
811 // suggestion of some sort". 887 // suggestion of some sort".
812 if ((i->type != AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED) && 888 if ((i->type != AutocompleteMatchType::SEARCH_WHAT_YOU_TYPED) &&
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 prevent_search_history_inlining); 1007 prevent_search_history_inlining);
932 // Add the match to |scored_results| by putting the what-you-typed match 1008 // Add the match to |scored_results| by putting the what-you-typed match
933 // on the front and appending all other matches. We want the what-you- 1009 // on the front and appending all other matches. We want the what-you-
934 // typed match to always be first. 1010 // typed match to always be first.
935 SearchSuggestionParser::SuggestResults::iterator insertion_position = 1011 SearchSuggestionParser::SuggestResults::iterator insertion_position =
936 scored_results.end(); 1012 scored_results.end();
937 if (trimmed_suggestion == trimmed_input) { 1013 if (trimmed_suggestion == trimmed_input) {
938 found_what_you_typed_match = true; 1014 found_what_you_typed_match = true;
939 insertion_position = scored_results.begin(); 1015 insertion_position = scored_results.begin();
940 } 1016 }
941 scored_results.insert( 1017 SearchSuggestionParser::SuggestResult history_suggestion(
942 insertion_position, 1018 trimmed_suggestion, AutocompleteMatchType::SEARCH_HISTORY,
943 SearchSuggestionParser::SuggestResult( 1019 trimmed_suggestion, base::string16(), base::string16(),
944 trimmed_suggestion, AutocompleteMatchType::SEARCH_HISTORY, 1020 base::string16(), base::string16(), std::string(), std::string(),
945 trimmed_suggestion, base::string16(), base::string16(), 1021 is_keyword, relevance, false, false, trimmed_input);
946 base::string16(), base::string16(), std::string(), std::string(), 1022 // History results are synchronous; they are received at the last keystroke.
947 is_keyword, relevance, false, false, trimmed_input)); 1023 history_suggestion.set_received_after_last_keystroke(false);
1024 scored_results.insert(insertion_position, history_suggestion);
948 } 1025 }
949 1026
950 // History returns results sorted for us. However, we may have docked some 1027 // History returns results sorted for us. However, we may have docked some
951 // results' scores, so things are no longer in order. While keeping the 1028 // results' scores, so things are no longer in order. While keeping the
952 // what-you-typed match at the front (if it exists), do a stable sort to get 1029 // what-you-typed match at the front (if it exists), do a stable sort to get
953 // things back in order without otherwise disturbing results with equal 1030 // things back in order without otherwise disturbing results with equal
954 // scores, then force the scores to be unique, so that the order in which 1031 // scores, then force the scores to be unique, so that the order in which
955 // they're shown is deterministic. 1032 // they're shown is deterministic.
956 std::stable_sort(scored_results.begin() + 1033 std::stable_sort(scored_results.begin() +
957 (found_what_you_typed_match ? 1 : 0), 1034 (found_what_you_typed_match ? 1 : 0),
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1172 if (inline_autocomplete_offset != base::string16::npos) 1249 if (inline_autocomplete_offset != base::string16::npos)
1173 ++inline_autocomplete_offset; 1250 ++inline_autocomplete_offset;
1174 } 1251 }
1175 if (inline_autocomplete_offset != base::string16::npos) { 1252 if (inline_autocomplete_offset != base::string16::npos) {
1176 DCHECK(inline_autocomplete_offset <= match.fill_into_edit.length()); 1253 DCHECK(inline_autocomplete_offset <= match.fill_into_edit.length());
1177 match.inline_autocompletion = 1254 match.inline_autocompletion =
1178 match.fill_into_edit.substr(inline_autocomplete_offset); 1255 match.fill_into_edit.substr(inline_autocomplete_offset);
1179 } 1256 }
1180 // An inlineable navsuggestion can only be the default match when there 1257 // An inlineable navsuggestion can only be the default match when there
1181 // is no keyword provider active, lest it appear first and break the user 1258 // is no keyword provider active, lest it appear first and break the user
1182 // out of keyword mode. It can also only be default if either the inline 1259 // out of keyword mode. We also must have received the navsuggestion before
1260 // the last keystroke. (We don't want asynchronous inline autocompletions.)
1261 // The navsuggestion can also only be default if either the inline
1183 // autocompletion is empty or we're not preventing inline autocompletion. 1262 // autocompletion is empty or we're not preventing inline autocompletion.
1184 // Finally, if we have an inlineable navsuggestion with an inline completion 1263 // Finally, if we have an inlineable navsuggestion with an inline completion
1185 // that we're not preventing, make sure we didn't trim any whitespace. 1264 // that we're not preventing, make sure we didn't trim any whitespace.
1186 // We don't want to claim http://foo.com/bar is inlineable against the 1265 // We don't want to claim http://foo.com/bar is inlineable against the
1187 // input "foo.com/b ". 1266 // input "foo.com/b ".
1188 match.allowed_to_be_default_match = (prefix != NULL) && 1267 match.allowed_to_be_default_match =
1268 (prefix != NULL) &&
1189 (providers_.GetKeywordProviderURL() == NULL) && 1269 (providers_.GetKeywordProviderURL() == NULL) &&
1270 !navigation.received_after_last_keystroke() &&
1190 (match.inline_autocompletion.empty() || 1271 (match.inline_autocompletion.empty() ||
1191 (!input_.prevent_inline_autocomplete() && !trimmed_whitespace)); 1272 (!input_.prevent_inline_autocomplete() && !trimmed_whitespace));
1192 match.EnsureUWYTIsAllowedToBeDefault( 1273 match.EnsureUWYTIsAllowedToBeDefault(
1193 input_.canonicalized_url(), providers_.template_url_service()); 1274 input_.canonicalized_url(), providers_.template_url_service());
1194 1275
1195 match.contents = navigation.match_contents(); 1276 match.contents = navigation.match_contents();
1196 match.contents_class = navigation.match_contents_class(); 1277 match.contents_class = navigation.match_contents_class();
1197 match.description = navigation.description(); 1278 match.description = navigation.description();
1198 AutocompleteMatch::ClassifyMatchInString(input, match.description, 1279 AutocompleteMatch::ClassifyMatchInString(input, match.description,
1199 ACMatchClassification::NONE, &match.description_class); 1280 ACMatchClassification::NONE, &match.description_class);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1252 last_answer_seen_.query_type = match->answer_type; 1333 last_answer_seen_.query_type = match->answer_type;
1253 } 1334 }
1254 1335
1255 void SearchProvider::DoAnswersQuery(const AutocompleteInput& input) { 1336 void SearchProvider::DoAnswersQuery(const AutocompleteInput& input) {
1256 // If the query text starts with trimmed input, this is valid prefetch data. 1337 // If the query text starts with trimmed input, this is valid prefetch data.
1257 prefetch_data_ = StartsWith(last_answer_seen_.full_query_text, 1338 prefetch_data_ = StartsWith(last_answer_seen_.full_query_text,
1258 base::CollapseWhitespace(input.text(), false), 1339 base::CollapseWhitespace(input.text(), false),
1259 false) ? 1340 false) ?
1260 last_answer_seen_ : AnswersQueryData(); 1341 last_answer_seen_ : AnswersQueryData();
1261 } 1342 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698