OLD | NEW |
---|---|
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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 // we think the likelihood of the user selecting them is low enough that | 46 // we think the likelihood of the user selecting them is low enough that |
47 // prefetching isn't worth doing. | 47 // prefetching isn't worth doing. |
48 const AutocompleteMatch* GetMatchToPrefetch(const AutocompleteResult& result) { | 48 const AutocompleteMatch* GetMatchToPrefetch(const AutocompleteResult& result) { |
49 if (chrome::ShouldAllowPrefetchNonDefaultMatch()) { | 49 if (chrome::ShouldAllowPrefetchNonDefaultMatch()) { |
50 const AutocompleteResult::const_iterator prefetch_match = std::find_if( | 50 const AutocompleteResult::const_iterator prefetch_match = std::find_if( |
51 result.begin(), result.end(), SearchProvider::ShouldPrefetch); | 51 result.begin(), result.end(), SearchProvider::ShouldPrefetch); |
52 return prefetch_match != result.end() ? &(*prefetch_match) : NULL; | 52 return prefetch_match != result.end() ? &(*prefetch_match) : NULL; |
53 } | 53 } |
54 | 54 |
55 // If the default match should be prefetched, do that. | 55 // If the default match should be prefetched, do that. |
56 const AutocompleteResult::const_iterator default_match( | 56 const AutocompleteResult::const_iterator default_match( |
groby-ooo-7-16
2015/05/27 19:25:51
While we're here - is there any reason to copy-con
| |
57 result.default_match()); | 57 result.default_match()); |
58 if ((default_match != result.end()) && | 58 if ((default_match != result.end()) && |
59 SearchProvider::ShouldPrefetch(*default_match)) | 59 SearchProvider::ShouldPrefetch(*default_match)) |
60 return &(*default_match); | 60 return &(*default_match); |
61 | 61 |
62 // Otherwise, if the top match is a verbatim match and the very next match | |
63 // is prefetchable, fetch that. | |
64 if ((result.ShouldHideTopMatch() || | |
groby-ooo-7-16
2015/05/27 19:25:51
I suppose the question here is, does the RHS of th
dschuyler
2015/05/28 18:58:05
It sounds like it's not used in instant.
| |
65 result.TopMatchIsStandaloneVerbatimMatch()) && | |
66 (result.size() > 1) && | |
67 SearchProvider::ShouldPrefetch(result.match_at(1))) | |
68 return &result.match_at(1); | |
69 | |
70 return NULL; | 62 return NULL; |
71 } | 63 } |
72 | 64 |
73 // Calls back to the OmniboxController when the requested image is downloaded. | 65 // Calls back to the OmniboxController when the requested image is downloaded. |
74 // This is a separate class instead of being implemented on OmniboxController | 66 // This is a separate class instead of being implemented on OmniboxController |
75 // because BitmapFetcherService currently takes ownership of this object. | 67 // because BitmapFetcherService currently takes ownership of this object. |
76 // TODO(dschuyler): Make BitmapFetcherService use the more typical non-owning | 68 // TODO(dschuyler): Make BitmapFetcherService use the more typical non-owning |
77 // ObserverList pattern and have OmniboxController implement the Observer call | 69 // ObserverList pattern and have OmniboxController implement the Observer call |
78 // directly. | 70 // directly. |
79 class AnswerImageObserver : public BitmapFetcherService::Observer { | 71 class AnswerImageObserver : public BitmapFetcherService::Observer { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 // We could prefetch the alternate nav URL, if any, but because there | 206 // 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, | 207 // 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. | 208 // the OS DNS cache could suffer eviction problems for minimal gain. |
217 } | 209 } |
218 } | 210 } |
219 | 211 |
220 void OmniboxController::SetAnswerBitmap(const SkBitmap& bitmap) { | 212 void OmniboxController::SetAnswerBitmap(const SkBitmap& bitmap) { |
221 request_id_ = BitmapFetcherService::REQUEST_ID_INVALID; | 213 request_id_ = BitmapFetcherService::REQUEST_ID_INVALID; |
222 popup_->SetAnswerBitmap(bitmap); | 214 popup_->SetAnswerBitmap(bitmap); |
223 } | 215 } |
OLD | NEW |