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

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

Issue 69703002: Modified GetMatchToPrefetch() to return a valid match for prefetching even when hide_verbatim flag i (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments 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 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/autocomplete/autocomplete_match.h" 9 #include "chrome/browser/autocomplete/autocomplete_match.h"
10 #include "chrome/browser/autocomplete/search_provider.h" 10 #include "chrome/browser/autocomplete/search_provider.h"
(...skipping 13 matching lines...) Expand all
24 #include "extensions/common/constants.h" 24 #include "extensions/common/constants.h"
25 #include "ui/gfx/rect.h" 25 #include "ui/gfx/rect.h"
26 26
27 namespace { 27 namespace {
28 28
29 // Returns the AutocompleteMatch that the InstantController should prefetch, if 29 // Returns the AutocompleteMatch that the InstantController should prefetch, if
30 // any. 30 // any.
31 // 31 //
32 // The SearchProvider may mark some suggestions to be prefetched based on 32 // The SearchProvider may mark some suggestions to be prefetched based on
33 // instructions from the suggest server. If such a match ranks sufficiently 33 // instructions from the suggest server. If such a match ranks sufficiently
34 // highly, we'll return it. We only care about matches that are the default or 34 // highly, we'll return it.
35 // else the very first entry in the dropdown (which can happen for non-default 35 //
36 // matches only if we're hiding a top verbatim match); for other matches, we 36 // We only care about matches that are the default or the very first entry in
37 // think the likelihood of the user selecting them is low enough that 37 // the dropdown (which can happen for non-default matches only if we're hiding
38 // prefetching isn't worth doing. 38 // a top verbatim match) or the second entry in the dropdown (which can happen
39 // for non-default matches when a top verbatim match is shown); for other
40 // matches, we think the likelihood of the user selecting them is low enough
41 // that prefetching isn't worth doing.
39 const AutocompleteMatch* GetMatchToPrefetch(const AutocompleteResult& result) { 42 const AutocompleteMatch* GetMatchToPrefetch(const AutocompleteResult& result) {
40 const AutocompleteResult::const_iterator default_match( 43 const AutocompleteResult::const_iterator default_match(
41 result.default_match()); 44 result.default_match());
42 if (default_match == result.end()) 45 if (default_match == result.end())
43 return NULL; 46 return NULL;
44 47
45 if (SearchProvider::ShouldPrefetch(*default_match)) 48 if (SearchProvider::ShouldPrefetch(*default_match))
46 return &(*default_match); 49 return &(*default_match);
47 50
48 return (result.ShouldHideTopMatch() && (result.size() > 1) && 51 return ((result.ShouldHideTopMatch() ||
49 SearchProvider::ShouldPrefetch(result.match_at(1))) ? 52 result.TopMatchIsVerbatimAndHasNoConsecutiveVerbatimMatches()) &&
50 &result.match_at(1) : NULL; 53 (result.size() > 1) &&
54 SearchProvider::ShouldPrefetch(result.match_at(1))) ?
55 &result.match_at(1) : NULL;
Peter Kasting 2013/12/17 23:47:34 Nit: Indenting here is inconsistent; sometimes you
kmadhusu 2013/12/18 23:26:08 Fixed indentation.
51 } 56 }
52 57
53 } // namespace 58 } // namespace
54 59
55 OmniboxController::OmniboxController(OmniboxEditModel* omnibox_edit_model, 60 OmniboxController::OmniboxController(OmniboxEditModel* omnibox_edit_model,
56 Profile* profile) 61 Profile* profile)
57 : omnibox_edit_model_(omnibox_edit_model), 62 : omnibox_edit_model_(omnibox_edit_model),
58 profile_(profile), 63 profile_(profile),
59 popup_(NULL), 64 popup_(NULL),
60 autocomplete_controller_(new AutocompleteController(profile, this, 65 autocomplete_controller_(new AutocompleteController(profile, this,
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 if (profile_->GetNetworkPredictor()) { 152 if (profile_->GetNetworkPredictor()) {
148 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl( 153 profile_->GetNetworkPredictor()->AnticipateOmniboxUrl(
149 match.destination_url, 154 match.destination_url,
150 predictors::AutocompleteActionPredictor::IsPreconnectable(match)); 155 predictors::AutocompleteActionPredictor::IsPreconnectable(match));
151 } 156 }
152 // We could prefetch the alternate nav URL, if any, but because there 157 // We could prefetch the alternate nav URL, if any, but because there
153 // can be many of these as a user types an initial series of characters, 158 // can be many of these as a user types an initial series of characters,
154 // the OS DNS cache could suffer eviction problems for minimal gain. 159 // the OS DNS cache could suffer eviction problems for minimal gain.
155 } 160 }
156 } 161 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698