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

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

Issue 2682263002: Network traffic annotation added to chrome::BitmapFetcher. (Closed)
Patch Set: Annotations updated. Created 3 years, 10 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/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
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
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
294 // If you cheange this, please also update annotation:
295 DCHECK(...);
Ramin Halavati 2017/02/15 11:52:03 Can we have a simple check here to ensure that Goo
Justin Donnelly 2017/02/15 21:39:44 We have no control over whether and when other Sug
Ramin Halavati 2017/02/16 07:03:30 Done.
296
297 net::NetworkTrafficAnnotationTag traffic_annotation =
298 net::DefineNetworkTrafficAnnotation("omnibox_result_change", R"(
299 semantics {
300 sender: "Omnibox Suggest"
301 description:
302 "The Google Chrome provides answers in the suggestion list to "
Justin Donnelly 2017/02/15 21:39:44 Remove "The".
Ramin Halavati 2017/02/16 07:03:30 Done.
303 "the queries you type in the omnibox. This request retrieves a "
304 "small image (for example, an icon illustrating the current "
305 "weather conditions) when this can add information to the "
306 "answer."
307 trigger:
308 "Change of results for the query typed by the user in the "
309 "omnibox."
310 data:
311 "The only data sent is the path to an image. No user data is "
312 "included, although the general weather condition (sunny, "
313 "rainy, etc.) in the user's current location could be inferred "
314 "from the name of the image in the path."
315 destination: GOOGLE_OWNED_SERVICE
316 }
317 policy {
318 cookies_allowed: false
319 cookies_store: ""
320 setting:
321 "You can enable or disable this feature via 'Use a prediction "
322 "service to help complete searches and URLs typed in the "
323 "address bar.' in Chrome's settings under Advanced. The "
324 "feature is enabled by default."
325 policy {
326 SearchSuggestEnabled {
327 policy_options {mode: MANDATORY}
328 value: false
329 }
330 }
331 })");
332
292 request_id_ = image_service->RequestImage( 333 request_id_ = image_service->RequestImage(
293 match->answer->second_line().image_url(), 334 match->answer->second_line().image_url(),
294 new AnswerImageObserver( 335 new AnswerImageObserver(
295 base::Bind(&ChromeOmniboxClient::OnBitmapFetched, 336 base::Bind(&ChromeOmniboxClient::OnBitmapFetched,
296 base::Unretained(this), on_bitmap_fetched))); 337 base::Unretained(this), on_bitmap_fetched)),
338 traffic_annotation);
297 } 339 }
298 } 340 }
299 } 341 }
300 342
301 void ChromeOmniboxClient::OnCurrentMatchChanged( 343 void ChromeOmniboxClient::OnCurrentMatchChanged(
302 const AutocompleteMatch& match) { 344 const AutocompleteMatch& match) {
303 if (!prerender::IsOmniboxEnabled(profile_)) 345 if (!prerender::IsOmniboxEnabled(profile_))
304 DoPreconnect(match); 346 DoPreconnect(match);
305 } 347 }
306 348
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 InstantSearchPrerenderer::GetForProfile(profile_); 495 InstantSearchPrerenderer::GetForProfile(profile_);
454 if (prerenderer) 496 if (prerenderer)
455 prerenderer->Prerender(suggestion); 497 prerenderer->Prerender(suggestion);
456 } 498 }
457 499
458 void ChromeOmniboxClient::OnBitmapFetched(const BitmapFetchedCallback& callback, 500 void ChromeOmniboxClient::OnBitmapFetched(const BitmapFetchedCallback& callback,
459 const SkBitmap& bitmap) { 501 const SkBitmap& bitmap) {
460 request_id_ = BitmapFetcherService::REQUEST_ID_INVALID; 502 request_id_ = BitmapFetcherService::REQUEST_ID_INVALID;
461 callback.Run(bitmap); 503 callback.Run(bitmap);
462 } 504 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_avatar_downloader.cc ('k') | chrome/browser/ui/passwords/account_avatar_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698