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: "" | |
Justin Donnelly
2017/02/14 17:01:05
suggest (Alternatively, "omnibox" if a more genera
Ramin Halavati
2017/02/15 11:52:03
Done.
| |
297 description: "" | |
Justin Donnelly
2017/02/14 17:01:05
Google Chrome provides answers in the suggestion l
Ramin Halavati
2017/02/15 11:52:03
Done.
| |
298 trigger: "" | |
Justin Donnelly
2017/02/14 17:01:05
Query typed by the user in the omnibox.
Ramin Halavati
2017/02/15 11:52:03
Done.
| |
299 data: "" | |
Justin Donnelly
2017/02/14 17:01:05
The only data sent is the path to an image. No use
Ramin Halavati
2017/02/15 11:52:03
Done.
| |
300 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER | |
Justin Donnelly
2017/02/14 17:01:05
Yeah, this is a tough one. Currently, no search en
Ramin Halavati
2017/02/15 11:52:03
Can we add a DCHECK to insure that Google owned se
Justin Donnelly
2017/02/15 21:39:44
Response in other comment.
Ramin Halavati
2017/02/16 07:03:30
Done.
| |
301 } | |
302 policy { | |
303 cookies_allowed: false/true | |
Justin Donnelly
2017/02/14 17:01:05
false (requests are to ssl.gstatic.com)
Ramin Halavati
2017/02/15 11:52:03
I wonder as the default URLFetcher allows to send
Justin Donnelly
2017/02/15 21:39:44
Yeah, if the annotation is meant to be a descripti
Ramin Halavati
2017/02/16 07:03:30
Done.
| |
304 cookies_store: "" | |
305 setting: "" | |
Justin Donnelly
2017/02/14 17:01:05
Disable ‘Use a prediction service to help complete
Ramin Halavati
2017/02/15 11:52:03
Done.
| |
306 policy { | |
307 [POLICY_NAME] { | |
Justin Donnelly
2017/02/14 17:01:05
SearchSuggestEnabled
Ramin Halavati
2017/02/15 11:52:03
Done.
| |
308 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} | |
Justin Donnelly
2017/02/14 17:01:05
I'm honestly not sure.
I see that there's a Cloud
Ramin Halavati
2017/02/15 11:52:03
It seems that selecting false value for this will
Justin Donnelly
2017/02/15 21:39:44
Cool, thanks for the reference, that's helpful.
Ramin Halavati
2017/02/16 07:03:30
Done.
| |
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 |