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

Side by Side Diff: chrome/browser/autocomplete/history_contents_provider.h

Issue 7607007: Add confidence to AutocompleteMatch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 #ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H_ 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H_
6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H_ 6 #define CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H_
7 #pragma once 7 #pragma once
8 8
9 #include "chrome/browser/autocomplete/history_provider.h" 9 #include "chrome/browser/autocomplete/history_provider.h"
10 #include "chrome/browser/history/history.h" 10 #include "chrome/browser/history/history.h"
11 11
12 struct MatchReference;
Peter Kasting 2011/08/09 20:53:00 Nit: Shouldn't this be moved inside HistoryContent
dominich 2011/08/09 21:43:43 I went back and forward on this a couple of times.
13
12 namespace bookmark_utils { 14 namespace bookmark_utils {
13 struct TitleMatch; 15 struct TitleMatch;
14 } 16 }
15 17
16 // HistoryContentsProvider is an AutocompleteProvider that provides results from 18 // HistoryContentsProvider is an AutocompleteProvider that provides results from
17 // the contents (body and/or title) of previously visited pages. 19 // the contents (body and/or title) of previously visited pages.
18 // HistoryContentsProvider gets results from two sources: 20 // HistoryContentsProvider gets results from two sources:
19 // . HistoryService: this provides results for matches in the body/title of 21 // . HistoryService: this provides results for matches in the body/title of
20 // previously viewed pages. This is asynchronous. 22 // previously viewed pages. This is asynchronous.
21 // . BookmarkModel: provides results for matches in the titles of bookmarks. 23 // . BookmarkModel: provides results for matches in the titles of bookmarks.
(...skipping 16 matching lines...) Expand all
38 virtual ~HistoryContentsProvider(); 40 virtual ~HistoryContentsProvider();
39 41
40 void QueryComplete(HistoryService::Handle handle, 42 void QueryComplete(HistoryService::Handle handle,
41 history::QueryResults* results); 43 history::QueryResults* results);
42 44
43 // Converts each MatchingPageResult in results_ to an AutocompleteMatch and 45 // Converts each MatchingPageResult in results_ to an AutocompleteMatch and
44 // adds it to matches_. 46 // adds it to matches_.
45 void ConvertResults(); 47 void ConvertResults();
46 48
47 // Creates and returns an AutocompleteMatch from a MatchingPageResult. 49 // Creates and returns an AutocompleteMatch from a MatchingPageResult.
48 AutocompleteMatch ResultToMatch(const history::URLResult& result, 50 AutocompleteMatch ResultToMatch(const MatchReference& match_reference);
49 int score);
50 51
51 // Adds ACMatchClassifications to match from the offset positions in 52 // Adds ACMatchClassifications to match from the offset positions in
52 // page_result. 53 // page_result.
53 void ClassifyDescription(const history::URLResult& result, 54 void ClassifyDescription(const history::URLResult& result,
54 AutocompleteMatch* match) const; 55 AutocompleteMatch* match) const;
55 56
56 // Calculates and returns the relevance of a particular result. See the 57 // Calculates and returns the relevance of a particular result. See the
57 // chart in autocomplete.h for the list of values this returns. 58 // chart in autocomplete.h for the list of values this returns.
58 int CalculateRelevance(const history::URLResult& result); 59 int CalculateRelevance(const history::URLResult& result);
59 60
61 // Calculates and returns the confidence for a particular result. This is
62 // calculated by comparing the result's |visit_count| to that of all the
63 // results.
64 float CalculateConfidence(const history::URLResult& result,
65 const history::QueryResults& results) const;
66
60 // Queries the bookmarks for any bookmarks whose title matches input. All 67 // Queries the bookmarks for any bookmarks whose title matches input. All
61 // matches are added directly to results_. 68 // matches are added directly to results_.
62 void QueryBookmarks(const AutocompleteInput& input); 69 void QueryBookmarks(const AutocompleteInput& input);
63 70
64 // Converts a BookmarkModel::TitleMatch to a QueryResult and adds it to 71 // Converts a BookmarkModel::TitleMatch to a QueryResult and adds it to
65 // results_. 72 // results_.
66 void AddBookmarkTitleMatchToResults(const bookmark_utils::TitleMatch& match); 73 void AddBookmarkTitleMatchToResults(const bookmark_utils::TitleMatch& match);
67 74
68 // Return true if the search term can be found in the title of |result|. 75 // Return true if the search term can be found in the title of |result|.
69 bool MatchInTitle(const history::URLResult& result); 76 bool MatchInTitle(const history::URLResult& result);
(...skipping 26 matching lines...) Expand all
96 // Whether results_ is valid (so we can tell invalid apart from empty). 103 // Whether results_ is valid (so we can tell invalid apart from empty).
97 bool have_results_; 104 bool have_results_;
98 105
99 // Current query string. 106 // Current query string.
100 string16 query_; 107 string16 query_;
101 108
102 DISALLOW_COPY_AND_ASSIGN(HistoryContentsProvider); 109 DISALLOW_COPY_AND_ASSIGN(HistoryContentsProvider);
103 }; 110 };
104 111
105 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H_ 112 #endif // CHROME_BROWSER_AUTOCOMPLETE_HISTORY_CONTENTS_PROVIDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698