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

Unified Diff: chrome/browser/ui/omnibox/omnibox_controller.cc

Issue 324273004: Allow non default prefetch suggestions to be prefetched (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/omnibox/omnibox_controller.cc
diff --git a/chrome/browser/ui/omnibox/omnibox_controller.cc b/chrome/browser/ui/omnibox/omnibox_controller.cc
index 29d27d7e01d42b142f9e723ed68754e68b31e732..0db08853e017dce0d0ee9cbd5ca69d3b89be4b43 100644
--- a/chrome/browser/ui/omnibox/omnibox_controller.cc
+++ b/chrome/browser/ui/omnibox/omnibox_controller.cc
@@ -30,30 +30,39 @@ namespace {
//
// The SearchProvider may mark some suggestions to be prefetched based on
// instructions from the suggest server. If such a match ranks sufficiently
-// highly, we'll return it.
+// highly or if allow_prefetch_non_default_match field trial is enabled, we'll
+// return it.
//
-// We only care about matches that are the default or the very first entry in
-// the dropdown (which can happen for non-default matches only if we're hiding
-// a top verbatim match) or the second entry in the dropdown (which can happen
-// for non-default matches when a top verbatim match is shown); for other
-// matches, we think the likelihood of the user selecting them is low enough
-// that prefetching isn't worth doing.
+// If the allow_prefetch_non_default_match field trial is enabled we return the
kmadhusu 2014/06/18 17:07:38 s/allow_prefetch_.../kAllowPrefetchNonDefaultMatch
sidharthms 2014/06/18 22:45:22 Done.
+// prefetch suggestion even if it is not the default match. Otherwise we only
+// care about matches that are the default or the very first entry in the
+// dropdown (which can happen for non-default matches only if we're hiding a top
+// verbatim match) or the second entry in the dropdown (which can happen for
+// non-default matches when a top verbatim match is shown); for other matches,
+// we think the likelihood of the user selecting them is low enough that
+// prefetching isn't worth doing.
const AutocompleteMatch* GetMatchToPrefetch(const AutocompleteResult& result) {
- // If the default match should be prefetched, do that.
- const AutocompleteResult::const_iterator default_match(
- result.default_match());
- if ((default_match != result.end()) &&
- SearchProvider::ShouldPrefetch(*default_match))
- return &(*default_match);
-
- // Otherwise, if the top match is a verbatim match and the very next match is
- // prefetchable, fetch that.
- if ((result.ShouldHideTopMatch() ||
- result.TopMatchIsStandaloneVerbatimMatch()) &&
- (result.size() > 1) &&
- SearchProvider::ShouldPrefetch(result.match_at(1)))
- return &result.match_at(1);
-
+ if (chrome::ShouldAllowPrefetchNonDefaultMatch()) {
+ const AutocompleteResult::const_iterator prefetch_match = std::find_if(
+ result.begin(), result.end(), SearchProvider::ShouldPrefetch);
+ if (prefetch_match != result.end())
kmadhusu 2014/06/18 17:07:38 nit: You can use a ternary operator here and remov
sidharthms 2014/06/18 22:45:22 Done.
+ return &(*prefetch_match);
kmadhusu 2014/06/18 17:07:38 As you said yesterday, when we type "ya" we are su
sidharthms 2014/06/18 22:45:22 Done.
+ } else {
+ // If the default match should be prefetched, do that.
+ const AutocompleteResult::const_iterator default_match(
+ result.default_match());
+ if ((default_match != result.end()) &&
+ SearchProvider::ShouldPrefetch(*default_match))
+ return &(*default_match);
+
+ // Otherwise, if the top match is a verbatim match and the very next match
+ // is prefetchable, fetch that.
+ if ((result.ShouldHideTopMatch() ||
+ result.TopMatchIsStandaloneVerbatimMatch()) &&
+ (result.size() > 1) &&
+ SearchProvider::ShouldPrefetch(result.match_at(1)))
+ return &result.match_at(1);
+ }
return NULL;
}
« chrome/browser/search/search_unittest.cc ('K') | « chrome/browser/search/search_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698