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

Side by Side Diff: chrome/browser/ui/omnibox/omnibox_controller.cc

Issue 1154063003: removing ShouldHideTopMatch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review changes Created 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "chrome/browser/ui/omnibox/omnibox_controller.h" 5 #include "chrome/browser/ui/omnibox/omnibox_controller.h"
6 6
7 #include "base/metrics/histogram.h" 7 #include "base/metrics/histogram.h"
8 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 8 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
9 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service_factory.h" 9 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service_factory.h"
10 #include "chrome/browser/net/predictor.h" 10 #include "chrome/browser/net/predictor.h"
(...skipping 21 matching lines...) Expand all
32 // Returns the AutocompleteMatch that the InstantController should prefetch, if 32 // Returns the AutocompleteMatch that the InstantController should prefetch, if
33 // any. 33 // any.
34 // 34 //
35 // The SearchProvider may mark some suggestions to be prefetched based on 35 // The SearchProvider may mark some suggestions to be prefetched based on
36 // instructions from the suggest server. If such a match ranks sufficiently 36 // instructions from the suggest server. If such a match ranks sufficiently
37 // highly or if kAllowPrefetchNonDefaultMatch field trial is enabled, we'll 37 // highly or if kAllowPrefetchNonDefaultMatch field trial is enabled, we'll
38 // return it. 38 // return it.
39 // 39 //
40 // If the kAllowPrefetchNonDefaultMatch field trial is enabled we return the 40 // If the kAllowPrefetchNonDefaultMatch field trial is enabled we return the
41 // prefetch suggestion even if it is not the default match. Otherwise we only 41 // prefetch suggestion even if it is not the default match. Otherwise we only
42 // care about matches that are the default or the very first entry in the 42 // care about matches that are the default; for other matches, we think the
43 // dropdown (which can happen for non-default matches only if we're hiding a top 43 // likelihood of the user selecting them is low enough that prefetching isn't
44 // verbatim match) or the second entry in the dropdown (which can happen for 44 // worth doing.
45 // non-default matches when a top verbatim match is shown); for other matches,
46 // we think the likelihood of the user selecting them is low enough that
47 // prefetching isn't worth doing.
48 const AutocompleteMatch* GetMatchToPrefetch(const AutocompleteResult& result) { 45 const AutocompleteMatch* GetMatchToPrefetch(const AutocompleteResult& result) {
49 if (chrome::ShouldAllowPrefetchNonDefaultMatch()) { 46 if (chrome::ShouldAllowPrefetchNonDefaultMatch()) {
50 const AutocompleteResult::const_iterator prefetch_match = std::find_if( 47 const AutocompleteResult::const_iterator prefetch_match = std::find_if(
51 result.begin(), result.end(), SearchProvider::ShouldPrefetch); 48 result.begin(), result.end(), SearchProvider::ShouldPrefetch);
52 return prefetch_match != result.end() ? &(*prefetch_match) : NULL; 49 return prefetch_match != result.end() ? &(*prefetch_match) : NULL;
53 } 50 }
54 51
55 // If the default match should be prefetched, do that. 52 // If the default match should be prefetched, do that.
56 const AutocompleteResult::const_iterator default_match( 53 const auto default_match = result.default_match();
57 result.default_match());
58 if ((default_match != result.end()) && 54 if ((default_match != result.end()) &&
59 SearchProvider::ShouldPrefetch(*default_match)) 55 SearchProvider::ShouldPrefetch(*default_match))
60 return &(*default_match); 56 return &(*default_match);
61 57
62 // Otherwise, if the top match is a verbatim match and the very next match
Mark P 2015/06/01 19:23:02 I don't understand why you're removing this block.
Peter Kasting 2015/06/01 20:18:01 kmadhusu said the TopMatchIsStandaloneVerbatimMatc
kmadhusu 2015/06/01 20:24:32 pkasting@, I am assuming default match is always t
Peter Kasting 2015/06/01 20:26:57 Default match is always top match. What removing
kmadhusu 2015/06/01 20:37:21 I see. Thanks for the details. I think we need thi
dschuyler 2015/06/05 20:33:54 Thanks for going over that! Done.
63 // is prefetchable, fetch that.
64 if ((result.ShouldHideTopMatch() ||
65 result.TopMatchIsStandaloneVerbatimMatch()) &&
66 (result.size() > 1) &&
67 SearchProvider::ShouldPrefetch(result.match_at(1)))
68 return &result.match_at(1);
69
70 return NULL; 58 return NULL;
71 } 59 }
72 60
73 // Calls back to the OmniboxController when the requested image is downloaded. 61 // Calls back to the OmniboxController when the requested image is downloaded.
74 // This is a separate class instead of being implemented on OmniboxController 62 // This is a separate class instead of being implemented on OmniboxController
75 // because BitmapFetcherService currently takes ownership of this object. 63 // because BitmapFetcherService currently takes ownership of this object.
76 // TODO(dschuyler): Make BitmapFetcherService use the more typical non-owning 64 // TODO(dschuyler): Make BitmapFetcherService use the more typical non-owning
77 // ObserverList pattern and have OmniboxController implement the Observer call 65 // ObserverList pattern and have OmniboxController implement the Observer call
78 // directly. 66 // directly.
79 class AnswerImageObserver : public BitmapFetcherService::Observer { 67 class AnswerImageObserver : public BitmapFetcherService::Observer {
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 // We could prefetch the alternate nav URL, if any, but because there 202 // We could prefetch the alternate nav URL, if any, but because there
215 // can be many of these as a user types an initial series of characters, 203 // can be many of these as a user types an initial series of characters,
216 // the OS DNS cache could suffer eviction problems for minimal gain. 204 // the OS DNS cache could suffer eviction problems for minimal gain.
217 } 205 }
218 } 206 }
219 207
220 void OmniboxController::SetAnswerBitmap(const SkBitmap& bitmap) { 208 void OmniboxController::SetAnswerBitmap(const SkBitmap& bitmap) {
221 request_id_ = BitmapFetcherService::REQUEST_ID_INVALID; 209 request_id_ = BitmapFetcherService::REQUEST_ID_INVALID;
222 popup_->SetAnswerBitmap(bitmap); 210 popup_->SetAnswerBitmap(bitmap);
223 } 211 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698