| OLD | NEW | 
|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #ifndef COMPONENTS_NTP_SNIPPETS_CATEGORY_INFO_H_ | 5 #ifndef COMPONENTS_NTP_SNIPPETS_CATEGORY_INFO_H_ | 
| 6 #define COMPONENTS_NTP_SNIPPETS_CATEGORY_INFO_H_ | 6 #define COMPONENTS_NTP_SNIPPETS_CATEGORY_INFO_H_ | 
| 7 | 7 | 
| 8 #include "base/macros.h" | 8 #include "base/macros.h" | 
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" | 
| 10 | 10 | 
| 11 namespace ntp_snippets { | 11 namespace ntp_snippets { | 
| 12 | 12 | 
| 13 // On Android builds, a Java counterpart will be generated for this enum. | 13 // On Android builds, a Java counterpart will be generated for this enum. | 
| 14 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.ntp.snippets | 14 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.ntp.snippets | 
| 15 enum class ContentSuggestionsCardLayout { | 15 enum class ContentSuggestionsCardLayout { | 
| 16   // Uses all fields. | 16   // Uses all fields. | 
| 17   FULL_CARD, | 17   FULL_CARD, | 
| 18 | 18 | 
| 19   // No snippet_text and no thumbnail image. | 19   // No snippet_text and no thumbnail image. | 
| 20   MINIMAL_CARD | 20   MINIMAL_CARD | 
| 21 }; | 21 }; | 
| 22 | 22 | 
| 23 // Contains static meta information about a Category. | 23 // Contains static meta information about a Category. | 
| 24 class CategoryInfo { | 24 class CategoryInfo { | 
| 25  public: | 25  public: | 
| 26   CategoryInfo(const base::string16& title, | 26   CategoryInfo(const base::string16& title, | 
| 27                ContentSuggestionsCardLayout card_layout, | 27                ContentSuggestionsCardLayout card_layout, | 
| 28                bool has_more_action, | 28                bool has_fetch_action, | 
| 29                bool has_reload_action, |  | 
| 30                bool has_view_all_action, | 29                bool has_view_all_action, | 
| 31                bool show_if_empty, | 30                bool show_if_empty, | 
| 32                const base::string16& no_suggestions_message); | 31                const base::string16& no_suggestions_message); | 
| 33   CategoryInfo() = delete; | 32   CategoryInfo() = delete; | 
| 34   CategoryInfo(CategoryInfo&&); | 33   CategoryInfo(CategoryInfo&&); | 
| 35   CategoryInfo(const CategoryInfo&); | 34   CategoryInfo(const CategoryInfo&); | 
| 36   CategoryInfo& operator=(CategoryInfo&&); | 35   CategoryInfo& operator=(CategoryInfo&&); | 
| 37   CategoryInfo& operator=(const CategoryInfo&); | 36   CategoryInfo& operator=(const CategoryInfo&); | 
| 38   ~CategoryInfo(); | 37   ~CategoryInfo(); | 
| 39 | 38 | 
| 40   // Localized title of the category. | 39   // Localized title of the category. | 
| 41   const base::string16& title() const { return title_; } | 40   const base::string16& title() const { return title_; } | 
| 42 | 41 | 
| 43   // Layout of the cards to be used to display suggestions in this category. | 42   // Layout of the cards to be used to display suggestions in this category. | 
| 44   ContentSuggestionsCardLayout card_layout() const { return card_layout_; } | 43   ContentSuggestionsCardLayout card_layout() const { return card_layout_; } | 
| 45 | 44 | 
| 46   // Whether the category supports a "More" action, that triggers fetching more | 45   // Whether the category supports a "Fetch" action, that triggers fetching more | 
| 47   // suggestions for the category, while keeping the current ones. | 46   // suggestions for the category. | 
| 48   bool has_more_action() const { return has_more_action_; } | 47   bool has_fetch_action() const { return has_fetch_action_; } | 
| 49 |  | 
| 50   // Whether the category supports a "Reload" action, that triggers fetching new |  | 
| 51   // suggestions to replace the current ones. |  | 
| 52   bool has_reload_action() const { return has_reload_action_; } |  | 
| 53 | 48 | 
| 54   // Whether the category supports a "ViewAll" action, that triggers displaying | 49   // Whether the category supports a "ViewAll" action, that triggers displaying | 
| 55   // all the content related to the current categories. | 50   // all the content related to the current categories. | 
| 56   bool has_view_all_action() const { return has_view_all_action_; } | 51   bool has_view_all_action() const { return has_view_all_action_; } | 
| 57 | 52 | 
| 58   // Whether this category should be shown if it offers no suggestions. | 53   // Whether this category should be shown if it offers no suggestions. | 
| 59   bool show_if_empty() const { return show_if_empty_; } | 54   bool show_if_empty() const { return show_if_empty_; } | 
| 60 | 55 | 
| 61   // The message to show if there are no suggestions in this category. Note that | 56   // The message to show if there are no suggestions in this category. Note that | 
| 62   // this matters even if |show_if_empty()| is false: The message still shows | 57   // this matters even if |show_if_empty()| is false: The message still shows | 
| 63   // up when the user dismisses all suggestions in the category. | 58   // up when the user dismisses all suggestions in the category. | 
| 64   const base::string16& no_suggestions_message() const { | 59   const base::string16& no_suggestions_message() const { | 
| 65     return no_suggestions_message_; | 60     return no_suggestions_message_; | 
| 66   } | 61   } | 
| 67 | 62 | 
| 68  private: | 63  private: | 
| 69   base::string16 title_; | 64   base::string16 title_; | 
| 70   ContentSuggestionsCardLayout card_layout_; | 65   ContentSuggestionsCardLayout card_layout_; | 
| 71 | 66 | 
| 72   // Supported actions for the category. | 67   // Supported actions for the category. | 
| 73   bool has_more_action_; | 68   bool has_fetch_action_; | 
| 74   bool has_reload_action_; |  | 
| 75   bool has_view_all_action_; | 69   bool has_view_all_action_; | 
| 76 | 70 | 
| 77   // Whether to show the category if a fetch returns no suggestions. | 71   // Whether to show the category if a fetch returns no suggestions. | 
| 78   bool show_if_empty_; | 72   bool show_if_empty_; | 
| 79   base::string16 no_suggestions_message_; | 73   base::string16 no_suggestions_message_; | 
| 80 }; | 74 }; | 
| 81 | 75 | 
| 82 }  // namespace ntp_snippets | 76 }  // namespace ntp_snippets | 
| 83 | 77 | 
| 84 #endif  // COMPONENTS_NTP_SNIPPETS_CATEGORY_INFO_H_ | 78 #endif  // COMPONENTS_NTP_SNIPPETS_CATEGORY_INFO_H_ | 
| OLD | NEW | 
|---|