category_info.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // Copyright 2016 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_NTP_SNIPPETS_CATEGORY_INFO_H_
  5. #define COMPONENTS_NTP_SNIPPETS_CATEGORY_INFO_H_
  6. #include <string>
  7. namespace ntp_snippets {
  8. // On Android builds, a Java counterpart will be generated for this enum.
  9. // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.ntp.snippets
  10. enum class ContentSuggestionsCardLayout {
  11. // Uses all fields.
  12. FULL_CARD,
  13. // No snippet_text and no thumbnail image.
  14. MINIMAL_CARD
  15. };
  16. // On Android builds, a Java counterpart will be generated for this enum.
  17. // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.suggestions
  18. enum class ContentSuggestionsAdditionalAction {
  19. // No additional action available.
  20. NONE,
  21. // More suggestions can be fetched using the Fetch methods with this category.
  22. FETCH,
  23. // Open a new surface dedicated to the content related to this category. The
  24. // UI has to choose which surface to open.
  25. VIEW_ALL
  26. };
  27. // Contains static meta information about a Category.
  28. class CategoryInfo {
  29. public:
  30. CategoryInfo(const std::u16string& title,
  31. ContentSuggestionsCardLayout card_layout,
  32. ContentSuggestionsAdditionalAction additional_action,
  33. bool show_if_empty,
  34. const std::u16string& no_suggestions_message);
  35. CategoryInfo() = delete;
  36. CategoryInfo(CategoryInfo&&);
  37. CategoryInfo(const CategoryInfo&);
  38. CategoryInfo& operator=(CategoryInfo&&);
  39. CategoryInfo& operator=(const CategoryInfo&);
  40. ~CategoryInfo();
  41. // Localized title of the category.
  42. const std::u16string& title() const { return title_; }
  43. // Layout of the cards to be used to display suggestions in this category.
  44. ContentSuggestionsCardLayout card_layout() const { return card_layout_; }
  45. // Supported action for the category.
  46. ContentSuggestionsAdditionalAction additional_action() const {
  47. return additional_action_;
  48. }
  49. // Whether this category should be shown if it offers no suggestions.
  50. bool show_if_empty() const { return show_if_empty_; }
  51. // The message to show if there are no suggestions in this category. Note that
  52. // this matters even if |show_if_empty()| is false: The message still shows
  53. // up when the user dismisses all suggestions in the category.
  54. const std::u16string& no_suggestions_message() const {
  55. return no_suggestions_message_;
  56. }
  57. private:
  58. std::u16string title_;
  59. ContentSuggestionsCardLayout card_layout_;
  60. ContentSuggestionsAdditionalAction additional_action_;
  61. // Whether to show the category if a fetch returns no suggestions.
  62. bool show_if_empty_;
  63. std::u16string no_suggestions_message_;
  64. };
  65. } // namespace ntp_snippets
  66. #endif // COMPONENTS_NTP_SNIPPETS_CATEGORY_INFO_H_