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

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

Issue 10274023: Omnibox SearchProvider Experiment Client Implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes and cleanup. Created 8 years, 6 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 if (i.IsWord()) { 56 if (i.IsWord()) {
57 if (found_word) 57 if (found_word)
58 return true; 58 return true;
59 found_word = true; 59 found_word = true;
60 } 60 }
61 } 61 }
62 } 62 }
63 return false; 63 return false;
64 } 64 }
65 65
66 }; 66 } // namespace
67 67
68 68
69 // SearchProvider::Providers -------------------------------------------------- 69 // SearchProvider::Providers --------------------------------------------------
70 70
71 SearchProvider::Providers::Providers(TemplateURLService* template_url_service) 71 SearchProvider::Providers::Providers(TemplateURLService* template_url_service)
72 : template_url_service_(template_url_service) { 72 : template_url_service_(template_url_service) {
73 } 73 }
74 74
75 const TemplateURL* SearchProvider::Providers::GetDefaultProviderURL() const { 75 const TemplateURL* SearchProvider::Providers::GetDefaultProviderURL() const {
76 return default_provider_.empty() ? NULL : 76 return default_provider_.empty() ? NULL :
(...skipping 12 matching lines...) Expand all
89 const int SearchProvider::kDefaultProviderURLFetcherID = 1; 89 const int SearchProvider::kDefaultProviderURLFetcherID = 1;
90 // static 90 // static
91 const int SearchProvider::kKeywordProviderURLFetcherID = 2; 91 const int SearchProvider::kKeywordProviderURLFetcherID = 2;
92 // static 92 // static
93 bool SearchProvider::query_suggest_immediately_ = false; 93 bool SearchProvider::query_suggest_immediately_ = false;
94 94
95 SearchProvider::SearchProvider(ACProviderListener* listener, Profile* profile) 95 SearchProvider::SearchProvider(ACProviderListener* listener, Profile* profile)
96 : AutocompleteProvider(listener, profile, "Search"), 96 : AutocompleteProvider(listener, profile, "Search"),
97 providers_(TemplateURLServiceFactory::GetForProfile(profile)), 97 providers_(TemplateURLServiceFactory::GetForProfile(profile)),
98 suggest_results_pending_(0), 98 suggest_results_pending_(0),
99 has_suggested_relevance_(false),
100 has_verbatim_relevance_(false),
101 verbatim_relevance_(0),
99 have_suggest_results_(false), 102 have_suggest_results_(false),
100 instant_finalized_(false) { 103 instant_finalized_(false) {
101 // We use GetSuggestNumberOfGroups() as the group ID to mean "not in field 104 // We use GetSuggestNumberOfGroups() as the group ID to mean "not in field
102 // trial." Field trial groups run from 0 to GetSuggestNumberOfGroups() - 1 105 // trial." Field trial groups run from 0 to GetSuggestNumberOfGroups() - 1
103 // (inclusive). 106 // (inclusive).
104 int suggest_field_trial_group_number = 107 int suggest_field_trial_group_number =
105 AutocompleteFieldTrial::GetSuggestNumberOfGroups(); 108 AutocompleteFieldTrial::GetSuggestNumberOfGroups();
106 if (AutocompleteFieldTrial::InSuggestFieldTrial()) { 109 if (AutocompleteFieldTrial::InSuggestFieldTrial()) {
107 suggest_field_trial_group_number = 110 suggest_field_trial_group_number =
108 AutocompleteFieldTrial::GetSuggestGroupNameAsNumber(); 111 AutocompleteFieldTrial::GetSuggestGroupNameAsNumber();
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 if (suggest_results_pending_ == 0) { 304 if (suggest_results_pending_ == 0) {
302 UpdateDone(); 305 UpdateDone();
303 // We only need to update the listener if we're actually done. 306 // We only need to update the listener if we're actually done.
304 if (done_) 307 if (done_)
305 listener_->OnProviderUpdate(false); 308 listener_->OnProviderUpdate(false);
306 } 309 }
307 } 310 }
308 311
309 void SearchProvider::Stop() { 312 void SearchProvider::Stop() {
310 StopSuggest(); 313 StopSuggest();
311 ClearResults();
312 done_ = true; 314 done_ = true;
313 default_provider_suggest_text_.clear(); 315 default_provider_suggest_text_.clear();
314 } 316 }
315 317
316 void SearchProvider::AddProviderInfo(ProvidersInfo* provider_info) const { 318 void SearchProvider::AddProviderInfo(ProvidersInfo* provider_info) const {
317 provider_info->push_back(metrics::OmniboxEventProto_ProviderInfo()); 319 provider_info->push_back(metrics::OmniboxEventProto_ProviderInfo());
318 metrics::OmniboxEventProto_ProviderInfo& new_entry = provider_info->back(); 320 metrics::OmniboxEventProto_ProviderInfo& new_entry = provider_info->back();
319 new_entry.set_provider(AsOmniboxEventProviderType()); 321 new_entry.set_provider(AsOmniboxEventProviderType());
320 new_entry.set_provider_done(done_); 322 new_entry.set_provider_done(done_);
321 } 323 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 // have its results, or are allowed to keep running it, just do that, rather 436 // have its results, or are allowed to keep running it, just do that, rather
435 // than starting a new query. 437 // than starting a new query.
436 if (minimal_changes && 438 if (minimal_changes &&
437 (have_suggest_results_ || 439 (have_suggest_results_ ||
438 (!done_ && 440 (!done_ &&
439 input_.matches_requested() == AutocompleteInput::ALL_MATCHES))) 441 input_.matches_requested() == AutocompleteInput::ALL_MATCHES)))
440 return; 442 return;
441 443
442 // We can't keep running any previous query, so halt it. 444 // We can't keep running any previous query, so halt it.
443 StopSuggest(); 445 StopSuggest();
444 ClearResults(); 446
447 // Remove existing results that cannot inline autocomplete the new input.
448 RemoveStaleResults();
445 449
446 // We can't start a new query if we're only allowed synchronous results. 450 // We can't start a new query if we're only allowed synchronous results.
447 if (input_.matches_requested() != AutocompleteInput::ALL_MATCHES) 451 if (input_.matches_requested() != AutocompleteInput::ALL_MATCHES)
448 return; 452 return;
449 453
450 // We'll have at least one pending fetch. Set it to 1 now, but the value is 454 // We'll have at least one pending fetch. Set it to 1 now, but the value is
451 // correctly set in Run. As Run isn't invoked immediately we need to set this 455 // correctly set in Run. As Run isn't invoked immediately we need to set this
452 // now, else we won't think we're waiting on results from the server when we 456 // now, else we won't think we're waiting on results from the server when we
453 // really are. 457 // really are.
454 suggest_results_pending_ = 1; 458 suggest_results_pending_ = 1;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 // Stop any in-progress URL fetches. 525 // Stop any in-progress URL fetches.
522 keyword_fetcher_.reset(); 526 keyword_fetcher_.reset();
523 default_fetcher_.reset(); 527 default_fetcher_.reset();
524 } 528 }
525 529
526 void SearchProvider::ClearResults() { 530 void SearchProvider::ClearResults() {
527 keyword_suggest_results_.clear(); 531 keyword_suggest_results_.clear();
528 default_suggest_results_.clear(); 532 default_suggest_results_.clear();
529 keyword_navigation_results_.clear(); 533 keyword_navigation_results_.clear();
530 default_navigation_results_.clear(); 534 default_navigation_results_.clear();
535 has_suggested_relevance_ = false;
536 has_verbatim_relevance_ = false;
537 verbatim_relevance_ = 0;
531 have_suggest_results_ = false; 538 have_suggest_results_ = false;
532 } 539 }
533 540
541 void SearchProvider::RemoveStaleResults() {
542 RemoveStaleSuggestResults(&keyword_suggest_results_, true);
543 RemoveStaleSuggestResults(&default_suggest_results_, false);
544 RemoveStaleNavigationResults(&keyword_navigation_results_, true);
545 RemoveStaleNavigationResults(&default_navigation_results_, false);
546 }
547
548 void SearchProvider::RemoveStaleSuggestResults(SuggestResults* list,
549 bool is_keyword) {
550 const string16& input = is_keyword ? keyword_input_text_ : input_.text();
551 for (SuggestResults::iterator i = list->begin(); i < list->end();)
552 i = (i->suggestion().find(input) != 0) ? list->erase(i) : (i + 1);
Peter Kasting 2012/06/05 00:47:51 Nit: Seems clearer: i = StartsWith(i->suggestio
msw 2012/06/05 01:49:41 Done.
553 }
554
555 void SearchProvider::RemoveStaleNavigationResults(NavigationResults* list,
556 bool is_keyword) {
557 const string16& input = is_keyword ? keyword_input_text_ : input_.text();
558 for (NavigationResults::iterator i = list->begin(); i < list->end();) {
559 const string16 fill(AutocompleteInput::FormattedStringWithEquivalentMeaning(
560 i->url(), StringForURLDisplay(i->url(), true, false)));
561 i = !URLPrefix::BestURLPrefix(fill, input) ? list->erase(i) : (i + 1);
562 }
563 }
564
565 void SearchProvider::ApplyCalculatedRelevance() {
566 ApplyCalculatedSuggestRelevance(&keyword_suggest_results_, true);
567 ApplyCalculatedSuggestRelevance(&default_suggest_results_, false);
568 ApplyCalculatedNavigationRelevance(&keyword_navigation_results_, true);
569 ApplyCalculatedNavigationRelevance(&default_navigation_results_, false);
570 has_suggested_relevance_ = false;
571 has_verbatim_relevance_ = false;
572 verbatim_relevance_ = 0;
573 }
574
575 void SearchProvider::ApplyCalculatedSuggestRelevance(SuggestResults* list,
576 bool is_keyword) {
577 for (size_t i = 0; i < list->size(); ++i) {
578 (*list)[i].set_relevance(CalculateRelevanceForSuggestion(is_keyword) +
579 (list->size() - i - 1));
580 }
581 }
582
583 void SearchProvider::ApplyCalculatedNavigationRelevance(NavigationResults* list,
584 bool is_keyword) {
585 for (size_t i = 0; i < list->size(); ++i) {
586 (*list)[i].set_relevance(CalculateRelevanceForNavigation(is_keyword) +
587 (list->size() - i - 1));
588 }
589 }
590
534 net::URLFetcher* SearchProvider::CreateSuggestFetcher( 591 net::URLFetcher* SearchProvider::CreateSuggestFetcher(
535 int id, 592 int id,
536 const TemplateURLRef& suggestions_url, 593 const TemplateURLRef& suggestions_url,
537 const string16& text) { 594 const string16& text) {
538 DCHECK(suggestions_url.SupportsReplacement()); 595 DCHECK(suggestions_url.SupportsReplacement());
539 net::URLFetcher* fetcher = content::URLFetcher::Create(id, 596 net::URLFetcher* fetcher = content::URLFetcher::Create(id,
540 GURL(suggestions_url.ReplaceSearchTerms(text, 597 GURL(suggestions_url.ReplaceSearchTerms(text,
541 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())), 598 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE, string16())),
542 net::URLFetcher::GET, this); 599 net::URLFetcher::GET, this);
543 fetcher->SetRequestContext(profile_->GetRequestContext()); 600 fetcher->SetRequestContext(profile_->GetRequestContext());
(...skipping 13 matching lines...) Expand all
557 if (!root_val->GetAsList(&root_list) || !root_list->GetString(0, &query) || 614 if (!root_val->GetAsList(&root_list) || !root_list->GetString(0, &query) ||
558 (query != input_text) || !root_list->GetList(1, &results)) 615 (query != input_text) || !root_list->GetList(1, &results))
559 return false; 616 return false;
560 617
561 // 3rd element: Description list. 618 // 3rd element: Description list.
562 ListValue* descriptions = NULL; 619 ListValue* descriptions = NULL;
563 root_list->GetList(2, &descriptions); 620 root_list->GetList(2, &descriptions);
564 621
565 // 4th element: Disregard the query URL list for now. 622 // 4th element: Disregard the query URL list for now.
566 623
624 // Reset suggested relevance information from the default provider.
625 if (!is_keyword) {
626 has_suggested_relevance_ = false;
627 has_verbatim_relevance_ = false;
628 verbatim_relevance_ = 0;
629 }
630
567 // 5th element: Optional key-value pairs from the Suggest server. 631 // 5th element: Optional key-value pairs from the Suggest server.
568 ListValue* types = NULL; 632 ListValue* types = NULL;
569 DictionaryValue* dict_val = NULL; 633 ListValue* relevances = NULL;
570 if (root_list->GetDictionary(4, &dict_val)) { 634 DictionaryValue* extras = NULL;
571 // Parse Google Suggest specific type extension. 635 if (root_list->GetDictionary(4, &extras)) {
572 dict_val->GetList("google:suggesttype", &types); 636 extras->GetList("google:suggesttype", &types);
637
638 // Only accept relevance suggestions if Instant is disabled.
639 if (!is_keyword && !InstantController::IsEnabled(profile_)) {
640 // Discard this list if its size does not match that of the suggestions.
641 if (extras->GetList("google:suggestrelevance", &relevances) &&
642 relevances->GetSize() != results->GetSize())
643 relevances = NULL;
644
645 if (extras->GetInteger("google:verbatimrelevance", &verbatim_relevance_))
646 has_verbatim_relevance_ = true;
647 }
573 } 648 }
574 649
575 SuggestResults* suggest_results = 650 SuggestResults* suggest_results =
576 is_keyword ? &keyword_suggest_results_ : &default_suggest_results_; 651 is_keyword ? &keyword_suggest_results_ : &default_suggest_results_;
577 NavigationResults* navigation_results = 652 NavigationResults* navigation_results =
578 is_keyword ? &keyword_navigation_results_ : &default_navigation_results_; 653 is_keyword ? &keyword_navigation_results_ : &default_navigation_results_;
579 654
580 string16 result; 655 // Clear the previous results now that new results are available.
581 bool results_updated = false; 656 suggest_results->clear();
657 navigation_results->clear();
658
659 string16 result, title;
660 std::string type;
661 int relevance = -1;
582 for (size_t index = 0; results->GetString(index, &result); ++index) { 662 for (size_t index = 0; results->GetString(index, &result); ++index) {
583 // Google search may return empty suggestions for weird input characters, 663 // Google search may return empty suggestions for weird input characters,
584 // they make no sense at all and can cause problems in our code. 664 // they make no sense at all and can cause problems in our code.
585 if (result.empty()) 665 if (result.empty())
586 continue; 666 continue;
587 667
588 std::string type; 668 // Apply valid suggested relevance scores; discard invalid lists.
669 if (relevances != NULL && !relevances->GetInteger(index, &relevance))
670 relevances = NULL;
589 if (types && types->GetString(index, &type) && (type == "NAVIGATION")) { 671 if (types && types->GetString(index, &type) && (type == "NAVIGATION")) {
590 if (navigation_results->size() < kMaxMatches) { 672 // Do not blindly trust the URL coming from the server to be valid.
591 // Do not blindly trust the URL coming from the server to be valid. 673 GURL url(URLFixerUpper::FixupURL(UTF16ToUTF8(result), std::string()));
592 GURL url(URLFixerUpper::FixupURL(UTF16ToUTF8(result), std::string())); 674 if (url.is_valid()) {
593 if (url.is_valid()) { 675 if (descriptions != NULL)
594 string16 description; 676 descriptions->GetString(index, &title);
595 if (descriptions != NULL) 677 navigation_results->push_back(NavigationResult(url, title, relevance));
596 descriptions->GetString(index, &description);
597 // Decrement the relevance for successive results to preserve order.
598 int relevance = CalculateRelevanceForNavigation(is_keyword) +
599 (kMaxMatches - navigation_results->size() - 1);
600 navigation_results->push_back(
601 NavigationResult(url, description, relevance));
602 results_updated = true;
603 }
604 } 678 }
605 } else { 679 } else {
606 // TODO(kochi): Currently we treat a calculator result as a query, but it 680 // TODO(kochi): Improve calculator result presentation.
607 // is better to have better presentation for caluculator results. 681 suggest_results->push_back(SuggestResult(result, relevance));
608 if (suggest_results->size() < kMaxMatches) {
609 // Decrement the relevance for successive results to preserve order.
610 int relevance = CalculateRelevanceForSuggestion(is_keyword) +
611 (kMaxMatches - suggest_results->size() - 1);
612 suggest_results->push_back(SuggestResult(result, relevance));
613 results_updated = true;
614 }
615 } 682 }
616 } 683 }
617 684
685 // Apply calculated relevance scores if a valid list was not provided.
686 if (relevances == NULL) {
687 ApplyCalculatedSuggestRelevance(suggest_results, is_keyword);
688 ApplyCalculatedNavigationRelevance(navigation_results, is_keyword);
689 } else if (!is_keyword) {
690 has_suggested_relevance_ = true;
691 }
692
618 have_suggest_results_ = true; 693 have_suggest_results_ = true;
619 return results_updated; 694 return true;
Peter Kasting 2012/06/05 00:47:51 Nit: Did you want to preserve the more fine-graine
msw 2012/06/05 01:49:41 I'll leave this as-is. Getting the exact same resu
620 } 695 }
621 696
622 void SearchProvider::ConvertResultsToAutocompleteMatches() { 697 void SearchProvider::ConvertResultsToAutocompleteMatches() {
623 // Convert all the results to matches and add them to a map, so we can keep 698 // Convert all the results to matches and add them to a map, so we can keep
624 // the most relevant match for each result. 699 // the most relevant match for each result.
625 MatchMap map; 700 MatchMap map;
626 const Time no_time; 701 const Time no_time;
627 int did_not_accept_keyword_suggestion = keyword_suggest_results_.empty() ? 702 int did_not_accept_keyword_suggestion = keyword_suggest_results_.empty() ?
628 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE : 703 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE :
629 TemplateURLRef::NO_SUGGESTION_CHOSEN; 704 TemplateURLRef::NO_SUGGESTION_CHOSEN;
630 // Keyword what you typed results are handled by the KeywordProvider. 705 // Keyword what you typed results are handled by the KeywordProvider.
631 706
632 int verbatim_relevance = CalculateRelevanceForWhatYouTyped(); 707 int verbatim_relevance = CalculateRelevanceForWhatYouTyped();
633 int did_not_accept_default_suggestion = default_suggest_results_.empty() ? 708 int did_not_accept_default_suggestion = default_suggest_results_.empty() ?
634 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE : 709 TemplateURLRef::NO_SUGGESTIONS_AVAILABLE :
635 TemplateURLRef::NO_SUGGESTION_CHOSEN; 710 TemplateURLRef::NO_SUGGESTION_CHOSEN;
636 AddMatchToMap(input_.text(), input_.text(), verbatim_relevance, 711 if (verbatim_relevance > 0) {
637 AutocompleteMatch::SEARCH_WHAT_YOU_TYPED, 712 AddMatchToMap(input_.text(), input_.text(), verbatim_relevance,
638 did_not_accept_default_suggestion, false, &map); 713 AutocompleteMatch::SEARCH_WHAT_YOU_TYPED,
714 did_not_accept_default_suggestion, false, &map);
715 }
639 const size_t what_you_typed_size = map.size(); 716 const size_t what_you_typed_size = map.size();
640 if (!default_provider_suggest_text_.empty()) { 717 if (!default_provider_suggest_text_.empty()) {
641 AddMatchToMap(input_.text() + default_provider_suggest_text_, 718 AddMatchToMap(input_.text() + default_provider_suggest_text_,
642 input_.text(), verbatim_relevance + 1, 719 input_.text(), verbatim_relevance + 1,
643 AutocompleteMatch::SEARCH_SUGGEST, 720 AutocompleteMatch::SEARCH_SUGGEST,
644 did_not_accept_default_suggestion, false, &map); 721 did_not_accept_default_suggestion, false, &map);
645 } 722 }
646 723
647 AddHistoryResultsToMap(keyword_history_results_, true, 724 AddHistoryResultsToMap(keyword_history_results_, true,
648 did_not_accept_keyword_suggestion, &map); 725 did_not_accept_keyword_suggestion, &map);
(...skipping 12 matching lines...) Expand all
661 AddNavigationResultsToMatches(default_navigation_results_, false); 738 AddNavigationResultsToMatches(default_navigation_results_, false);
662 739
663 // Allow an additional match for "what you typed" if it's present. 740 // Allow an additional match for "what you typed" if it's present.
664 const size_t max_total_matches = kMaxMatches + what_you_typed_size; 741 const size_t max_total_matches = kMaxMatches + what_you_typed_size;
665 std::partial_sort(matches_.begin(), 742 std::partial_sort(matches_.begin(),
666 matches_.begin() + std::min(max_total_matches, matches_.size()), 743 matches_.begin() + std::min(max_total_matches, matches_.size()),
667 matches_.end(), &AutocompleteMatch::MoreRelevant); 744 matches_.end(), &AutocompleteMatch::MoreRelevant);
668 if (matches_.size() > max_total_matches) 745 if (matches_.size() > max_total_matches)
669 matches_.erase(matches_.begin() + max_total_matches, matches_.end()); 746 matches_.erase(matches_.begin() + max_total_matches, matches_.end());
670 747
748 // The top result must be inlinable; apply calculated scores if it is not.
749 if (!matches_.empty() &&
750 (has_suggested_relevance_ || has_verbatim_relevance_) &&
751 (matches_.front().type == AutocompleteMatch::SEARCH_SUGGEST ||
752 matches_.front().type == AutocompleteMatch::NAVSUGGEST) &&
753 matches_.front().inline_autocomplete_offset == string16::npos) {
754 ApplyCalculatedRelevance();
755 ConvertResultsToAutocompleteMatches();
756 }
757
671 UpdateStarredStateOfMatches(); 758 UpdateStarredStateOfMatches();
672 UpdateDone(); 759 UpdateDone();
673 } 760 }
674 761
675 void SearchProvider::AddNavigationResultsToMatches( 762 void SearchProvider::AddNavigationResultsToMatches(
676 const NavigationResults& navigation_results, 763 const NavigationResults& navigation_results,
677 bool is_keyword) { 764 bool is_keyword) {
678 if (!navigation_results.empty()) { 765 if (!navigation_results.empty()) {
679 // TODO(kochi|msw): Add more navigational results if they get more 766 // TODO(kochi|msw): Add more navigational results if they get more
680 // meaningful relevance values; see http://b/1170574. 767 // meaningful relevance values; see http://b/1170574.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 bool is_keyword, 876 bool is_keyword,
790 MatchMap* map) { 877 MatchMap* map) {
791 const string16& input_text = is_keyword ? keyword_input_text_ : input_.text(); 878 const string16& input_text = is_keyword ? keyword_input_text_ : input_.text();
792 for (size_t i = 0; i < results.size(); ++i) { 879 for (size_t i = 0; i < results.size(); ++i) {
793 AddMatchToMap(results[i].suggestion(), input_text, results[i].relevance(), 880 AddMatchToMap(results[i].suggestion(), input_text, results[i].relevance(),
794 AutocompleteMatch::SEARCH_SUGGEST, i, is_keyword, map); 881 AutocompleteMatch::SEARCH_SUGGEST, i, is_keyword, map);
795 } 882 }
796 } 883 }
797 884
798 int SearchProvider::CalculateRelevanceForWhatYouTyped() const { 885 int SearchProvider::CalculateRelevanceForWhatYouTyped() const {
886 if (has_verbatim_relevance_ && !input_.prevent_inline_autocomplete())
887 return verbatim_relevance_;
888
799 if (!providers_.keyword_provider().empty()) 889 if (!providers_.keyword_provider().empty())
800 return 250; 890 return 250;
801 891
802 switch (input_.type()) { 892 switch (input_.type()) {
803 case AutocompleteInput::UNKNOWN: 893 case AutocompleteInput::UNKNOWN:
804 case AutocompleteInput::QUERY: 894 case AutocompleteInput::QUERY:
805 case AutocompleteInput::FORCED_QUERY: 895 case AutocompleteInput::FORCED_QUERY:
806 return 1300; 896 return 1300;
807 897
808 case AutocompleteInput::REQUESTED_URL: 898 case AutocompleteInput::REQUESTED_URL:
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 ACMatchClassification::NONE, &match.description_class); 1114 ACMatchClassification::NONE, &match.description_class);
1025 return match; 1115 return match;
1026 } 1116 }
1027 1117
1028 void SearchProvider::UpdateDone() { 1118 void SearchProvider::UpdateDone() {
1029 // We're done when there are no more suggest queries pending (this is set to 1 1119 // We're done when there are no more suggest queries pending (this is set to 1
1030 // when the timer is started) and we're not waiting on instant. 1120 // when the timer is started) and we're not waiting on instant.
1031 done_ = ((suggest_results_pending_ == 0) && 1121 done_ = ((suggest_results_pending_ == 0) &&
1032 (instant_finalized_ || !InstantController::IsEnabled(profile_))); 1122 (instant_finalized_ || !InstantController::IsEnabled(profile_)));
1033 } 1123 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698