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

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

Issue 2682263002: Network traffic annotation added to chrome::BitmapFetcher. (Closed)
Patch Set: nits 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 // TODO(jdonnelly, rhalavati): Create a helper function with Callback to
295 // create annotation and pass it to image_service, merging this annotation
296 // and the one in
297 // chrome/browser/autocomplete/chrome_autocomplete_provider_client.cc
298 net::NetworkTrafficAnnotationTag traffic_annotation =
299 net::DefineNetworkTrafficAnnotation("omnibox_result_change", R"(
300 semantics {
301 sender: "Omnibox"
302 description:
303 "Chromium provides answers in the suggestion list for "
304 "certain queries that user types in the omnibox. This request "
305 "retrieves a small image (for example, an icon illustrating "
306 "the current weather conditions) when this can add information "
307 "to an answer."
308 trigger:
309 "Change of results for the query typed by the user in the "
310 "omnibox."
311 data:
312 "The only data sent is the path to an image. No user data is "
313 "included, although some might be inferrable (e.g. whether the "
314 "weather is sunny or rainy in the user's current location) "
315 "from the name of the image in the path."
316 destination: WEBSITE
317 }
318 policy {
319 cookies_allowed: true
320 cookies_store: "user"
321 setting:
322 "You can enable or disable this feature via 'Use a prediction "
323 "service to help complete searches and URLs typed in the "
324 "address bar.' in Chromium's settings under Advanced. The "
325 "feature is enabled by default."
326 policy {
327 SearchSuggestEnabled {
328 policy_options {mode: MANDATORY}
329 value: false
330 }
331 }
332 })");
333
292 request_id_ = image_service->RequestImage( 334 request_id_ = image_service->RequestImage(
293 match->answer->second_line().image_url(), 335 match->answer->second_line().image_url(),
294 new AnswerImageObserver( 336 new AnswerImageObserver(
295 base::Bind(&ChromeOmniboxClient::OnBitmapFetched, 337 base::Bind(&ChromeOmniboxClient::OnBitmapFetched,
296 base::Unretained(this), on_bitmap_fetched))); 338 base::Unretained(this), on_bitmap_fetched)),
339 traffic_annotation);
297 } 340 }
298 } 341 }
299 } 342 }
300 343
301 void ChromeOmniboxClient::OnCurrentMatchChanged( 344 void ChromeOmniboxClient::OnCurrentMatchChanged(
302 const AutocompleteMatch& match) { 345 const AutocompleteMatch& match) {
303 if (!prerender::IsOmniboxEnabled(profile_)) 346 if (!prerender::IsOmniboxEnabled(profile_))
304 DoPreconnect(match); 347 DoPreconnect(match);
305 } 348 }
306 349
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 InstantSearchPrerenderer::GetForProfile(profile_); 496 InstantSearchPrerenderer::GetForProfile(profile_);
454 if (prerenderer) 497 if (prerenderer)
455 prerenderer->Prerender(suggestion); 498 prerenderer->Prerender(suggestion);
456 } 499 }
457 500
458 void ChromeOmniboxClient::OnBitmapFetched(const BitmapFetchedCallback& callback, 501 void ChromeOmniboxClient::OnBitmapFetched(const BitmapFetchedCallback& callback,
459 const SkBitmap& bitmap) { 502 const SkBitmap& bitmap) {
460 request_id_ = BitmapFetcherService::REQUEST_ID_INVALID; 503 request_id_ = BitmapFetcherService::REQUEST_ID_INVALID;
461 callback.Run(bitmap); 504 callback.Run(bitmap);
462 } 505 }
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