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

Unified Diff: components/ntp_snippets/content_suggestions_service.h

Issue 2244793002: Remove deleted offline page suggestions from opened NTPs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months 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/content_suggestions_service.h
diff --git a/components/ntp_snippets/content_suggestions_service.h b/components/ntp_snippets/content_suggestions_service.h
index ad7f8a9f7c6a126e9636b004316c297b4066995f..96fe9b9f297eabb614934cf2a8651d547ea07086 100644
--- a/components/ntp_snippets/content_suggestions_service.h
+++ b/components/ntp_snippets/content_suggestions_service.h
@@ -50,6 +50,15 @@ class ContentSuggestionsService : public KeyedService,
virtual void OnCategoryStatusChanged(Category category,
CategoryStatus new_status) = 0;
+ // Fired when a suggestion has been invalidated. The UI must immediately
+ // clear the suggestion even from open NTPs. Invalidation happens, for
+ // example, when the content that the suggestion refers to is gone.
+ // Note that this event may be fired even if the corresponding |category| is
+ // not currently AVAILABLE, because open UIs may still be showing the
+ // suggestion that is to be removed.
+ virtual void OnSuggestionInvalidated(Category category,
+ const std::string& suggestion_id) = 0;
+
// Sent when the service is shutting down. After the service has shut down,
// it will not provide any data anymore, though calling the getters is still
// safe.
@@ -161,6 +170,9 @@ class ContentSuggestionsService : public KeyedService,
void OnCategoryStatusChanged(ContentSuggestionsProvider* provider,
Category category,
CategoryStatus new_status) override;
+ void OnSuggestionInvalidated(ContentSuggestionsProvider* provider,
+ Category category,
+ const std::string& suggestion_id) override;
// Registers the given |provider| for the given |category|, unless it is
// already registered. Returns true if the category was newly registered or
@@ -168,6 +180,12 @@ class ContentSuggestionsService : public KeyedService,
bool RegisterCategoryIfRequired(ContentSuggestionsProvider* provider,
Category category);
+ // Removes a suggestion from the local stores |id_category_map_| and
+ // |suggestions_by_category_|, if it exists. Returns true if the suggestion
+ // still existed.
Marc Treib 2016/08/16 09:03:54 Returns true if a suggestion was removed? (I find
Philipp Keck 2016/08/16 10:54:40 Done.
+ bool RemoveSuggestionByID(Category category,
+ const std::string& suggestion_id);
+
// Fires the OnCategoryStatusChanged event for the given |category|.
void NotifyCategoryStatusChanged(Category category);

Powered by Google App Engine
This is Rietveld 408576698