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

Side by Side Diff: chrome/browser/history/scored_history_match.h

Issue 77453007: Omnibox: Make HistoryURL Highlight Titles like HistoryQuick Provider (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years 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 #ifndef CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_ 5 #ifndef CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_
6 #define CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_ 6 #define CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_
7 7
8 #include <map> 8 #include <map>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // with url_info to make tie-breaking a bit smarter. 57 // with url_info to make tie-breaking a bit smarter.
58 static bool MatchScoreGreater(const ScoredHistoryMatch& m1, 58 static bool MatchScoreGreater(const ScoredHistoryMatch& m1,
59 const ScoredHistoryMatch& m2); 59 const ScoredHistoryMatch& m2);
60 60
61 // Accessors: 61 // Accessors:
62 int raw_score() const { return raw_score_; } 62 int raw_score() const { return raw_score_; }
63 const TermMatches& url_matches() const { return url_matches_; } 63 const TermMatches& url_matches() const { return url_matches_; }
64 const TermMatches& title_matches() const { return title_matches_; } 64 const TermMatches& title_matches() const { return title_matches_; }
65 bool can_inline() const { return can_inline_; } 65 bool can_inline() const { return can_inline_; }
66 66
67 // Returns |term_matches| after removing all matches that are not at a
68 // word break that starts after position |start_pos|. If |start_pos| is
69 // string::npos, does no filtering and simply returns |term_matches|.
70 static TermMatches FilterTermMatchesByWordStarts(
71 const TermMatches& term_matches,
72 const WordStarts& word_starts,
73 const size_t start_pos);
74
67 private: 75 private:
68 friend class ScoredHistoryMatchTest; 76 friend class ScoredHistoryMatchTest;
69 77
70 // The number of days of recency scores to precompute. 78 // The number of days of recency scores to precompute.
71 static const int kDaysToPrecomputeRecencyScoresFor; 79 static const int kDaysToPrecomputeRecencyScoresFor;
72 80
73 // The number of raw term score buckets use; raw term scores 81 // The number of raw term score buckets use; raw term scores
74 // greater this are capped at the score of the largest bucket. 82 // greater this are capped at the score of the largest bucket.
75 static const int kMaxRawTermScore; 83 static const int kMaxRawTermScore;
76 84
77 // Return a topicality score based on how many matches appear in the 85 // Return a topicality score based on how many matches appear in the
78 // url and the page's title and where they are (e.g., at word 86 // url and the page's title and where they are (e.g., at word
79 // boundaries). Revises |url_matches_| and |title_matches_| in the 87 // boundaries). Revises |url_matches_| and |title_matches_| in the
80 // process so they only reflect matches used for scoring. (For 88 // process so they only reflect matches used for scoring. (For
81 // instance, some mid-word matches are not given credit in scoring.) 89 // instance, some mid-word matches are not given credit in scoring.)
82 float GetTopicalityScore(const int num_terms, 90 float GetTopicalityScore(const int num_terms,
83 const string16& cleaned_up_url, 91 const string16& cleaned_up_url,
84 const RowWordStarts& word_starts); 92 const RowWordStarts& word_starts);
85 93
86 // Helper function for GetTopicalityScore().
87 // Returns |term_matches| after removing all matches that are not at a
88 // word break that starts after position |start_pos|. If |start_pos| is
89 // string::npos, does no filtering and simply returns |term_matches|.
90 static TermMatches FilterTermMatchesByWordStarts(
91 const TermMatches& term_matches,
92 const WordStarts& word_starts,
93 const size_t start_pos);
94
95 // Precalculates raw_term_score_to_topicality_score_, used in 94 // Precalculates raw_term_score_to_topicality_score_, used in
96 // GetTopicalityScore(). 95 // GetTopicalityScore().
97 static void FillInTermScoreToTopicalityScoreArray(); 96 static void FillInTermScoreToTopicalityScoreArray();
98 97
99 // Returns a recency score based on |last_visit_days_ago|, which is 98 // Returns a recency score based on |last_visit_days_ago|, which is
100 // how many days ago the page was last visited. 99 // how many days ago the page was last visited.
101 static float GetRecencyScore(int last_visit_days_ago); 100 static float GetRecencyScore(int last_visit_days_ago);
102 101
103 // Pre-calculates days_ago_to_recency_numerator_, used in 102 // Pre-calculates days_ago_to_recency_numerator_, used in
104 // GetRecencyScore(). 103 // GetRecencyScore().
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 // matches) because if a non-inlineable match comes first than all matches 178 // matches) because if a non-inlineable match comes first than all matches
180 // will get demoted later in HistoryQuickProvider to non-inlineable scores. 179 // will get demoted later in HistoryQuickProvider to non-inlineable scores.
181 // Set to -1 to indicate no maximum score. 180 // Set to -1 to indicate no maximum score.
182 static int max_assigned_score_for_non_inlineable_matches_; 181 static int max_assigned_score_for_non_inlineable_matches_;
183 }; 182 };
184 typedef std::vector<ScoredHistoryMatch> ScoredHistoryMatches; 183 typedef std::vector<ScoredHistoryMatch> ScoredHistoryMatches;
185 184
186 } // namespace history 185 } // namespace history
187 186
188 #endif // CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_ 187 #endif // CHROME_BROWSER_HISTORY_SCORED_HISTORY_MATCH_H_
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/history_url_provider.cc ('k') | chrome/browser/history/scored_history_match.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698