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 30 matching lines...) Expand all Loading... |
41 #include "components/omnibox/browser/autocomplete_match.h" | 41 #include "components/omnibox/browser/autocomplete_match.h" |
42 #include "components/omnibox/browser/autocomplete_result.h" | 42 #include "components/omnibox/browser/autocomplete_result.h" |
43 #include "components/omnibox/browser/search_provider.h" | 43 #include "components/omnibox/browser/search_provider.h" |
44 #include "components/prefs/pref_service.h" | 44 #include "components/prefs/pref_service.h" |
45 #include "components/search/search.h" | 45 #include "components/search/search.h" |
46 #include "components/search_engines/template_url_service.h" | 46 #include "components/search_engines/template_url_service.h" |
47 #include "content/public/browser/navigation_controller.h" | 47 #include "content/public/browser/navigation_controller.h" |
48 #include "content/public/browser/navigation_entry.h" | 48 #include "content/public/browser/navigation_entry.h" |
49 #include "content/public/browser/web_contents.h" | 49 #include "content/public/browser/web_contents.h" |
50 #include "extensions/common/constants.h" | 50 #include "extensions/common/constants.h" |
| 51 #include "net/traffic_annotation/network_traffic_annotation.h" |
51 #include "third_party/skia/include/core/SkBitmap.h" | 52 #include "third_party/skia/include/core/SkBitmap.h" |
52 #include "ui/base/window_open_disposition.h" | 53 #include "ui/base/window_open_disposition.h" |
53 #include "url/gurl.h" | 54 #include "url/gurl.h" |
54 | 55 |
55 using predictors::AutocompleteActionPredictor; | 56 using predictors::AutocompleteActionPredictor; |
56 | 57 |
57 namespace { | 58 namespace { |
58 | 59 |
59 // Returns the AutocompleteMatch that the InstantController should prefetch, if | 60 // Returns the AutocompleteMatch that the InstantController should prefetch, if |
60 // any. | 61 // any. |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 } | 283 } |
283 | 284 |
284 const auto match = std::find_if( | 285 const auto match = std::find_if( |
285 result.begin(), result.end(), | 286 result.begin(), result.end(), |
286 [](const AutocompleteMatch& current) { return !!current.answer; }); | 287 [](const AutocompleteMatch& current) { return !!current.answer; }); |
287 if (match != result.end()) { | 288 if (match != result.end()) { |
288 BitmapFetcherService* image_service = | 289 BitmapFetcherService* image_service = |
289 BitmapFetcherServiceFactory::GetForBrowserContext(profile_); | 290 BitmapFetcherServiceFactory::GetForBrowserContext(profile_); |
290 if (image_service) { | 291 if (image_service) { |
291 image_service->CancelRequest(request_id_); | 292 image_service->CancelRequest(request_id_); |
| 293 net::NetworkTrafficAnnotationTag traffic_annotation = |
| 294 net::DefineNetworkTrafficAnnotation("", R"( |
| 295 semantics { |
| 296 sender: "" |
| 297 description: "" |
| 298 trigger: "" |
| 299 data: "" |
| 300 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER |
| 301 } |
| 302 policy { |
| 303 cookies_allowed: false/true |
| 304 cookies_store: "" |
| 305 setting: "" |
| 306 policy { |
| 307 [POLICY_NAME] { |
| 308 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} |
| 309 value: ... |
| 310 } |
| 311 } |
| 312 })"); |
292 request_id_ = image_service->RequestImage( | 313 request_id_ = image_service->RequestImage( |
293 match->answer->second_line().image_url(), | 314 match->answer->second_line().image_url(), |
294 new AnswerImageObserver( | 315 new AnswerImageObserver( |
295 base::Bind(&ChromeOmniboxClient::OnBitmapFetched, | 316 base::Bind(&ChromeOmniboxClient::OnBitmapFetched, |
296 base::Unretained(this), on_bitmap_fetched))); | 317 base::Unretained(this), on_bitmap_fetched)), |
| 318 traffic_annotation); |
297 } | 319 } |
298 } | 320 } |
299 } | 321 } |
300 | 322 |
301 void ChromeOmniboxClient::OnCurrentMatchChanged( | 323 void ChromeOmniboxClient::OnCurrentMatchChanged( |
302 const AutocompleteMatch& match) { | 324 const AutocompleteMatch& match) { |
303 if (!prerender::IsOmniboxEnabled(profile_)) | 325 if (!prerender::IsOmniboxEnabled(profile_)) |
304 DoPreconnect(match); | 326 DoPreconnect(match); |
305 } | 327 } |
306 | 328 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 InstantSearchPrerenderer::GetForProfile(profile_); | 475 InstantSearchPrerenderer::GetForProfile(profile_); |
454 if (prerenderer) | 476 if (prerenderer) |
455 prerenderer->Prerender(suggestion); | 477 prerenderer->Prerender(suggestion); |
456 } | 478 } |
457 | 479 |
458 void ChromeOmniboxClient::OnBitmapFetched(const BitmapFetchedCallback& callback, | 480 void ChromeOmniboxClient::OnBitmapFetched(const BitmapFetchedCallback& callback, |
459 const SkBitmap& bitmap) { | 481 const SkBitmap& bitmap) { |
460 request_id_ = BitmapFetcherService::REQUEST_ID_INVALID; | 482 request_id_ = BitmapFetcherService::REQUEST_ID_INVALID; |
461 callback.Run(bitmap); | 483 callback.Run(bitmap); |
462 } | 484 } |
OLD | NEW |