OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/autocomplete/chrome_autocomplete_provider_client.h" | 5 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/feature_list.h" | 9 #include "base/feature_list.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "chrome/common/chrome_features.h" | 27 #include "chrome/common/chrome_features.h" |
28 #include "chrome/common/pref_names.h" | 28 #include "chrome/common/pref_names.h" |
29 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
30 #include "components/browser_sync/profile_sync_service.h" | 30 #include "components/browser_sync/profile_sync_service.h" |
31 #include "components/history/core/browser/history_service.h" | 31 #include "components/history/core/browser/history_service.h" |
32 #include "components/omnibox/browser/autocomplete_classifier.h" | 32 #include "components/omnibox/browser/autocomplete_classifier.h" |
33 #include "components/prefs/pref_service.h" | 33 #include "components/prefs/pref_service.h" |
34 #include "components/sync/driver/sync_service_utils.h" | 34 #include "components/sync/driver/sync_service_utils.h" |
35 #include "content/public/browser/notification_service.h" | 35 #include "content/public/browser/notification_service.h" |
36 #include "extensions/features/features.h" | 36 #include "extensions/features/features.h" |
| 37 #include "net/traffic_annotation/network_traffic_annotation.h" |
37 | 38 |
38 #if BUILDFLAG(ENABLE_EXTENSIONS) | 39 #if BUILDFLAG(ENABLE_EXTENSIONS) |
39 #include "chrome/browser/autocomplete/keyword_extensions_delegate_impl.h" | 40 #include "chrome/browser/autocomplete/keyword_extensions_delegate_impl.h" |
40 #endif | 41 #endif |
41 | 42 |
42 #if !defined(OS_ANDROID) | 43 #if !defined(OS_ANDROID) |
43 namespace { | 44 namespace { |
44 | 45 |
45 // This list should be kept in sync with chrome/common/url_constants.h. | 46 // This list should be kept in sync with chrome/common/url_constants.h. |
46 // Only include useful sub-pages, confirmation alerts are not useful. | 47 // Only include useful sub-pages, confirmation alerts are not useful. |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 void ChromeAutocompleteProviderClient::DeleteMatchingURLsForKeywordFromHistory( | 243 void ChromeAutocompleteProviderClient::DeleteMatchingURLsForKeywordFromHistory( |
243 history::KeywordID keyword_id, | 244 history::KeywordID keyword_id, |
244 const base::string16& term) { | 245 const base::string16& term) { |
245 GetHistoryService()->DeleteMatchingURLsForKeyword(keyword_id, term); | 246 GetHistoryService()->DeleteMatchingURLsForKeyword(keyword_id, term); |
246 } | 247 } |
247 | 248 |
248 void ChromeAutocompleteProviderClient::PrefetchImage(const GURL& url) { | 249 void ChromeAutocompleteProviderClient::PrefetchImage(const GURL& url) { |
249 BitmapFetcherService* image_service = | 250 BitmapFetcherService* image_service = |
250 BitmapFetcherServiceFactory::GetForBrowserContext(profile_); | 251 BitmapFetcherServiceFactory::GetForBrowserContext(profile_); |
251 DCHECK(image_service); | 252 DCHECK(image_service); |
252 image_service->Prefetch(url); | 253 |
| 254 // TODO(jdonnelly, rhalavati): Create a helper function with Callback to |
| 255 // create annotation and pass it to image_service, merging this annotation and |
| 256 // chrome/browser/ui/omnibox/chrome_omnibox_client.cc |
| 257 net::NetworkTrafficAnnotationTag traffic_annotation = |
| 258 net::DefineNetworkTrafficAnnotation("omnibox_prefetch_image", R"( |
| 259 semantics { |
| 260 sender: "Omnibox" |
| 261 description: |
| 262 "Chromium provides answers in the suggestion list for certain " |
| 263 "queries that the user types in the omnibox. This request " |
| 264 "retrieves a small image (for example, an icon illustrating the " |
| 265 "current weather conditions) when this can add information to an " |
| 266 "answer." |
| 267 trigger: |
| 268 "Change of results for the query typed by the user in the " |
| 269 "omnibox." |
| 270 data: |
| 271 "The only data sent is the path to an image. No user data is " |
| 272 "included, although some might be inferrable (e.g. whether the " |
| 273 "weather is sunny or rainy in the user's current location) from " |
| 274 "the name of the image in the path." |
| 275 destination: WEBSITE |
| 276 } |
| 277 policy { |
| 278 cookies_allowed: true |
| 279 cookies_store: "user" |
| 280 setting: |
| 281 "You can enable or disable this feature via 'Use a prediction " |
| 282 "service to help complete searches and URLs typed in the " |
| 283 "address bar.' in Chromium's settings under Advanced. The " |
| 284 "feature is enabled by default." |
| 285 policy { |
| 286 SearchSuggestEnabled { |
| 287 policy_options {mode: MANDATORY} |
| 288 value: false |
| 289 } |
| 290 } |
| 291 })"); |
| 292 |
| 293 image_service->Prefetch(url, traffic_annotation); |
253 } | 294 } |
254 | 295 |
255 void ChromeAutocompleteProviderClient::OnAutocompleteControllerResultReady( | 296 void ChromeAutocompleteProviderClient::OnAutocompleteControllerResultReady( |
256 AutocompleteController* controller) { | 297 AutocompleteController* controller) { |
257 content::NotificationService::current()->Notify( | 298 content::NotificationService::current()->Notify( |
258 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, | 299 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, |
259 content::Source<AutocompleteController>(controller), | 300 content::Source<AutocompleteController>(controller), |
260 content::NotificationService::NoDetails()); | 301 content::NotificationService::NoDetails()); |
261 } | 302 } |
OLD | NEW |