OLD | NEW |
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/auto_reset.h" | |
11 #include "base/callback.h" | 10 #include "base/callback.h" |
12 #include "base/i18n/break_iterator.h" | 11 #include "base/i18n/break_iterator.h" |
13 #include "base/i18n/case_conversion.h" | 12 #include "base/i18n/case_conversion.h" |
14 #include "base/i18n/icu_string_conversions.h" | 13 #include "base/i18n/icu_string_conversions.h" |
15 #include "base/json/json_string_value_serializer.h" | 14 #include "base/json/json_string_value_serializer.h" |
16 #include "base/message_loop.h" | 15 #include "base/message_loop.h" |
17 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
18 #include "base/prefs/pref_service.h" | 17 #include "base/prefs/pref_service.h" |
19 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
20 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 const char SearchProvider::kRelevanceFromServerKey[] = "relevance_from_server"; | 242 const char SearchProvider::kRelevanceFromServerKey[] = "relevance_from_server"; |
244 const char SearchProvider::kTrue[] = "true"; | 243 const char SearchProvider::kTrue[] = "true"; |
245 const char SearchProvider::kFalse[] = "false"; | 244 const char SearchProvider::kFalse[] = "false"; |
246 | 245 |
247 SearchProvider::SearchProvider(AutocompleteProviderListener* listener, | 246 SearchProvider::SearchProvider(AutocompleteProviderListener* listener, |
248 Profile* profile) | 247 Profile* profile) |
249 : AutocompleteProvider(listener, profile, | 248 : AutocompleteProvider(listener, profile, |
250 AutocompleteProvider::TYPE_SEARCH), | 249 AutocompleteProvider::TYPE_SEARCH), |
251 providers_(TemplateURLServiceFactory::GetForProfile(profile)), | 250 providers_(TemplateURLServiceFactory::GetForProfile(profile)), |
252 suggest_results_pending_(0), | 251 suggest_results_pending_(0), |
253 instant_finalized_(false), | |
254 field_trial_triggered_(false), | 252 field_trial_triggered_(false), |
255 field_trial_triggered_in_session_(false), | 253 field_trial_triggered_in_session_(false), |
256 suppress_search_suggestions_(false), | |
257 omnibox_start_margin_(-1) { | 254 omnibox_start_margin_(-1) { |
258 } | 255 } |
259 | 256 |
260 // static | 257 // static |
261 AutocompleteMatch SearchProvider::CreateSearchSuggestion( | 258 AutocompleteMatch SearchProvider::CreateSearchSuggestion( |
262 Profile* profile, | 259 Profile* profile, |
263 AutocompleteProvider* autocomplete_provider, | 260 AutocompleteProvider* autocomplete_provider, |
264 const AutocompleteInput& input, | 261 const AutocompleteInput& input, |
265 const string16& query_string, | 262 const string16& query_string, |
266 const string16& input_text, | 263 const string16& input_text, |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 new_entry.mutable_field_trial_triggered_in_session()->Add( | 363 new_entry.mutable_field_trial_triggered_in_session()->Add( |
367 field_trial_hashes[i]); | 364 field_trial_hashes[i]); |
368 } | 365 } |
369 } | 366 } |
370 } | 367 } |
371 | 368 |
372 void SearchProvider::ResetSession() { | 369 void SearchProvider::ResetSession() { |
373 field_trial_triggered_in_session_ = false; | 370 field_trial_triggered_in_session_ = false; |
374 } | 371 } |
375 | 372 |
376 void SearchProvider::FinalizeInstantQuery(const string16& input_text, | |
377 const InstantSuggestion& suggestion) { | |
378 if (done_ || instant_finalized_) | |
379 return; | |
380 | |
381 instant_finalized_ = true; | |
382 UpdateDone(); | |
383 | |
384 if (input_text.empty()) { | |
385 // We only need to update the listener if we're actually done. | |
386 if (done_) | |
387 listener_->OnProviderUpdate(false); | |
388 return; | |
389 } | |
390 | |
391 default_provider_suggestion_ = suggestion; | |
392 | |
393 string16 adjusted_input_text(input_text); | |
394 AutocompleteInput::RemoveForcedQueryStringIfNecessary(input_.type(), | |
395 &adjusted_input_text); | |
396 | |
397 const string16 text = adjusted_input_text + suggestion.text; | |
398 bool results_updated = false; | |
399 // Remove any matches that are identical to |text|. We don't use the | |
400 // destination_url for comparison as it varies depending upon the index passed | |
401 // to TemplateURL::ReplaceSearchTerms. | |
402 for (ACMatches::iterator i = matches_.begin(); i != matches_.end();) { | |
403 if (((i->type == AutocompleteMatchType::SEARCH_HISTORY) || | |
404 (i->type == AutocompleteMatchType::SEARCH_SUGGEST)) && | |
405 (i->fill_into_edit == text)) { | |
406 i = matches_.erase(i); | |
407 results_updated = true; | |
408 } else { | |
409 ++i; | |
410 } | |
411 } | |
412 | |
413 // Add the new Instant suggest result. | |
414 if (suggestion.type == INSTANT_SUGGESTION_SEARCH) { | |
415 // Instant has a query suggestion. Rank it higher than SEARCH_WHAT_YOU_TYPED | |
416 // so that it gets autocompleted. | |
417 bool relevance_from_server; | |
418 const int verbatim_relevance = GetVerbatimRelevance(&relevance_from_server); | |
419 int did_not_accept_default_suggestion = | |
420 default_results_.suggest_results.empty() ? | |
421 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE : | |
422 TemplateURLRef::NO_SUGGESTION_CHOSEN; | |
423 MatchMap match_map; | |
424 AddMatchToMap(text, adjusted_input_text, verbatim_relevance + 1, | |
425 relevance_from_server, AutocompleteMatchType::SEARCH_SUGGEST, | |
426 did_not_accept_default_suggestion, false, &match_map); | |
427 if (!match_map.empty()) { | |
428 matches_.push_back(match_map.begin()->second); | |
429 results_updated = true; | |
430 } | |
431 } else { | |
432 // Instant has a URL suggestion. Rank it higher than other providers would | |
433 // rank URL_WHAT_YOU_TYPED so it gets autocompleted; use | |
434 // kNonURLVerbatimRelevance rather than |verbatim_relevance| so that the | |
435 // score does not change if the user keeps typing and the input changes from | |
436 // type UNKNOWN to URL. | |
437 matches_.push_back(NavigationToMatch(NavigationResult( | |
438 *this, GURL(UTF16ToUTF8(suggestion.text)), string16(), false, | |
439 kNonURLVerbatimRelevance + 1, false))); | |
440 results_updated = true; | |
441 } | |
442 | |
443 if (results_updated || done_) | |
444 listener_->OnProviderUpdate(results_updated); | |
445 } | |
446 | |
447 void SearchProvider::ClearInstantSuggestion() { | |
448 default_provider_suggestion_ = InstantSuggestion(); | |
449 if (done_ || instant_finalized_) | |
450 return; | |
451 instant_finalized_ = true; | |
452 UpdateMatches(); | |
453 listener_->OnProviderUpdate(true); | |
454 } | |
455 | |
456 void SearchProvider::SuppressSearchSuggestions() { | |
457 suppress_search_suggestions_ = true; | |
458 } | |
459 | |
460 void SearchProvider::SetOmniboxStartMargin(int omnibox_start_margin) { | 373 void SearchProvider::SetOmniboxStartMargin(int omnibox_start_margin) { |
461 omnibox_start_margin_ = omnibox_start_margin; | 374 omnibox_start_margin_ = omnibox_start_margin; |
462 } | 375 } |
463 | 376 |
464 bool SearchProvider::IsNonInstantSearchDone() const { | |
465 return !timer_.IsRunning() && (suggest_results_pending_ == 0); | |
466 } | |
467 | |
468 SearchProvider::~SearchProvider() { | 377 SearchProvider::~SearchProvider() { |
469 } | 378 } |
470 | 379 |
471 // static | 380 // static |
472 void SearchProvider::RemoveStaleResults(const string16& input, | 381 void SearchProvider::RemoveStaleResults(const string16& input, |
473 int verbatim_relevance, | 382 int verbatim_relevance, |
474 SuggestResults* suggest_results, | 383 SuggestResults* suggest_results, |
475 NavigationResults* navigation_results) { | 384 NavigationResults* navigation_results) { |
476 DCHECK_GE(verbatim_relevance, 0); | 385 DCHECK_GE(verbatim_relevance, 0); |
477 // Keep pointers to the head of (the highest scoring elements of) | 386 // Keep pointers to the head of (the highest scoring elements of) |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 // differently for extension and non-extension keywords. If you | 444 // differently for extension and non-extension keywords. If you |
536 // make such a change, however, you should update this comment to | 445 // make such a change, however, you should update this comment to |
537 // describe it, so it's clear why the functions diverge. | 446 // describe it, so it's clear why the functions diverge. |
538 if (prefer_keyword) | 447 if (prefer_keyword) |
539 return 1500; | 448 return 1500; |
540 return (type == AutocompleteInput::QUERY) ? 1450 : 1100; | 449 return (type == AutocompleteInput::QUERY) ? 1450 : 1100; |
541 } | 450 } |
542 | 451 |
543 void SearchProvider::Start(const AutocompleteInput& input, | 452 void SearchProvider::Start(const AutocompleteInput& input, |
544 bool minimal_changes) { | 453 bool minimal_changes) { |
545 const bool suppress_search_suggestions = suppress_search_suggestions_; | |
546 suppress_search_suggestions_ = false; | |
547 | |
548 // Do our best to load the model as early as possible. This will reduce | 454 // Do our best to load the model as early as possible. This will reduce |
549 // odds of having the model not ready when really needed (a non-empty input). | 455 // odds of having the model not ready when really needed (a non-empty input). |
550 TemplateURLService* model = providers_.template_url_service(); | 456 TemplateURLService* model = providers_.template_url_service(); |
551 DCHECK(model); | 457 DCHECK(model); |
552 model->Load(); | 458 model->Load(); |
553 | 459 |
554 matches_.clear(); | 460 matches_.clear(); |
555 field_trial_triggered_ = false; | 461 field_trial_triggered_ = false; |
556 | 462 |
557 instant_finalized_ = | |
558 (input.matches_requested() != AutocompleteInput::ALL_MATCHES); | |
559 | |
560 // Can't return search/suggest results for bogus input or without a profile. | 463 // Can't return search/suggest results for bogus input or without a profile. |
561 if (!profile_ || (input.type() == AutocompleteInput::INVALID)) { | 464 if (!profile_ || (input.type() == AutocompleteInput::INVALID)) { |
562 Stop(false); | 465 Stop(false); |
563 return; | 466 return; |
564 } | 467 } |
565 | 468 |
566 keyword_input_ = input; | 469 keyword_input_ = input; |
567 const TemplateURL* keyword_provider = | 470 const TemplateURL* keyword_provider = |
568 KeywordProvider::GetSubstitutingTemplateURLForInput(model, | 471 KeywordProvider::GetSubstitutingTemplateURLForInput(model, |
569 &keyword_input_); | 472 &keyword_input_); |
(...skipping 16 matching lines...) Expand all Loading... |
586 } | 489 } |
587 | 490 |
588 // If we're still running an old query but have since changed the query text | 491 // If we're still running an old query but have since changed the query text |
589 // or the providers, abort the query. | 492 // or the providers, abort the query. |
590 string16 default_provider_keyword(default_provider ? | 493 string16 default_provider_keyword(default_provider ? |
591 default_provider->keyword() : string16()); | 494 default_provider->keyword() : string16()); |
592 string16 keyword_provider_keyword(keyword_provider ? | 495 string16 keyword_provider_keyword(keyword_provider ? |
593 keyword_provider->keyword() : string16()); | 496 keyword_provider->keyword() : string16()); |
594 if (!minimal_changes || | 497 if (!minimal_changes || |
595 !providers_.equal(default_provider_keyword, keyword_provider_keyword)) { | 498 !providers_.equal(default_provider_keyword, keyword_provider_keyword)) { |
596 // If Instant has not come back with a suggestion, adjust the previous | |
597 // suggestion if possible. If |instant_finalized| is true, we are looking | |
598 // for synchronous matches only, so the suggestion is cleared. | |
599 if (instant_finalized_) | |
600 default_provider_suggestion_ = InstantSuggestion(); | |
601 else | |
602 AdjustDefaultProviderSuggestion(input_.text(), input.text()); | |
603 | |
604 // Cancel any in-flight suggest requests. | 499 // Cancel any in-flight suggest requests. |
605 if (!done_) { | 500 if (!done_) |
606 // The Stop(false) call below clears |default_provider_suggestion_|, but | |
607 // in this instance we do not want to clear cached results, so we | |
608 // restore it. | |
609 base::AutoReset<InstantSuggestion> reset(&default_provider_suggestion_, | |
610 InstantSuggestion()); | |
611 Stop(false); | 501 Stop(false); |
612 } | |
613 } | 502 } |
614 | 503 |
615 providers_.set(default_provider_keyword, keyword_provider_keyword); | 504 providers_.set(default_provider_keyword, keyword_provider_keyword); |
616 | 505 |
617 if (input.text().empty()) { | 506 if (input.text().empty()) { |
618 // User typed "?" alone. Give them a placeholder result indicating what | 507 // User typed "?" alone. Give them a placeholder result indicating what |
619 // this syntax does. | 508 // this syntax does. |
620 if (default_provider) { | 509 if (default_provider) { |
621 AutocompleteMatch match; | 510 AutocompleteMatch match; |
622 match.provider = this; | 511 match.provider = this; |
623 match.contents.assign(l10n_util::GetStringUTF16(IDS_EMPTY_KEYWORD_VALUE)); | 512 match.contents.assign(l10n_util::GetStringUTF16(IDS_EMPTY_KEYWORD_VALUE)); |
624 match.contents_class.push_back( | 513 match.contents_class.push_back( |
625 ACMatchClassification(0, ACMatchClassification::NONE)); | 514 ACMatchClassification(0, ACMatchClassification::NONE)); |
626 match.keyword = providers_.default_provider(); | 515 match.keyword = providers_.default_provider(); |
627 matches_.push_back(match); | 516 matches_.push_back(match); |
628 } | 517 } |
629 Stop(false); | 518 Stop(false); |
630 return; | 519 return; |
631 } | 520 } |
632 | 521 |
633 input_ = input; | 522 input_ = input; |
634 | 523 |
635 if (!suppress_search_suggestions) { | 524 DoHistoryQuery(minimal_changes); |
636 DoHistoryQuery(minimal_changes); | 525 StartOrStopSuggestQuery(minimal_changes); |
637 StartOrStopSuggestQuery(minimal_changes); | |
638 } | |
639 UpdateMatches(); | 526 UpdateMatches(); |
640 } | 527 } |
641 | 528 |
642 void SearchProvider::Stop(bool clear_cached_results) { | 529 void SearchProvider::Stop(bool clear_cached_results) { |
643 StopSuggest(); | 530 StopSuggest(); |
644 done_ = true; | 531 done_ = true; |
645 default_provider_suggestion_ = InstantSuggestion(); | |
646 | 532 |
647 if (clear_cached_results) | 533 if (clear_cached_results) |
648 ClearAllResults(); | 534 ClearAllResults(); |
649 } | 535 } |
650 | 536 |
651 void SearchProvider::OnURLFetchComplete(const net::URLFetcher* source) { | 537 void SearchProvider::OnURLFetchComplete(const net::URLFetcher* source) { |
652 DCHECK(!done_); | 538 DCHECK(!done_); |
653 suggest_results_pending_--; | 539 suggest_results_pending_--; |
654 LogOmniboxSuggestRequest(REPLY_RECEIVED); | 540 LogOmniboxSuggestRequest(REPLY_RECEIVED); |
655 DCHECK_GE(suggest_results_pending_, 0); // Should never go negative. | 541 DCHECK_GE(suggest_results_pending_, 0); // Should never go negative. |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
898 RemoveStaleResults(keyword_input_.text(), GetKeywordVerbatimRelevance(NULL), | 784 RemoveStaleResults(keyword_input_.text(), GetKeywordVerbatimRelevance(NULL), |
899 &keyword_results_.suggest_results, | 785 &keyword_results_.suggest_results, |
900 &keyword_results_.navigation_results); | 786 &keyword_results_.navigation_results); |
901 } else { | 787 } else { |
902 // User is either in keyword mode with a blank input or out of | 788 // User is either in keyword mode with a blank input or out of |
903 // keyword mode entirely. | 789 // keyword mode entirely. |
904 keyword_results_.Clear(); | 790 keyword_results_.Clear(); |
905 } | 791 } |
906 } | 792 } |
907 | 793 |
908 void SearchProvider::AdjustDefaultProviderSuggestion( | |
909 const string16& previous_input, | |
910 const string16& current_input) { | |
911 if (default_provider_suggestion_.type == INSTANT_SUGGESTION_URL) { | |
912 // Description and relevance do not matter in the check for staleness. | |
913 NavigationResult result(*this, GURL(default_provider_suggestion_.text), | |
914 string16(), false, 100, false); | |
915 // If navigation suggestion is stale, clear |default_provider_suggestion_|. | |
916 if (!result.IsInlineable(current_input)) | |
917 default_provider_suggestion_ = InstantSuggestion(); | |
918 } else { | |
919 DCHECK(default_provider_suggestion_.type == INSTANT_SUGGESTION_SEARCH); | |
920 // InstantSuggestion of type SEARCH contain only the suggested text, and not | |
921 // the full text of the query. This looks at the current and previous input | |
922 // to determine if the user is typing forward, and if the new input is | |
923 // contained in |default_provider_suggestion_|. If so, the suggestion is | |
924 // adjusted and can be kept. Otherwise, it is reset. | |
925 if (!previous_input.empty() && | |
926 StartsWith(current_input, previous_input, false)) { | |
927 // User is typing forward; verify if new input is part of the suggestion. | |
928 const string16 new_text = string16(current_input, previous_input.size()); | |
929 if (StartsWith(default_provider_suggestion_.text, new_text, false)) { | |
930 // New input is a prefix to the previous suggestion, adjust the | |
931 // suggestion to strip the prefix. | |
932 default_provider_suggestion_.text.erase(0, new_text.size()); | |
933 return; | |
934 } | |
935 } | |
936 // If we are here, the search suggestion is stale; reset it. | |
937 default_provider_suggestion_ = InstantSuggestion(); | |
938 } | |
939 } | |
940 | |
941 void SearchProvider::ApplyCalculatedRelevance() { | 794 void SearchProvider::ApplyCalculatedRelevance() { |
942 ApplyCalculatedSuggestRelevance(&keyword_results_.suggest_results); | 795 ApplyCalculatedSuggestRelevance(&keyword_results_.suggest_results); |
943 ApplyCalculatedSuggestRelevance(&default_results_.suggest_results); | 796 ApplyCalculatedSuggestRelevance(&default_results_.suggest_results); |
944 ApplyCalculatedNavigationRelevance(&keyword_results_.navigation_results); | 797 ApplyCalculatedNavigationRelevance(&keyword_results_.navigation_results); |
945 ApplyCalculatedNavigationRelevance(&default_results_.navigation_results); | 798 ApplyCalculatedNavigationRelevance(&default_results_.navigation_results); |
946 default_results_.verbatim_relevance = -1; | 799 default_results_.verbatim_relevance = -1; |
947 keyword_results_.verbatim_relevance = -1; | 800 keyword_results_.verbatim_relevance = -1; |
948 } | 801 } |
949 | 802 |
950 void SearchProvider::ApplyCalculatedSuggestRelevance(SuggestResults* list) { | 803 void SearchProvider::ApplyCalculatedSuggestRelevance(SuggestResults* list) { |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1124 const int keyword_verbatim_relevance = | 977 const int keyword_verbatim_relevance = |
1125 GetKeywordVerbatimRelevance(&keyword_relevance_from_server); | 978 GetKeywordVerbatimRelevance(&keyword_relevance_from_server); |
1126 if (keyword_verbatim_relevance > 0) { | 979 if (keyword_verbatim_relevance > 0) { |
1127 AddMatchToMap(keyword_input_.text(), keyword_input_.text(), | 980 AddMatchToMap(keyword_input_.text(), keyword_input_.text(), |
1128 keyword_verbatim_relevance, keyword_relevance_from_server, | 981 keyword_verbatim_relevance, keyword_relevance_from_server, |
1129 AutocompleteMatchType::SEARCH_OTHER_ENGINE, | 982 AutocompleteMatchType::SEARCH_OTHER_ENGINE, |
1130 did_not_accept_keyword_suggestion, true, &map); | 983 did_not_accept_keyword_suggestion, true, &map); |
1131 } | 984 } |
1132 } | 985 } |
1133 } | 986 } |
1134 if (!default_provider_suggestion_.text.empty() && | |
1135 default_provider_suggestion_.type == INSTANT_SUGGESTION_SEARCH && | |
1136 !input_.prevent_inline_autocomplete()) | |
1137 AddMatchToMap(input_.text() + default_provider_suggestion_.text, | |
1138 input_.text(), verbatim_relevance + 1, relevance_from_server, | |
1139 AutocompleteMatchType::SEARCH_SUGGEST, | |
1140 did_not_accept_default_suggestion, false, &map); | |
1141 | |
1142 AddHistoryResultsToMap(keyword_history_results_, true, | 987 AddHistoryResultsToMap(keyword_history_results_, true, |
1143 did_not_accept_keyword_suggestion, &map); | 988 did_not_accept_keyword_suggestion, &map); |
1144 AddHistoryResultsToMap(default_history_results_, false, | 989 AddHistoryResultsToMap(default_history_results_, false, |
1145 did_not_accept_default_suggestion, &map); | 990 did_not_accept_default_suggestion, &map); |
1146 | 991 |
1147 AddSuggestResultsToMap(keyword_results_.suggest_results, &map); | 992 AddSuggestResultsToMap(keyword_results_.suggest_results, &map); |
1148 AddSuggestResultsToMap(default_results_.suggest_results, &map); | 993 AddSuggestResultsToMap(default_results_.suggest_results, &map); |
1149 | 994 |
1150 ACMatches matches; | 995 ACMatches matches; |
1151 for (MatchMap::const_iterator i(map.begin()); i != map.end(); ++i) | 996 for (MatchMap::const_iterator i(map.begin()); i != map.end(); ++i) |
1152 matches.push_back(i->second); | 997 matches.push_back(i->second); |
1153 | 998 |
1154 if (!default_provider_suggestion_.text.empty() && | |
1155 default_provider_suggestion_.type == INSTANT_SUGGESTION_URL && | |
1156 !input_.prevent_inline_autocomplete()) { | |
1157 // See comment in FinalizeInstantQuery() for why we don't use | |
1158 // |verbatim_relevance| here. | |
1159 matches.push_back(NavigationToMatch(NavigationResult( | |
1160 *this, GURL(UTF16ToUTF8(default_provider_suggestion_.text)), string16(), | |
1161 false, kNonURLVerbatimRelevance + 1, false))); | |
1162 } | |
1163 AddNavigationResultsToMatches(keyword_results_.navigation_results, &matches); | 999 AddNavigationResultsToMatches(keyword_results_.navigation_results, &matches); |
1164 AddNavigationResultsToMatches(default_results_.navigation_results, &matches); | 1000 AddNavigationResultsToMatches(default_results_.navigation_results, &matches); |
1165 | 1001 |
1166 // Now add the most relevant matches to |matches_|. We take up to kMaxMatches | 1002 // Now add the most relevant matches to |matches_|. We take up to kMaxMatches |
1167 // suggest/navsuggest matches, regardless of origin. If Instant Extended is | 1003 // suggest/navsuggest matches, regardless of origin. If Instant Extended is |
1168 // enabled and we have server-provided (and thus hopefully more accurate) | 1004 // enabled and we have server-provided (and thus hopefully more accurate) |
1169 // scores for some suggestions, we allow more of those, until we reach | 1005 // scores for some suggestions, we allow more of those, until we reach |
1170 // AutocompleteResult::kMaxMatches total matches (that is, enough to fill the | 1006 // AutocompleteResult::kMaxMatches total matches (that is, enough to fill the |
1171 // whole popup). | 1007 // whole popup). |
1172 // | 1008 // |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1666 return; | 1502 return; |
1667 max_query_relevance = std::max(max_query_relevance - 1, 0); | 1503 max_query_relevance = std::max(max_query_relevance - 1, 0); |
1668 it->set_relevance(max_query_relevance); | 1504 it->set_relevance(max_query_relevance); |
1669 it->set_relevance_from_server(relevance_from_server); | 1505 it->set_relevance_from_server(relevance_from_server); |
1670 } | 1506 } |
1671 } | 1507 } |
1672 | 1508 |
1673 void SearchProvider::UpdateDone() { | 1509 void SearchProvider::UpdateDone() { |
1674 // We're done when the timer isn't running, there are no suggest queries | 1510 // We're done when the timer isn't running, there are no suggest queries |
1675 // pending, and we're not waiting on Instant. | 1511 // pending, and we're not waiting on Instant. |
1676 done_ = IsNonInstantSearchDone() && | 1512 done_ = !timer_.IsRunning() && (suggest_results_pending_ == 0); |
1677 (instant_finalized_ || !chrome::IsInstantEnabled(profile_)); | |
1678 } | 1513 } |
OLD | NEW |