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..fc4802ca84d592b7738aa9d107e090ca705401a3 100644 |
--- a/components/ntp_snippets/content_suggestions_category.h |
+++ b/components/ntp_snippets/content_suggestions_category.h |
@@ -5,10 +5,51 @@ |
#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: |
+ int id() const { return id_; } |
tschumann
2016/07/28 15:36:10
we should document this id. To make clear which pr
Philipp Keck
2016/07/28 16:59:58
Done.
|
+ |
+ bool IsKnownCategory(KnownSuggestionsCategories known_category) const; |
+ |
+ private: |
+ friend class ContentSuggestionsCategoryFactory; |
+ |
+ ContentSuggestionsCategory(int id); |
+ |
+ int id_; |
+}; |
+ |
+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 |