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/chrome_omnibox_client.h" | 5 #include "chrome/browser/ui/omnibox/chrome_omnibox_client.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 SearchProvider::GetSuggestMetadata(*match_to_prefetch); | 283 SearchProvider::GetSuggestMetadata(*match_to_prefetch); |
284 } | 284 } |
285 // Send the prefetch suggestion unconditionally to the InstantPage. If | 285 // Send the prefetch suggestion unconditionally to the InstantPage. If |
286 // there is no suggestion to prefetch, we need to send a blank query to | 286 // there is no suggestion to prefetch, we need to send a blank query to |
287 // clear the prefetched results. | 287 // clear the prefetched results. |
288 SetSuggestionToPrefetch(prefetch_suggestion); | 288 SetSuggestionToPrefetch(prefetch_suggestion); |
289 } | 289 } |
290 | 290 |
291 const auto match = std::find_if( | 291 const auto match = std::find_if( |
292 result.begin(), result.end(), | 292 result.begin(), result.end(), |
293 [](const AutocompleteMatch& current)->bool { return current.answer; }); | 293 [](const AutocompleteMatch& current) { return !!current.answer; }); |
294 if (match != result.end()) { | 294 if (match != result.end()) { |
295 BitmapFetcherService* image_service = | 295 BitmapFetcherService* image_service = |
296 BitmapFetcherServiceFactory::GetForBrowserContext(profile_); | 296 BitmapFetcherServiceFactory::GetForBrowserContext(profile_); |
297 if (image_service) { | 297 if (image_service) { |
298 image_service->CancelRequest(request_id_); | 298 image_service->CancelRequest(request_id_); |
299 request_id_ = image_service->RequestImage( | 299 request_id_ = image_service->RequestImage( |
300 match->answer->second_line().image_url(), | 300 match->answer->second_line().image_url(), |
301 new AnswerImageObserver( | 301 new AnswerImageObserver( |
302 base::Bind(&ChromeOmniboxClient::OnBitmapFetched, | 302 base::Bind(&ChromeOmniboxClient::OnBitmapFetched, |
303 base::Unretained(this), on_bitmap_fetched))); | 303 base::Unretained(this), on_bitmap_fetched))); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 if (prerenderer) | 469 if (prerenderer) |
470 prerenderer->Prerender(suggestion); | 470 prerenderer->Prerender(suggestion); |
471 } | 471 } |
472 } | 472 } |
473 | 473 |
474 void ChromeOmniboxClient::OnBitmapFetched(const BitmapFetchedCallback& callback, | 474 void ChromeOmniboxClient::OnBitmapFetched(const BitmapFetchedCallback& callback, |
475 const SkBitmap& bitmap) { | 475 const SkBitmap& bitmap) { |
476 request_id_ = BitmapFetcherService::REQUEST_ID_INVALID; | 476 request_id_ = BitmapFetcherService::REQUEST_ID_INVALID; |
477 callback.Run(bitmap); | 477 callback.Run(bitmap); |
478 } | 478 } |
OLD | NEW |