Chromium Code Reviews| Index: chrome/browser/autocomplete/network_action_predictor.cc |
| diff --git a/chrome/browser/autocomplete/network_action_predictor.cc b/chrome/browser/autocomplete/network_action_predictor.cc |
| index 848feeb5b84cf1064b8df75bb19ab480c5151477..68d5f509b4b3dc0794efb8472ca98691eaac56e7 100644 |
| --- a/chrome/browser/autocomplete/network_action_predictor.cc |
| +++ b/chrome/browser/autocomplete/network_action_predictor.cc |
| @@ -56,6 +56,22 @@ bool GetURLRowForAutocompleteMatch(Profile* profile, |
| return url_db && (url_db->GetRowForURL(match.destination_url, url_row) != 0); |
| } |
| +// Return true if the suggestion type is a 'search' type. |
| +bool IsSearchType(const AutocompleteMatch::Type& type) { |
|
Peter Kasting
2012/01/09 20:47:37
Nit: I wonder if this is consistent with other pla
dominich
2012/01/09 22:43:43
Hmm. On the other side of this, when we swap in th
Peter Kasting
2012/01/09 22:51:30
In the abstract, yes; the fact that we have many o
|
| + switch (type) { |
| + // Matches using the user's default search engine. |
| + case AutocompleteMatch::SEARCH_WHAT_YOU_TYPED: |
| + case AutocompleteMatch::SEARCH_HISTORY: |
| + case AutocompleteMatch::SEARCH_SUGGEST: |
| + // A match that uses a non-default search engine (e.g. for tab-to-search). |
|
Peter Kasting
2012/01/09 20:47:37
Nit: Unindent 2.
dominich
2012/01/09 22:43:43
Done.
|
| + case AutocompleteMatch::SEARCH_OTHER_ENGINE: |
| + return true; |
| + |
| + default: |
| + return false; |
| + } |
| +} |
| + |
| } |
| const int NetworkActionPredictor::kMaximumDaysToKeepEntry = 14; |
| @@ -150,10 +166,7 @@ NetworkActionPredictor::Action NetworkActionPredictor::RecommendAction( |
| // Downgrade prerender to preconnect if this is a search match or if omnibox |
| // prerendering is disabled. |
| if (action == ACTION_PRERENDER && |
| - ((match.type == AutocompleteMatch::SEARCH_WHAT_YOU_TYPED || |
| - match.type == AutocompleteMatch::SEARCH_SUGGEST || |
| - match.type == AutocompleteMatch::SEARCH_OTHER_ENGINE) || |
| - !prerender::IsOmniboxEnabled(profile_))) { |
| + (IsPreconnectable(match) || !prerender::IsOmniboxEnabled(profile_))) { |
| action = ACTION_PRECONNECT; |
| } |
| @@ -164,18 +177,7 @@ NetworkActionPredictor::Action NetworkActionPredictor::RecommendAction( |
| // i.e., it is now quite likely that the user will select the related domain. |
| // static |
| bool NetworkActionPredictor::IsPreconnectable(const AutocompleteMatch& match) { |
| - switch (match.type) { |
| - // Matches using the user's default search engine. |
| - case AutocompleteMatch::SEARCH_WHAT_YOU_TYPED: |
| - case AutocompleteMatch::SEARCH_HISTORY: |
| - case AutocompleteMatch::SEARCH_SUGGEST: |
| - // A match that uses a non-default search engine (e.g. for tab-to-search). |
| - case AutocompleteMatch::SEARCH_OTHER_ENGINE: |
| - return true; |
| - |
| - default: |
| - return false; |
| - } |
| + return IsSearchType(match.type); |
| } |
| void NetworkActionPredictor::Shutdown() { |
| @@ -231,10 +233,12 @@ void NetworkActionPredictor::OnOmniboxOpenedUrl(const AutocompleteLog& log) { |
| if (log.text.length() < kMinimumUserTextLength) |
| return; |
| - UMA_HISTOGRAM_COUNTS("NetworkActionPredictor.NavigationCount", 1); |
| + const AutocompleteMatch& match = log.result.match_at(log.selected_index); |
| + |
| + UMA_HISTOGRAM_BOOLEAN("Prerender.OmniboxNavigationsCouldPrerender", |
| + prerender::IsOmniboxEnabled(profile_) && !IsSearchType(match.type)); |
| - const GURL& opened_url = |
| - log.result.match_at(log.selected_index).destination_url; |
| + const GURL& opened_url = match.destination_url; |
| const string16 lower_user_text(base::i18n::ToLower(log.text)); |