| 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 auto providers_it = providers_by_category_.find(category); | 190 auto providers_it = providers_by_category_.find(category); |
| 191 if (providers_it == providers_by_category_.end()) { | 191 if (providers_it == providers_by_category_.end()) { |
| 192 return; | 192 return; |
| 193 } | 193 } |
| 194 | 194 |
| 195 ContentSuggestionsProvider* provider = providers_it->second; | 195 ContentSuggestionsProvider* provider = providers_it->second; |
| 196 UnregisterCategory(category, provider); | 196 UnregisterCategory(category, provider); |
| 197 | 197 |
| 198 dismissed_providers_by_category_[category] = provider; | 198 dismissed_providers_by_category_[category] = provider; |
| 199 StoreDismissedCategoriesToPrefs(); | 199 StoreDismissedCategoriesToPrefs(); |
| 200 |
| 201 category_ranker_->OnCategoryDismissed(category); |
| 200 } | 202 } |
| 201 | 203 |
| 202 void ContentSuggestionsService::RestoreDismissedCategories() { | 204 void ContentSuggestionsService::RestoreDismissedCategories() { |
| 203 // Make a copy as the original will be modified during iteration. | 205 // Make a copy as the original will be modified during iteration. |
| 204 auto dismissed_providers_by_category_copy = dismissed_providers_by_category_; | 206 auto dismissed_providers_by_category_copy = dismissed_providers_by_category_; |
| 205 for (const auto& category_provider_pair : | 207 for (const auto& category_provider_pair : |
| 206 dismissed_providers_by_category_copy) { | 208 dismissed_providers_by_category_copy) { |
| 207 RestoreDismissedCategory(category_provider_pair.first); | 209 RestoreDismissedCategory(category_provider_pair.first); |
| 208 } | 210 } |
| 209 StoreDismissedCategoriesToPrefs(); | 211 StoreDismissedCategoriesToPrefs(); |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() { | 506 void ContentSuggestionsService::StoreDismissedCategoriesToPrefs() { |
| 505 base::ListValue list; | 507 base::ListValue list; |
| 506 for (const auto& category_provider_pair : dismissed_providers_by_category_) { | 508 for (const auto& category_provider_pair : dismissed_providers_by_category_) { |
| 507 list.AppendInteger(category_provider_pair.first.id()); | 509 list.AppendInteger(category_provider_pair.first.id()); |
| 508 } | 510 } |
| 509 | 511 |
| 510 pref_service_->Set(prefs::kDismissedCategories, list); | 512 pref_service_->Set(prefs::kDismissedCategories, list); |
| 511 } | 513 } |
| 512 | 514 |
| 513 } // namespace ntp_snippets | 515 } // namespace ntp_snippets |
| OLD | NEW |