| 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/memory/ptr_util.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "base/time/default_clock.h" | 17 #include "base/time/default_clock.h" |
| 18 #include "base/values.h" | 18 #include "base/values.h" |
| 19 #include "components/favicon/core/large_icon_service.h" | 19 #include "components/favicon/core/large_icon_service.h" |
| 20 #include "components/favicon_base/fallback_icon_style.h" | 20 #include "components/favicon_base/fallback_icon_style.h" |
| 21 #include "components/favicon_base/favicon_types.h" | 21 #include "components/favicon_base/favicon_types.h" |
| 22 #include "components/ntp_snippets/content_suggestions_metrics.h" |
| 22 #include "components/ntp_snippets/pref_names.h" | 23 #include "components/ntp_snippets/pref_names.h" |
| 23 #include "components/prefs/pref_registry_simple.h" | 24 #include "components/prefs/pref_registry_simple.h" |
| 24 #include "components/prefs/pref_service.h" | 25 #include "components/prefs/pref_service.h" |
| 25 #include "ui/gfx/image/image.h" | 26 #include "ui/gfx/image/image.h" |
| 26 | 27 |
| 27 namespace ntp_snippets { | 28 namespace ntp_snippets { |
| 28 | 29 |
| 29 ContentSuggestionsService::ContentSuggestionsService( | 30 ContentSuggestionsService::ContentSuggestionsService( |
| 30 State state, | 31 State state, |
| 31 SigninManagerBase* signin_manager, | 32 SigninManagerBase* signin_manager, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 47 // Can be null in tests. | 48 // Can be null in tests. |
| 48 if (signin_manager) { | 49 if (signin_manager) { |
| 49 signin_observer_.Add(signin_manager); | 50 signin_observer_.Add(signin_manager); |
| 50 } | 51 } |
| 51 | 52 |
| 52 if (history_service) { | 53 if (history_service) { |
| 53 history_service_observer_.Add(history_service); | 54 history_service_observer_.Add(history_service); |
| 54 } | 55 } |
| 55 | 56 |
| 56 RestoreDismissedCategoriesFromPrefs(); | 57 RestoreDismissedCategoriesFromPrefs(); |
| 58 metrics::RecordRemoteSuggestionsServiceState( |
| 59 IsRemoteSuggestionsServiceEnabled()); |
| 57 } | 60 } |
| 58 | 61 |
| 59 ContentSuggestionsService::~ContentSuggestionsService() = default; | 62 ContentSuggestionsService::~ContentSuggestionsService() = default; |
| 60 | 63 |
| 61 void ContentSuggestionsService::Shutdown() { | 64 void ContentSuggestionsService::Shutdown() { |
| 62 remote_suggestions_provider_ = nullptr; | 65 remote_suggestions_provider_ = nullptr; |
| 63 remote_suggestions_scheduler_ = nullptr; | 66 remote_suggestions_scheduler_ = nullptr; |
| 64 suggestions_by_category_.clear(); | 67 suggestions_by_category_.clear(); |
| 65 providers_by_category_.clear(); | 68 providers_by_category_.clear(); |
| 66 categories_.clear(); | 69 categories_.clear(); |
| (...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() { | 624 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() { |
| 622 base::ListValue list; | 625 base::ListValue list; |
| 623 for (const auto& category_provider_pair : dismissed_providers_by_category_) { | 626 for (const auto& category_provider_pair : dismissed_providers_by_category_) { |
| 624 list.AppendInteger(category_provider_pair.first.id()); | 627 list.AppendInteger(category_provider_pair.first.id()); |
| 625 } | 628 } |
| 626 | 629 |
| 627 pref_service_->Set(prefs::kDismissedCategories, list); | 630 pref_service_->Set(prefs::kDismissedCategories, list); |
| 628 } | 631 } |
| 629 | 632 |
| 630 } // namespace ntp_snippets | 633 } // namespace ntp_snippets |
| OLD | NEW |