Chromium Code Reviews| Index: chrome/browser/autocomplete/history_url_provider.cc |
| diff --git a/chrome/browser/autocomplete/history_url_provider.cc b/chrome/browser/autocomplete/history_url_provider.cc |
| index b8581a09c9f26c5ff40c4c5605c6de768df346ed..2a15cf108be07a0867abd925f4f0a57c81f45c9a 100644 |
| --- a/chrome/browser/autocomplete/history_url_provider.cc |
| +++ b/chrome/browser/autocomplete/history_url_provider.cc |
| @@ -245,7 +245,8 @@ void HistoryURLProvider::DoAutocomplete(history::HistoryBackend* backend, |
| params->matches.push_back(what_you_typed_match); |
| } else if (params->prevent_inline_autocomplete || |
| history_matches.empty() || |
| - !PromoteMatchForInlineAutocomplete(params, history_matches.front())) { |
| + !PromoteMatchForInlineAutocomplete(params, history_matches.front(), |
| + history_matches)) { |
| // Failed to promote any URLs for inline autocompletion. Use the What You |
| // Typed match, if we have it. |
| first_match = 0; |
| @@ -268,8 +269,13 @@ void HistoryURLProvider::DoAutocomplete(history::HistoryBackend* backend, |
| DCHECK(!have_what_you_typed_match || |
| (match.url_info.url() != |
| GURL(params->matches.front().destination_url))); |
| - params->matches.push_back(HistoryMatchToACMatch(params, match, NORMAL, |
| - history_matches.size() - 1 - i)); |
| + // TODO(dominich): Should this be history_matches.size() - first_match - i? |
|
Peter Kasting
2011/08/09 20:53:00
No, it should not.
dominich
2011/08/09 21:43:43
Done.
|
| + AutocompleteMatch ac_match = |
| + HistoryMatchToACMatch(params, match, history_matches, NORMAL, |
| + history_matches.size() - 1 - i); |
| + UMA_HISTOGRAM_COUNTS_100("Autocomplete.Confidence_HistoryUrl", |
| + ac_match.confidence * 100); |
| + params->matches.push_back(ac_match); |
| } |
| } |
| @@ -302,9 +308,12 @@ void HistoryURLProvider::QueryComplete( |
| AutocompleteMatch HistoryURLProvider::SuggestExactInput( |
| const AutocompleteInput& input, |
| bool trim_http) { |
| + // TODO(dominich): Check that 100% confidence makes sense for exact input. |
|
Peter Kasting
2011/08/09 20:53:00
It doesn't. This will mean the what-you-typed mat
dominich
2011/08/09 21:43:43
You're mixing up the notion of rank and confidence
|
| AutocompleteMatch match(this, |
| - CalculateRelevance(input.type(), WHAT_YOU_TYPED, 0), false, |
| + CalculateRelevance(input.type(), WHAT_YOU_TYPED, 0), 1.0f, false, |
| AutocompleteMatch::URL_WHAT_YOU_TYPED); |
| + UMA_HISTOGRAM_COUNTS_100("Autocomplete.Confidence_HistoryUrl", |
| + match.confidence * 100); |
| const GURL& url = input.canonicalized_url(); |
| if (url.is_valid()) { |
| @@ -411,7 +420,8 @@ bool HistoryURLProvider::FixupExactSuggestion(history::URLDatabase* db, |
| bool HistoryURLProvider::PromoteMatchForInlineAutocomplete( |
| HistoryURLProviderParams* params, |
| - const HistoryMatch& match) { |
| + const HistoryMatch& match, |
| + const HistoryMatches& matches) { |
| // Promote the first match if it's been typed at least n times, where n == 1 |
| // for "simple" (host-only) URLs and n == 2 for others. We set a higher bar |
| // for these long URLs because it's less likely that users will want to visit |
| @@ -430,7 +440,7 @@ bool HistoryURLProvider::PromoteMatchForInlineAutocomplete( |
| // there's no way to know about "foo/", make reaching this point prevent any |
| // future pass from suggesting the exact input as a better match. |
| params->dont_suggest_exact_input = true; |
| - params->matches.push_back(HistoryMatchToACMatch(params, match, |
| + params->matches.push_back(HistoryMatchToACMatch(params, match, matches, |
| INLINE_AUTOCOMPLETE, 0)); |
| return true; |
| } |
| @@ -471,6 +481,22 @@ int HistoryURLProvider::CalculateRelevance(AutocompleteInput::Type input_type, |
| } |
| // static |
| +float HistoryURLProvider::CalculateConfidence( |
| + const history::HistoryMatch& match, |
| + const history::HistoryMatches& matches) { |
| + // TODO(dominich): Take into account typed count? |
|
Peter Kasting
2011/08/09 20:53:00
See comments in HCP for why typed_count is better
dominich
2011/08/09 21:43:43
It looks like CompareHistoryMatch is a good starti
|
| + // TODO(dominich): Take into account bookmarked page? |
| + float numerator = match.url_info.visit_count(); |
| + float denominator = 0.0f; |
| + for (history::HistoryMatches::const_iterator it = matches.begin(); |
| + it != matches.end(); ++it) { |
|
Peter Kasting
2011/08/09 20:53:00
Nit: No need for {}
dominich
2011/08/09 21:43:43
See comment on HCP as to why I prefer to keep this
|
| + denominator += it->url_info.visit_count(); |
| + } |
| + DCHECK(denominator > 0); |
| + return numerator / denominator; |
| +} |
| + |
| +// static |
| void HistoryURLProvider::PromoteOrCreateShorterSuggestion( |
| history::URLDatabase* db, |
| const HistoryURLProviderParams& params, |
| @@ -774,11 +800,13 @@ size_t HistoryURLProvider::RemoveSubsequentMatchesOf( |
| AutocompleteMatch HistoryURLProvider::HistoryMatchToACMatch( |
| HistoryURLProviderParams* params, |
| const HistoryMatch& history_match, |
| + const HistoryMatches& history_matches, |
| MatchType match_type, |
| size_t match_number) { |
| const history::URLRow& info = history_match.url_info; |
| AutocompleteMatch match(this, |
| CalculateRelevance(params->input.type(), match_type, match_number), |
| + CalculateConfidence(history_match, history_matches), |
| !!info.visit_count(), AutocompleteMatch::HISTORY_URL); |
| match.destination_url = info.url(); |
| DCHECK(match.destination_url.is_valid()); |