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 "chrome/browser/android/ntp/content_suggestions_notifier_service.h" | 5 #include "chrome/browser/android/ntp/content_suggestions_notifier_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/android/application_status_listener.h" | 9 #include "base/android/application_status_listener.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 use_snippet ? suggestion->snippet_text() | 145 use_snippet ? suggestion->snippet_text() |
146 : suggestion->publisher_name(), | 146 : suggestion->publisher_name(), |
147 timeout_at)); | 147 timeout_at)); |
148 } | 148 } |
149 | 149 |
150 void OnCategoryStatusChanged(Category category, | 150 void OnCategoryStatusChanged(Category category, |
151 CategoryStatus new_status) override { | 151 CategoryStatus new_status) override { |
152 if (!category.IsKnownCategory(KnownCategories::ARTICLES)) { | 152 if (!category.IsKnownCategory(KnownCategories::ARTICLES)) { |
153 return; | 153 return; |
154 } | 154 } |
155 switch (new_status) { | 155 if (!ntp_snippets::IsCategoryStatusAvailable(new_status)) { |
156 case CategoryStatus::AVAILABLE: | 156 ContentSuggestionsNotificationHelper::HideAllNotifications( |
157 case CategoryStatus::AVAILABLE_LOADING: | 157 CONTENT_SUGGESTIONS_HIDE_DISABLED); |
158 break; // nothing to do | |
159 case CategoryStatus::INITIALIZING: | |
160 case CategoryStatus::ALL_SUGGESTIONS_EXPLICITLY_DISABLED: | |
161 case CategoryStatus::CATEGORY_EXPLICITLY_DISABLED: | |
162 case CategoryStatus::LOADING_ERROR: | |
163 case CategoryStatus::NOT_PROVIDED: | |
164 case CategoryStatus::SIGNED_OUT: | |
165 ContentSuggestionsNotificationHelper::HideAllNotifications( | |
166 CONTENT_SUGGESTIONS_HIDE_DISABLED); | |
167 break; | |
168 } | 158 } |
169 } | 159 } |
170 | 160 |
171 void OnSuggestionInvalidated( | 161 void OnSuggestionInvalidated( |
172 const ContentSuggestion::ID& suggestion_id) override { | 162 const ContentSuggestion::ID& suggestion_id) override { |
173 ContentSuggestionsNotificationHelper::HideNotification( | 163 ContentSuggestionsNotificationHelper::HideNotification( |
174 suggestion_id, CONTENT_SUGGESTIONS_HIDE_EXPIRY); | 164 suggestion_id, CONTENT_SUGGESTIONS_HIDE_EXPIRY); |
175 } | 165 } |
176 | 166 |
177 void OnFullRefreshRequired() override { | 167 void OnFullRefreshRequired() override { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 registry->RegisterIntegerPref( | 257 registry->RegisterIntegerPref( |
268 prefs::kContentSuggestionsConsecutiveIgnoredPrefName, 0); | 258 prefs::kContentSuggestionsConsecutiveIgnoredPrefName, 0); |
269 registry->RegisterIntegerPref(prefs::kContentSuggestionsNotificationsSentDay, | 259 registry->RegisterIntegerPref(prefs::kContentSuggestionsNotificationsSentDay, |
270 0); | 260 0); |
271 registry->RegisterIntegerPref( | 261 registry->RegisterIntegerPref( |
272 prefs::kContentSuggestionsNotificationsSentCount, 0); | 262 prefs::kContentSuggestionsNotificationsSentCount, 0); |
273 | 263 |
274 // TODO(sfiera): remove after M62; no longer (and never really) used. | 264 // TODO(sfiera): remove after M62; no longer (and never really) used. |
275 registry->RegisterStringPref(kNotificationIDWithinCategory, std::string()); | 265 registry->RegisterStringPref(kNotificationIDWithinCategory, std::string()); |
276 } | 266 } |
OLD | NEW |