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

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: Adjust MockContentSuggestionsProvider 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 76f79cf471801cdf08b3adf07b0713ca36030656..ee74d49355da6dfa3578f10b5fbc01d3f002cef7 100644
--- a/components/ntp_snippets/content_suggestions_service.h
+++ b/components/ntp_snippets/content_suggestions_service.h
@@ -50,6 +50,16 @@ 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. This event may also be fired for
+ // |suggestion_id|s that never existed and should be ignored in that case.
+ 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.
@@ -155,6 +165,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
@@ -162,6 +175,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 a suggestion was
+ // removed.
+ bool RemoveSuggestionByID(Category category,
+ const std::string& suggestion_id);
+
// Fires the OnCategoryStatusChanged event for the given |category|.
void NotifyCategoryStatusChanged(Category category);
« no previous file with comments | « components/ntp_snippets/content_suggestions_provider.h ('k') | components/ntp_snippets/content_suggestions_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698