Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Unified Diff: components/ntp_snippets/remote/remote_suggestions_provider.cc

Issue 2496163002: [NTP Snippets] Don't notify about new suggestion when in a not-available state (Closed)
Patch Set: add test; fix Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/ntp_snippets/remote/remote_suggestions_provider.cc
diff --git a/components/ntp_snippets/remote/remote_suggestions_provider.cc b/components/ntp_snippets/remote/remote_suggestions_provider.cc
index 96ad674507a2fd717ed7800e65764a51e347f6ae..5cead224342f97cd87838927bb2c11115a6edf46 100644
--- a/components/ntp_snippets/remote/remote_suggestions_provider.cc
+++ b/components/ntp_snippets/remote/remote_suggestions_provider.cc
@@ -485,7 +485,8 @@ void RemoteSuggestionsProvider::ClearCachedSuggestions(Category category) {
database_->DeleteImages(GetSnippetIDVector(content->snippets));
content->snippets.clear();
- NotifyNewSuggestions(category, *content);
+ if (IsCategoryStatusAvailable(content->status))
+ NotifyNewSuggestions(category, *content);
}
void RemoteSuggestionsProvider::GetDismissedSuggestionsForDebugging(
@@ -1041,7 +1042,11 @@ void RemoteSuggestionsProvider::FinishInitialization() {
// don't know how long the fetch will take or if it will even complete.
for (const auto& item : category_contents_) {
Category category = item.first;
- NotifyNewSuggestions(category, item.second);
+ const CategoryContent& content = item.second;
+ // Note: We might be in a non-available status here, e.g. DISABLED due to
+ // enterprise policy.
+ if (IsCategoryStatusAvailable(content.status))
+ NotifyNewSuggestions(category, content);
}
}

Powered by Google App Engine
This is Rietveld 408576698