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/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( | |
| 55 "NewTabPage.ContentSuggestions.Preferences.RemoteSuggestions", | |
| 56 IsRemoteSuggestionsServiceEnabled()); | |
|
Marc Treib
2017/04/06 15:39:30
So far, all the metrics recording code lives in th
dgn
2017/04/06 17:28:12
Done.
| |
| 52 } | 57 } |
| 53 | 58 |
| 54 ContentSuggestionsService::~ContentSuggestionsService() = default; | 59 ContentSuggestionsService::~ContentSuggestionsService() = default; |
| 55 | 60 |
| 56 void ContentSuggestionsService::Shutdown() { | 61 void ContentSuggestionsService::Shutdown() { |
| 57 remote_suggestions_provider_ = nullptr; | 62 remote_suggestions_provider_ = nullptr; |
| 58 remote_suggestions_scheduler_ = nullptr; | 63 remote_suggestions_scheduler_ = nullptr; |
| 59 suggestions_by_category_.clear(); | 64 suggestions_by_category_.clear(); |
| 60 providers_by_category_.clear(); | 65 providers_by_category_.clear(); |
| 61 categories_.clear(); | 66 categories_.clear(); |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 538 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() { | 543 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() { |
| 539 base::ListValue list; | 544 base::ListValue list; |
| 540 for (const auto& category_provider_pair : dismissed_providers_by_category_) { | 545 for (const auto& category_provider_pair : dismissed_providers_by_category_) { |
| 541 list.AppendInteger(category_provider_pair.first.id()); | 546 list.AppendInteger(category_provider_pair.first.id()); |
| 542 } | 547 } |
| 543 | 548 |
| 544 pref_service_->Set(prefs::kDismissedCategories, list); | 549 pref_service_->Set(prefs::kDismissedCategories, list); |
| 545 } | 550 } |
| 546 | 551 |
| 547 } // namespace ntp_snippets | 552 } // namespace ntp_snippets |
| OLD | NEW |