Chromium Code Reviews| 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> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/location.h" | 13 #include "base/location.h" |
| 14 #include "base/memory/ptr_util.h" | |
| 14 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "base/time/default_clock.h" | |
| 16 #include "base/values.h" | 18 #include "base/values.h" |
| 17 #include "components/ntp_snippets/pref_names.h" | 19 #include "components/ntp_snippets/pref_names.h" |
| 18 #include "components/prefs/pref_registry_simple.h" | 20 #include "components/prefs/pref_registry_simple.h" |
| 19 #include "components/prefs/pref_service.h" | 21 #include "components/prefs/pref_service.h" |
| 20 #include "ui/gfx/image/image.h" | 22 #include "ui/gfx/image/image.h" |
| 21 | 23 |
| 22 namespace ntp_snippets { | 24 namespace ntp_snippets { |
| 23 | 25 |
| 24 ContentSuggestionsService::ContentSuggestionsService( | 26 ContentSuggestionsService::ContentSuggestionsService( |
| 25 State state, | 27 State state, |
| 26 SigninManagerBase* signin_manager, | 28 SigninManagerBase* signin_manager, |
| 27 history::HistoryService* history_service, | 29 history::HistoryService* history_service, |
| 28 PrefService* pref_service, | 30 PrefService* pref_service, |
| 29 std::unique_ptr<CategoryRanker> category_ranker) | 31 std::unique_ptr<CategoryRanker> category_ranker) |
| 30 : state_(state), | 32 : state_(state), |
| 31 signin_observer_(this), | 33 signin_observer_(this), |
| 32 history_service_observer_(this), | 34 history_service_observer_(this), |
| 33 remote_suggestions_provider_(nullptr), | 35 remote_suggestions_provider_(nullptr), |
| 34 remote_suggestions_scheduler_(nullptr), | 36 remote_suggestions_scheduler_(nullptr), |
| 35 pref_service_(pref_service), | 37 pref_service_(pref_service), |
| 36 user_classifier_(pref_service), | 38 user_classifier_(pref_service, base::MakeUnique<base::DefaultClock>()), |
|
Marc Treib
2017/03/21 09:43:20
Hm, eventually we should probably pass in the User
jkrcal
2017/03/21 09:46:59
Agreed. There's also a lot of duplication in the u
| |
| 37 category_ranker_(std::move(category_ranker)) { | 39 category_ranker_(std::move(category_ranker)) { |
| 38 // Can be null in tests. | 40 // Can be null in tests. |
| 39 if (signin_manager) { | 41 if (signin_manager) { |
| 40 signin_observer_.Add(signin_manager); | 42 signin_observer_.Add(signin_manager); |
| 41 } | 43 } |
| 42 | 44 |
| 43 if (history_service) { | 45 if (history_service) { |
| 44 history_service_observer_.Add(history_service); | 46 history_service_observer_.Add(history_service); |
| 45 } | 47 } |
| 46 | 48 |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 509 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() { | 511 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() { |
| 510 base::ListValue list; | 512 base::ListValue list; |
| 511 for (const auto& category_provider_pair : dismissed_providers_by_category_) { | 513 for (const auto& category_provider_pair : dismissed_providers_by_category_) { |
| 512 list.AppendInteger(category_provider_pair.first.id()); | 514 list.AppendInteger(category_provider_pair.first.id()); |
| 513 } | 515 } |
| 514 | 516 |
| 515 pref_service_->Set(prefs::kDismissedCategories, list); | 517 pref_service_->Set(prefs::kDismissedCategories, list); |
| 516 } | 518 } |
| 517 | 519 |
| 518 } // namespace ntp_snippets | 520 } // namespace ntp_snippets |
| OLD | NEW |