| 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_button, | 28 bool has_more_action, |
| 29 bool has_reload_action, |
| 30 bool has_view_all_action, |
| 29 bool show_if_empty, | 31 bool show_if_empty, |
| 30 const base::string16& no_suggestions_message); | 32 const base::string16& no_suggestions_message); |
| 31 CategoryInfo(CategoryInfo&&) = default; | 33 CategoryInfo(CategoryInfo&&); |
| 32 CategoryInfo& operator=(CategoryInfo&&) = default; | 34 CategoryInfo& operator=(CategoryInfo&&); |
| 33 | |
| 34 ~CategoryInfo(); | 35 ~CategoryInfo(); |
| 35 | 36 |
| 36 // Localized title of the category. | 37 // Localized title of the category. |
| 37 const base::string16& title() const { return title_; } | 38 const base::string16& title() const { return title_; } |
| 38 | 39 |
| 39 // Layout of the cards to be used to display suggestions in this category. | 40 // Layout of the cards to be used to display suggestions in this category. |
| 40 ContentSuggestionsCardLayout card_layout() const { return card_layout_; } | 41 ContentSuggestionsCardLayout card_layout() const { return card_layout_; } |
| 41 | 42 |
| 42 // Whether the category should show a "More" button even if it's not empty | 43 // Whether the category supports a "More" action, that triggers fetching more |
| 43 // (there's always a "More" or "Reload" button if it is empty). The button | 44 // suggestions for the category, while keeping the current ones. |
| 44 // either triggers a fixed action (like opening a native page) or, if there | 45 bool has_more_action() const { return has_more_action_; } |
| 45 // is no such fixed action, it queries the provider for more suggestions. | 46 |
| 46 // TODO(treib): Rename this to "always_show_more_button". | 47 // Whether the category supports a "Reload" action, that triggers fetching new |
| 47 bool has_more_button() const { return has_more_button_; } | 48 // suggestions to replace the current ones. |
| 49 bool has_reload_action() const { return has_reload_action_; } |
| 50 |
| 51 // Whether the category supports a "ViewAll" action, that triggers displaying |
| 52 // all the content related to the current categories. |
| 53 bool has_view_all_action() const { return has_view_all_action_; } |
| 48 | 54 |
| 49 // Whether this category should be shown if it offers no suggestions. | 55 // Whether this category should be shown if it offers no suggestions. |
| 50 bool show_if_empty() const { return show_if_empty_; } | 56 bool show_if_empty() const { return show_if_empty_; } |
| 51 | 57 |
| 52 // The message to show if there are no suggestions in this category. Note that | 58 // The message to show if there are no suggestions in this category. Note that |
| 53 // this matters even if |show_if_empty()| is false: The message still shows | 59 // this matters even if |show_if_empty()| is false: The message still shows |
| 54 // up when the user dismisses all suggestions in the category. | 60 // up when the user dismisses all suggestions in the category. |
| 55 const base::string16& no_suggestions_message() const { | 61 const base::string16& no_suggestions_message() const { |
| 56 return no_suggestions_message_; | 62 return no_suggestions_message_; |
| 57 } | 63 } |
| 58 | 64 |
| 59 private: | 65 private: |
| 60 base::string16 title_; | 66 base::string16 title_; |
| 61 ContentSuggestionsCardLayout card_layout_; | 67 ContentSuggestionsCardLayout card_layout_; |
| 62 bool has_more_button_; | 68 |
| 69 // Supported actions for the category. |
| 70 bool has_more_action_; |
| 71 bool has_reload_action_; |
| 72 bool has_view_all_action_; |
| 73 |
| 74 // Whether to show the category if a fetch returns no suggestions. |
| 63 bool show_if_empty_; | 75 bool show_if_empty_; |
| 64 base::string16 no_suggestions_message_; | 76 base::string16 no_suggestions_message_; |
| 65 | 77 |
| 66 DISALLOW_COPY_AND_ASSIGN(CategoryInfo); | 78 DISALLOW_COPY_AND_ASSIGN(CategoryInfo); |
| 67 }; | 79 }; |
| 68 | 80 |
| 69 } // namespace ntp_snippets | 81 } // namespace ntp_snippets |
| 70 | 82 |
| 71 #endif // COMPONENTS_NTP_SNIPPETS_CATEGORY_INFO_H_ | 83 #endif // COMPONENTS_NTP_SNIPPETS_CATEGORY_INFO_H_ |
| OLD | NEW |