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/metrics/histogram_macros.h" |
15 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
16 #include "base/threading/thread_task_runner_handle.h" | 17 #include "base/threading/thread_task_runner_handle.h" |
17 #include "base/time/default_clock.h" | 18 #include "base/time/default_clock.h" |
18 #include "base/values.h" | 19 #include "base/values.h" |
19 #include "components/ntp_snippets/pref_names.h" | 20 #include "components/ntp_snippets/pref_names.h" |
20 #include "components/prefs/pref_registry_simple.h" | 21 #include "components/prefs/pref_registry_simple.h" |
21 #include "components/prefs/pref_service.h" | 22 #include "components/prefs/pref_service.h" |
22 #include "ui/gfx/image/image.h" | 23 #include "ui/gfx/image/image.h" |
23 | 24 |
24 namespace ntp_snippets { | 25 namespace ntp_snippets { |
(...skipping 17 matching lines...) Expand all Loading... |
42 // Can be null in tests. | 43 // Can be null in tests. |
43 if (signin_manager) { | 44 if (signin_manager) { |
44 signin_observer_.Add(signin_manager); | 45 signin_observer_.Add(signin_manager); |
45 } | 46 } |
46 | 47 |
47 if (history_service) { | 48 if (history_service) { |
48 history_service_observer_.Add(history_service); | 49 history_service_observer_.Add(history_service); |
49 } | 50 } |
50 | 51 |
51 RestoreDismissedCategoriesFromPrefs(); | 52 RestoreDismissedCategoriesFromPrefs(); |
| 53 |
| 54 UMA_HISTOGRAM_BOOLEAN("ContentSuggestions.Preferences.RemoteSuggestions", |
| 55 IsRemoteSuggestionsServiceEnabled()); |
52 } | 56 } |
53 | 57 |
54 ContentSuggestionsService::~ContentSuggestionsService() = default; | 58 ContentSuggestionsService::~ContentSuggestionsService() = default; |
55 | 59 |
56 void ContentSuggestionsService::Shutdown() { | 60 void ContentSuggestionsService::Shutdown() { |
57 remote_suggestions_provider_ = nullptr; | 61 remote_suggestions_provider_ = nullptr; |
58 remote_suggestions_scheduler_ = nullptr; | 62 remote_suggestions_scheduler_ = nullptr; |
59 suggestions_by_category_.clear(); | 63 suggestions_by_category_.clear(); |
60 providers_by_category_.clear(); | 64 providers_by_category_.clear(); |
61 categories_.clear(); | 65 categories_.clear(); |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() { | 542 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() { |
539 base::ListValue list; | 543 base::ListValue list; |
540 for (const auto& category_provider_pair : dismissed_providers_by_category_) { | 544 for (const auto& category_provider_pair : dismissed_providers_by_category_) { |
541 list.AppendInteger(category_provider_pair.first.id()); | 545 list.AppendInteger(category_provider_pair.first.id()); |
542 } | 546 } |
543 | 547 |
544 pref_service_->Set(prefs::kDismissedCategories, list); | 548 pref_service_->Set(prefs::kDismissedCategories, list); |
545 } | 549 } |
546 | 550 |
547 } // namespace ntp_snippets | 551 } // namespace ntp_snippets |
OLD | NEW |