Chromium Code Reviews| 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 Suggest Prefetch" | |
|
Peter Kasting
2017/02/24 02:38:22
I wonder if this is too fine-grained.
Over in htt
Ramin Halavati
2017/02/24 07:44:01
We need to have different |sender| texts for diffe
battre
2017/02/24 07:54:23
Actually, I would prefer if the same component reu
| |
| 261 description: | |
| 262 "Google Chrome provides answers in the suggestion list for certain " | |
|
Peter Kasting
2017/02/24 02:41:18
(Sorry for all the separate mails on this stuff)
| |
| 263 "queries that user types in the omnibox. This request retrieves a " | |
| 264 "small image (for example, an icon illustrating the current " | |
| 265 "weather conditions) when this can add information to an answer." | |
| 266 trigger: | |
| 267 "Change of results for the query typed by the user in the " | |
| 268 "omnibox." | |
| 269 data: | |
| 270 "The only data sent is the path to an image. No user data is " | |
| 271 "included, although some might be inferrable (e.g. whether the " | |
| 272 "weather is sunny or rainy in the user's current location) from " | |
| 273 "the name of the image in the path." | |
| 274 destination: WEBSITE | |
| 275 } | |
| 276 policy { | |
| 277 cookies_allowed: true | |
| 278 cookies_store: "user" | |
| 279 setting: | |
| 280 "You can enable or disable this feature via 'Use a prediction " | |
| 281 "service to help complete searches and URLs typed in the " | |
| 282 "address bar.' in Chrome's settings under Advanced. The " | |
|
Peter Kasting
2017/02/24 02:41:18
...similarly here "...in the settings page..."
| |
| 283 "feature is enabled by default." | |
| 284 policy { | |
| 285 SearchSuggestEnabled { | |
| 286 policy_options {mode: MANDATORY} | |
| 287 value: false | |
| 288 } | |
| 289 } | |
| 290 })"); | |
| 291 | |
| 292 image_service->Prefetch(url, traffic_annotation); | |
| 253 } | 293 } |
| 254 | 294 |
| 255 void ChromeAutocompleteProviderClient::OnAutocompleteControllerResultReady( | 295 void ChromeAutocompleteProviderClient::OnAutocompleteControllerResultReady( |
| 256 AutocompleteController* controller) { | 296 AutocompleteController* controller) { |
| 257 content::NotificationService::current()->Notify( | 297 content::NotificationService::current()->Notify( |
| 258 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, | 298 chrome::NOTIFICATION_AUTOCOMPLETE_CONTROLLER_RESULT_READY, |
| 259 content::Source<AutocompleteController>(controller), | 299 content::Source<AutocompleteController>(controller), |
| 260 content::NotificationService::NoDetails()); | 300 content::NotificationService::NoDetails()); |
| 261 } | 301 } |
| OLD | NEW |