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

Unified Diff: components/ntp_snippets/content_suggestions_provider.h

Issue 2194203002: Make ContentSuggestionsService recognize new/removed categories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@renaming
Patch Set: Put the status-change notification back in RegisterProvider() Created 4 years, 5 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_provider.h
diff --git a/components/ntp_snippets/content_suggestions_provider.h b/components/ntp_snippets/content_suggestions_provider.h
index 3a80b68dd4d66cb1240b7ee0ffba19c18efc8b24..8957dc776d42ae4335a26adec916cb9e52a5b14d 100644
--- a/components/ntp_snippets/content_suggestions_provider.h
+++ b/components/ntp_snippets/content_suggestions_provider.h
@@ -39,20 +39,29 @@ class ContentSuggestionsProvider {
// the full list of currently available suggestions for that category, i.e.,
// an empty list will remove all suggestions from the given category. Note
// that to clear them from the UI immediately, the provider needs to change
- // the status of the respective category.
+ // the status of the respective category. This may be called with |category|
+ // values that are not yet provided by any provider to create a new
+ // category.
Marc Treib 2016/08/01 14:23:37 I find this a bit confusing... it's not called wit
Philipp Keck 2016/08/01 14:59:03 Done. Changed here and below.
// IDs for the ContentSuggestions should be generated with
// |MakeUniqueID(..)| below.
virtual void OnNewSuggestions(
- Category changed_category,
+ ContentSuggestionsProvider* provider,
+ Category category,
std::vector<ContentSuggestion> suggestions) = 0;
// Called when the status of a category changed.
// |new_status| must be the value that is currently returned from the
- // provider's |GetCategoryStatus(category)| below.
+ // provider's |GetCategoryStatus(category)| below (unless it is
+ // NOT_PROVIDED).
Marc Treib 2016/08/01 14:23:37 I don't understand this - for NOT_PROVIDED, whatev
Philipp Keck 2016/08/01 14:59:03 Well, the current provider implementations just DC
Marc Treib 2016/08/01 15:17:47 The consistent behavior with GetCategoryInfo() is
Philipp Keck 2016/08/01 15:58:11 The notion of "existing" is relatively cumbersome
tschumann 2016/08/01 16:30:12 We should work towards a sound model, where the ob
Philipp Keck 2016/08/01 17:04:57 Acknowledged.
+ // This may be called with |category| values that are not yet provided by
+ // any provider to create a new category.
// Whenever the status changes to an unavailable status, all suggestions in
// that category must immediately be removed from all caches and from the
- // UI.
- virtual void OnCategoryStatusChanged(Category changed_category,
+ // UI, but the provider remains registered. When the status changes to
+ // NOT_PROVIDED, the category is unregistered without clearing the UI and
+ // must also be removed from |GetProvidedCategories()|.
+ virtual void OnCategoryStatusChanged(ContentSuggestionsProvider* provider,
+ Category category,
CategoryStatus new_status) = 0;
// Called when the provider needs to shut down and will not deliver any
@@ -66,8 +75,9 @@ class ContentSuggestionsProvider {
virtual void SetObserver(Observer* observer) = 0;
// Returns the categories provided by this provider.
- // TODO(pke): "The value returned by this getter must not change unless
- // OnXxx is called on the observer."
+ // The value returned by this getter must not change unless OnNewSuggestions
Marc Treib 2016/08/01 14:23:37 I'd formulate this as something like: When the set
Philipp Keck 2016/08/01 14:59:03 Done.
+ // (for adding categories) or OnCategoryStatusChanged (with NOT_PROVIDED for
+ // removing categories) is called on the observer.
tschumann 2016/08/01 14:21:17 i wonder if we can get rid of this function at all
Philipp Keck 2016/08/01 14:59:03 Yes we can, though I'm not sure about how we shoul
Marc Treib 2016/08/01 15:17:47 The service has the list categories per provider a
Philipp Keck 2016/08/01 15:58:11 Acknowledged.
tschumann 2016/08/01 16:24:08 To follow up briefly (we can move on offline): The
Philipp Keck 2016/08/01 17:04:57 Acknowledged.
Marc Treib 2016/08/01 17:30:35 Yay!
virtual std::vector<Category> GetProvidedCategories() = 0;
// Determines the status of the given |category|, see CategoryStatus.

Powered by Google App Engine
This is Rietveld 408576698