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

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

Issue 7607007: Add confidence to AutocompleteMatch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 798 matching lines...) Expand 10 before | Expand all | Expand 10 after
809 } 809 }
810 810
811 void SearchProvider::AddMatchToMap(const string16& query_string, 811 void SearchProvider::AddMatchToMap(const string16& query_string,
812 const string16& input_text, 812 const string16& input_text,
813 int relevance, 813 int relevance,
814 AutocompleteMatch::Type type, 814 AutocompleteMatch::Type type,
815 int accepted_suggestion, 815 int accepted_suggestion,
816 bool is_keyword, 816 bool is_keyword,
817 bool prevent_inline_autocomplete, 817 bool prevent_inline_autocomplete,
818 MatchMap* map) { 818 MatchMap* map) {
819 AutocompleteMatch match(this, relevance, false, type); 819 // TODO(dominich): Confidence. In this case, the confidence must depend on the
820 // source. Scored terms can be calculated based on score, but other sources
821 // need more care. Eg, suggest.
822 AutocompleteMatch match(this, relevance, 0.0f, false, type);
820 std::vector<size_t> content_param_offsets; 823 std::vector<size_t> content_param_offsets;
821 const TemplateURL& provider = is_keyword ? providers_.keyword_provider() : 824 const TemplateURL& provider = is_keyword ? providers_.keyword_provider() :
822 providers_.default_provider(); 825 providers_.default_provider();
823 match.template_url = &provider; 826 match.template_url = &provider;
824 match.contents.assign(query_string); 827 match.contents.assign(query_string);
825 // We do intra-string highlighting for suggestions - the suggested segment 828 // We do intra-string highlighting for suggestions - the suggested segment
826 // will be highlighted, e.g. for input_text = "you" the suggestion may be 829 // will be highlighted, e.g. for input_text = "you" the suggestion may be
827 // "youtube", so we'll bold the "tube" section: you*tube*. 830 // "youtube", so we'll bold the "tube" section: you*tube*.
828 if (input_text != query_string) { 831 if (input_text != query_string) {
829 size_t input_position = match.contents.find(input_text); 832 size_t input_position = match.contents.find(input_text);
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 if (!i.second && (match.relevance > i.first->second.relevance)) 913 if (!i.second && (match.relevance > i.first->second.relevance))
911 i.first->second = match; 914 i.first->second = match;
912 } 915 }
913 916
914 AutocompleteMatch SearchProvider::NavigationToMatch( 917 AutocompleteMatch SearchProvider::NavigationToMatch(
915 const NavigationResult& navigation, 918 const NavigationResult& navigation,
916 int relevance, 919 int relevance,
917 bool is_keyword) { 920 bool is_keyword) {
918 const string16& input_text = 921 const string16& input_text =
919 is_keyword ? keyword_input_text_ : input_.text(); 922 is_keyword ? keyword_input_text_ : input_.text();
920 AutocompleteMatch match(this, relevance, false, 923 // TODO(dominich): Confidence calculation.
924 AutocompleteMatch match(this, relevance, 0.0f, false,
921 AutocompleteMatch::NAVSUGGEST); 925 AutocompleteMatch::NAVSUGGEST);
922 match.destination_url = navigation.url; 926 match.destination_url = navigation.url;
923 match.contents = 927 match.contents =
924 StringForURLDisplay(navigation.url, true, !HasHTTPScheme(input_text)); 928 StringForURLDisplay(navigation.url, true, !HasHTTPScheme(input_text));
925 AutocompleteMatch::ClassifyMatchInString(input_text, match.contents, 929 AutocompleteMatch::ClassifyMatchInString(input_text, match.contents,
926 ACMatchClassification::URL, 930 ACMatchClassification::URL,
927 &match.contents_class); 931 &match.contents_class);
928 932
929 match.description = navigation.site_name; 933 match.description = navigation.site_name;
930 AutocompleteMatch::ClassifyMatchInString(input_text, navigation.site_name, 934 AutocompleteMatch::ClassifyMatchInString(input_text, navigation.site_name,
(...skipping 13 matching lines...) Expand all
944 948
945 return match; 949 return match;
946 } 950 }
947 951
948 void SearchProvider::UpdateDone() { 952 void SearchProvider::UpdateDone() {
949 // We're done when there are no more suggest queries pending (this is set to 1 953 // We're done when there are no more suggest queries pending (this is set to 1
950 // when the timer is started) and we're not waiting on instant. 954 // when the timer is started) and we're not waiting on instant.
951 done_ = ((suggest_results_pending_ == 0) && 955 done_ = ((suggest_results_pending_ == 0) &&
952 (instant_finalized_ || !InstantController::IsEnabled(profile_))); 956 (instant_finalized_ || !InstantController::IsEnabled(profile_)));
953 } 957 }
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/keyword_provider.cc ('k') | chrome/browser/autocomplete/shortcuts_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698