| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/content_suggestions_service.h" | 5 #include "components/ntp_snippets/content_suggestions_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "components/prefs/pref_service.h" | 21 #include "components/prefs/pref_service.h" |
| 22 #include "ui/gfx/image/image.h" | 22 #include "ui/gfx/image/image.h" |
| 23 | 23 |
| 24 namespace ntp_snippets { | 24 namespace ntp_snippets { |
| 25 | 25 |
| 26 ContentSuggestionsService::ContentSuggestionsService( | 26 ContentSuggestionsService::ContentSuggestionsService( |
| 27 State state, | 27 State state, |
| 28 SigninManagerBase* signin_manager, | 28 SigninManagerBase* signin_manager, |
| 29 history::HistoryService* history_service, | 29 history::HistoryService* history_service, |
| 30 PrefService* pref_service, | 30 PrefService* pref_service, |
| 31 std::unique_ptr<CategoryRanker> category_ranker) | 31 std::unique_ptr<CategoryRanker> category_ranker, |
| 32 std::unique_ptr<UserClassifier> user_classifier, |
| 33 std::unique_ptr<RemoteSuggestionsScheduler> remote_suggestions_scheduler) |
| 32 : state_(state), | 34 : state_(state), |
| 33 signin_observer_(this), | 35 signin_observer_(this), |
| 34 history_service_observer_(this), | 36 history_service_observer_(this), |
| 35 remote_suggestions_provider_(nullptr), | 37 remote_suggestions_provider_(nullptr), |
| 36 remote_suggestions_scheduler_(nullptr), | |
| 37 pref_service_(pref_service), | 38 pref_service_(pref_service), |
| 38 user_classifier_(pref_service, base::MakeUnique<base::DefaultClock>()), | 39 remote_suggestions_scheduler_(std::move(remote_suggestions_scheduler)), |
| 40 user_classifier_(std::move(user_classifier)), |
| 39 category_ranker_(std::move(category_ranker)) { | 41 category_ranker_(std::move(category_ranker)) { |
| 40 // Can be null in tests. | 42 // Can be null in tests. |
| 41 if (signin_manager) { | 43 if (signin_manager) { |
| 42 signin_observer_.Add(signin_manager); | 44 signin_observer_.Add(signin_manager); |
| 43 } | 45 } |
| 44 | 46 |
| 45 if (history_service) { | 47 if (history_service) { |
| 46 history_service_observer_.Add(history_service); | 48 history_service_observer_.Add(history_service); |
| 47 } | 49 } |
| 48 | 50 |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() { | 512 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() { |
| 511 base::ListValue list; | 513 base::ListValue list; |
| 512 for (const auto& category_provider_pair : dismissed_providers_by_category_) { | 514 for (const auto& category_provider_pair : dismissed_providers_by_category_) { |
| 513 list.AppendInteger(category_provider_pair.first.id()); | 515 list.AppendInteger(category_provider_pair.first.id()); |
| 514 } | 516 } |
| 515 | 517 |
| 516 pref_service_->Set(prefs::kDismissedCategories, list); | 518 pref_service_->Set(prefs::kDismissedCategories, list); |
| 517 } | 519 } |
| 518 | 520 |
| 519 } // namespace ntp_snippets | 521 } // namespace ntp_snippets |
| OLD | NEW |