Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/ntp_snippets/remote/remote_suggestions_provider_impl.h" | 5 #include "components/ntp_snippets/remote/remote_suggestions_provider_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 #include "components/ntp_snippets/category_rankers/category_ranker.h" | 26 #include "components/ntp_snippets/category_rankers/category_ranker.h" |
| 27 #include "components/ntp_snippets/features.h" | 27 #include "components/ntp_snippets/features.h" |
| 28 #include "components/ntp_snippets/pref_names.h" | 28 #include "components/ntp_snippets/pref_names.h" |
| 29 #include "components/ntp_snippets/remote/remote_suggestions_database.h" | 29 #include "components/ntp_snippets/remote/remote_suggestions_database.h" |
| 30 #include "components/ntp_snippets/remote/remote_suggestions_scheduler.h" | 30 #include "components/ntp_snippets/remote/remote_suggestions_scheduler.h" |
| 31 #include "components/ntp_snippets/switches.h" | 31 #include "components/ntp_snippets/switches.h" |
| 32 #include "components/prefs/pref_registry_simple.h" | 32 #include "components/prefs/pref_registry_simple.h" |
| 33 #include "components/prefs/pref_service.h" | 33 #include "components/prefs/pref_service.h" |
| 34 #include "components/strings/grit/components_strings.h" | 34 #include "components/strings/grit/components_strings.h" |
| 35 #include "components/variations/variations_associated_data.h" | 35 #include "components/variations/variations_associated_data.h" |
| 36 #include "net/traffic_annotation/network_traffic_annotation.h" | |
| 36 #include "ui/gfx/geometry/size.h" | 37 #include "ui/gfx/geometry/size.h" |
| 37 #include "ui/gfx/image/image.h" | 38 #include "ui/gfx/image/image.h" |
| 38 | 39 |
| 39 namespace ntp_snippets { | 40 namespace ntp_snippets { |
| 40 | 41 |
| 41 namespace { | 42 namespace { |
| 42 | 43 |
| 43 // Number of suggestions requested to the server. Consider replacing sparse UMA | 44 // Number of suggestions requested to the server. Consider replacing sparse UMA |
| 44 // histograms with COUNTS() if this number increases beyond 50. | 45 // histograms with COUNTS() if this number increases beyond 50. |
| 45 const int kMaxSuggestionCount = 10; | 46 const int kMaxSuggestionCount = 10; |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 281 const ImageFetchedCallback& callback) { | 282 const ImageFetchedCallback& callback) { |
| 282 if (url.is_empty() || !thumbnail_requests_throttler_.DemandQuotaForRequest( | 283 if (url.is_empty() || !thumbnail_requests_throttler_.DemandQuotaForRequest( |
| 283 /*interactive_request=*/true)) { | 284 /*interactive_request=*/true)) { |
| 284 // Return an empty image. Directly, this is never synchronous with the | 285 // Return an empty image. Directly, this is never synchronous with the |
| 285 // original FetchSuggestionImage() call - an asynchronous database query has | 286 // original FetchSuggestionImage() call - an asynchronous database query has |
| 286 // happened in the meantime. | 287 // happened in the meantime. |
| 287 callback.Run(gfx::Image()); | 288 callback.Run(gfx::Image()); |
| 288 return; | 289 return; |
| 289 } | 290 } |
| 290 | 291 |
| 292 net::NetworkTrafficAnnotationTag traffic_annotation = | |
|
Marc Treib
2017/05/09 13:40:36
I think this one was copied from the wrong place.
Ramin Halavati
2017/05/09 13:57:49
Acknowledged.
| |
| 293 net::DefineNetworkTrafficAnnotation("suggestions_service_factory", R"( | |
|
Marc Treib
2017/05/09 13:40:36
remote_suggestions_service
Ramin Halavati
2017/05/09 13:57:49
Done.
| |
| 294 semantics { | |
| 295 sender: "suggestions_service" | |
|
Marc Treib
2017/05/09 13:40:36
Content Suggestion thumbnail fetch
Ramin Halavati
2017/05/09 13:57:50
Done.
| |
| 296 description: | |
| 297 "Retrieves thumbnails for site suggestions based on the user's " | |
| 298 "synced browsing history, for use e.g. on the New Tab page." | |
|
Marc Treib
2017/05/09 13:40:36
Retrieves thumbnails for content suggestions, for
Ramin Halavati
2017/05/09 13:57:50
Done.
| |
| 299 trigger: | |
| 300 "Triggered when a thumbnail for a suggestion is required, and no " | |
| 301 "local thumbnail is available." | |
|
Marc Treib
2017/05/09 13:40:36
Triggered when the user looks at a content suggest
Ramin Halavati
2017/05/09 13:57:50
Done.
| |
| 302 data: "The URL for which to retrieve a thumbnail." | |
|
Marc Treib
2017/05/09 13:40:36
None.
Ramin Halavati
2017/05/09 13:57:49
Done.
| |
| 303 destination: GOOGLE_OWNED_SERVICE | |
| 304 } | |
| 305 policy { | |
| 306 cookies_allowed: false | |
| 307 setting: | |
| 308 "Users can disable this feature by signing out of Chrome, or " | |
|
Marc Treib
2017/05/09 13:40:36
Currently not available, but in progress: crbug.co
Ramin Halavati
2017/05/09 13:57:49
Done.
| |
| 309 "disabling Sync or History Sync in Chrome settings under 'Advanced " | |
| 310 "sync settings...'. The feature is enabled by default." | |
| 311 chrome_policy { | |
|
Marc Treib
2017/05/09 13:40:36
chrome_policy {
NTPContentSuggestionsE
Ramin Halavati
2017/05/09 13:57:50
Done.
| |
| 312 SyncDisabled { | |
| 313 policy_options {mode: MANDATORY} | |
| 314 SyncDisabled: true | |
| 315 } | |
| 316 } | |
| 317 chrome_policy { | |
| 318 SigninAllowed { | |
| 319 policy_options {mode: MANDATORY} | |
| 320 SigninAllowed: false | |
| 321 } | |
| 322 } | |
| 323 })"); | |
| 291 image_fetcher_->StartOrQueueNetworkRequest( | 324 image_fetcher_->StartOrQueueNetworkRequest( |
| 292 suggestion_id.id_within_category(), url, | 325 suggestion_id.id_within_category(), url, |
| 293 base::Bind(&CachedImageFetcher::OnImageDecodingDone, | 326 base::Bind(&CachedImageFetcher::OnImageDecodingDone, |
| 294 base::Unretained(this), callback)); | 327 base::Unretained(this), callback), |
| 328 traffic_annotation); | |
| 295 } | 329 } |
| 296 | 330 |
| 297 RemoteSuggestionsProviderImpl::RemoteSuggestionsProviderImpl( | 331 RemoteSuggestionsProviderImpl::RemoteSuggestionsProviderImpl( |
| 298 Observer* observer, | 332 Observer* observer, |
| 299 PrefService* pref_service, | 333 PrefService* pref_service, |
| 300 const std::string& application_language_code, | 334 const std::string& application_language_code, |
| 301 CategoryRanker* category_ranker, | 335 CategoryRanker* category_ranker, |
| 302 RemoteSuggestionsScheduler* scheduler, | 336 RemoteSuggestionsScheduler* scheduler, |
| 303 std::unique_ptr<RemoteSuggestionsFetcher> suggestions_fetcher, | 337 std::unique_ptr<RemoteSuggestionsFetcher> suggestions_fetcher, |
| 304 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher, | 338 std::unique_ptr<image_fetcher::ImageFetcher> image_fetcher, |
| (...skipping 1043 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1348 RemoteSuggestionsProviderImpl::CategoryContent::CategoryContent( | 1382 RemoteSuggestionsProviderImpl::CategoryContent::CategoryContent( |
| 1349 CategoryContent&&) = default; | 1383 CategoryContent&&) = default; |
| 1350 | 1384 |
| 1351 RemoteSuggestionsProviderImpl::CategoryContent::~CategoryContent() = default; | 1385 RemoteSuggestionsProviderImpl::CategoryContent::~CategoryContent() = default; |
| 1352 | 1386 |
| 1353 RemoteSuggestionsProviderImpl::CategoryContent& | 1387 RemoteSuggestionsProviderImpl::CategoryContent& |
| 1354 RemoteSuggestionsProviderImpl::CategoryContent::operator=(CategoryContent&&) = | 1388 RemoteSuggestionsProviderImpl::CategoryContent::operator=(CategoryContent&&) = |
| 1355 default; | 1389 default; |
| 1356 | 1390 |
| 1357 } // namespace ntp_snippets | 1391 } // namespace ntp_snippets |
| OLD | NEW |