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 // On Android builds, a Java counterpart will be generated for this enum. |
| 24 // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.suggestions |
| 25 enum class ContentSuggestionsAdditionalAction { |
| 26 // No additional action available. |
| 27 NONE, |
| 28 |
| 29 // More suggestions can be fetched using the Fetch methods with this category. |
| 30 FETCH, |
| 31 |
| 32 // Open a new surface dedicated to the content related to this category. The |
| 33 // UI has to choose which surface to open. |
| 34 VIEW_ALL |
| 35 }; |
| 36 |
23 // Contains static meta information about a Category. | 37 // Contains static meta information about a Category. |
24 class CategoryInfo { | 38 class CategoryInfo { |
25 public: | 39 public: |
26 CategoryInfo(const base::string16& title, | 40 CategoryInfo(const base::string16& title, |
27 ContentSuggestionsCardLayout card_layout, | 41 ContentSuggestionsCardLayout card_layout, |
28 bool has_fetch_action, | 42 ContentSuggestionsAdditionalAction additional_action, |
29 bool has_view_all_action, | |
30 bool show_if_empty, | 43 bool show_if_empty, |
31 const base::string16& no_suggestions_message); | 44 const base::string16& no_suggestions_message); |
32 CategoryInfo() = delete; | 45 CategoryInfo() = delete; |
33 CategoryInfo(CategoryInfo&&); | 46 CategoryInfo(CategoryInfo&&); |
34 CategoryInfo(const CategoryInfo&); | 47 CategoryInfo(const CategoryInfo&); |
35 CategoryInfo& operator=(CategoryInfo&&); | 48 CategoryInfo& operator=(CategoryInfo&&); |
36 CategoryInfo& operator=(const CategoryInfo&); | 49 CategoryInfo& operator=(const CategoryInfo&); |
37 ~CategoryInfo(); | 50 ~CategoryInfo(); |
38 | 51 |
39 // Localized title of the category. | 52 // Localized title of the category. |
40 const base::string16& title() const { return title_; } | 53 const base::string16& title() const { return title_; } |
41 | 54 |
42 // Layout of the cards to be used to display suggestions in this category. | 55 // Layout of the cards to be used to display suggestions in this category. |
43 ContentSuggestionsCardLayout card_layout() const { return card_layout_; } | 56 ContentSuggestionsCardLayout card_layout() const { return card_layout_; } |
44 | 57 |
45 // Whether the category supports a "Fetch" action, that triggers fetching more | 58 // Supported action for the category. |
46 // suggestions for the category. | 59 ContentSuggestionsAdditionalAction additional_action() const { |
47 bool has_fetch_action() const { return has_fetch_action_; } | 60 return additional_action_; |
48 | 61 } |
49 // Whether the category supports a "ViewAll" action, that triggers displaying | |
50 // all the content related to the current categories. | |
51 bool has_view_all_action() const { return has_view_all_action_; } | |
52 | 62 |
53 // Whether this category should be shown if it offers no suggestions. | 63 // Whether this category should be shown if it offers no suggestions. |
54 bool show_if_empty() const { return show_if_empty_; } | 64 bool show_if_empty() const { return show_if_empty_; } |
55 | 65 |
56 // The message to show if there are no suggestions in this category. Note that | 66 // The message to show if there are no suggestions in this category. Note that |
57 // this matters even if |show_if_empty()| is false: The message still shows | 67 // this matters even if |show_if_empty()| is false: The message still shows |
58 // up when the user dismisses all suggestions in the category. | 68 // up when the user dismisses all suggestions in the category. |
59 const base::string16& no_suggestions_message() const { | 69 const base::string16& no_suggestions_message() const { |
60 return no_suggestions_message_; | 70 return no_suggestions_message_; |
61 } | 71 } |
62 | 72 |
63 private: | 73 private: |
64 base::string16 title_; | 74 base::string16 title_; |
65 ContentSuggestionsCardLayout card_layout_; | 75 ContentSuggestionsCardLayout card_layout_; |
66 | 76 |
67 // Supported actions for the category. | 77 ContentSuggestionsAdditionalAction additional_action_; |
68 bool has_fetch_action_; | |
69 bool has_view_all_action_; | |
70 | 78 |
71 // Whether to show the category if a fetch returns no suggestions. | 79 // Whether to show the category if a fetch returns no suggestions. |
72 bool show_if_empty_; | 80 bool show_if_empty_; |
73 base::string16 no_suggestions_message_; | 81 base::string16 no_suggestions_message_; |
74 }; | 82 }; |
75 | 83 |
76 } // namespace ntp_snippets | 84 } // namespace ntp_snippets |
77 | 85 |
78 #endif // COMPONENTS_NTP_SNIPPETS_CATEGORY_INFO_H_ | 86 #endif // COMPONENTS_NTP_SNIPPETS_CATEGORY_INFO_H_ |
OLD | NEW |