| Index: components/ntp_snippets/content_suggestions_category.h
|
| diff --git a/components/ntp_snippets/content_suggestions_category.h b/components/ntp_snippets/content_suggestions_category.h
|
| index 70bb23d06fedc97de38433c46551ea6fc347af2c..460dd7eae23ef31c9b8bc89a36ae7dce23280fd0 100644
|
| --- a/components/ntp_snippets/content_suggestions_category.h
|
| +++ b/components/ntp_snippets/content_suggestions_category.h
|
| @@ -5,10 +5,58 @@
|
| #ifndef COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_CATEGORY_H_
|
| #define COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTIONS_CATEGORY_H_
|
|
|
| +#include <ostream>
|
| +
|
| namespace ntp_snippets {
|
|
|
| -// A category groups ContentSuggestions which belong together.
|
| -enum class ContentSuggestionsCategory { ARTICLES, OFFLINE_PAGES, COUNT };
|
| +class ContentSuggestionsCategoryFactory;
|
| +
|
| +// These are the categories that the client knows about.
|
| +// The values before LOCAL_CATEGORIES_COUNT are the categories that are provided
|
| +// locally on the device. Those values need to be listed in the
|
| +// ContentSuggestionsCategoryFactory constructor!
|
| +// Categories provided by the server (IDs strictly larger than
|
| +// REMOTE_CATEGORIES_OFFSET) only need to be hard-coded here if they need to be
|
| +// recognized by the client implementation.
|
| +enum class KnownSuggestionsCategories {
|
| + OFFLINE_PAGES,
|
| + LOCAL_CATEGORIES_COUNT,
|
| +
|
| + REMOTE_CATEGORIES_OFFSET = 10000,
|
| + ARTICLES = REMOTE_CATEGORIES_OFFSET + 1,
|
| +};
|
| +
|
| +// A category groups ContentSuggestions which belong together. Use the
|
| +// ContentSuggestionsCategoryFactory to obtain instances.
|
| +class ContentSuggestionsCategory {
|
| + public:
|
| + // Returns a non-negative identifier that is unique for the category and can
|
| + // be converted back to a ContentSuggestionsCategory instance using
|
| + // |ContentSuggestionsCategoryFactory::FromIDValue(id)|.
|
| + // Note that these IDs are not necessarily stable across multiple runs of
|
| + // the application, so they should not be persisted.
|
| + int id() const { return id_; }
|
| +
|
| + bool IsKnownCategory(KnownSuggestionsCategories known_category) const;
|
| +
|
| + private:
|
| + friend class ContentSuggestionsCategoryFactory;
|
| +
|
| + ContentSuggestionsCategory(int id);
|
| +
|
| + int id_;
|
| +
|
| + // Allow copy and assignment.
|
| +};
|
| +
|
| +bool operator==(const ContentSuggestionsCategory& left,
|
| + const ContentSuggestionsCategory& right);
|
| +
|
| +bool operator!=(const ContentSuggestionsCategory& left,
|
| + const ContentSuggestionsCategory& right);
|
| +
|
| +std::ostream& operator<<(std::ostream& os,
|
| + const ContentSuggestionsCategory& obj);
|
|
|
| } // namespace ntp_snippets
|
|
|
|
|