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_button, |
29 bool show_if_empty); | 29 bool show_if_empty, |
| 30 const base::string16& no_suggestions_message); |
30 CategoryInfo(CategoryInfo&&) = default; | 31 CategoryInfo(CategoryInfo&&) = default; |
31 CategoryInfo& operator=(CategoryInfo&&) = default; | 32 CategoryInfo& operator=(CategoryInfo&&) = default; |
32 | 33 |
33 ~CategoryInfo(); | 34 ~CategoryInfo(); |
34 | 35 |
35 // Localized title of the category. | 36 // Localized title of the category. |
36 const base::string16& title() const { return title_; } | 37 const base::string16& title() const { return title_; } |
37 | 38 |
38 // Layout of the cards to be used to display suggestions in this category. | 39 // Layout of the cards to be used to display suggestions in this category. |
39 ContentSuggestionsCardLayout card_layout() const { return card_layout_; } | 40 ContentSuggestionsCardLayout card_layout() const { return card_layout_; } |
40 | 41 |
41 // Whether the category supports a "More" button. The button either triggers | 42 // Whether the category should show a "More" button even if it's not empty |
42 // a fixed action (like opening a native page) or, if there is no such fixed | 43 // (there's always a "More" or "Reload" button if it is empty). The button |
43 // action, it queries the provider for more suggestions. | 44 // either triggers a fixed action (like opening a native page) or, if there |
| 45 // is no such fixed action, it queries the provider for more suggestions. |
| 46 // TODO(treib): Rename this to "always_show_more_button". |
44 bool has_more_button() const { return has_more_button_; } | 47 bool has_more_button() const { return has_more_button_; } |
45 | 48 |
46 // Whether this category should be shown if it offers no suggestions. | 49 // Whether this category should be shown if it offers no suggestions. |
47 bool show_if_empty() const { return show_if_empty_; } | 50 bool show_if_empty() const { return show_if_empty_; } |
48 | 51 |
| 52 // 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 |
| 54 // up when the user dismisses all suggestions in the category. |
| 55 const base::string16& no_suggestions_message() const { |
| 56 return no_suggestions_message_; |
| 57 } |
| 58 |
49 private: | 59 private: |
50 base::string16 title_; | 60 base::string16 title_; |
51 ContentSuggestionsCardLayout card_layout_; | 61 ContentSuggestionsCardLayout card_layout_; |
52 bool has_more_button_; | 62 bool has_more_button_; |
53 bool show_if_empty_; | 63 bool show_if_empty_; |
| 64 base::string16 no_suggestions_message_; |
54 | 65 |
55 DISALLOW_COPY_AND_ASSIGN(CategoryInfo); | 66 DISALLOW_COPY_AND_ASSIGN(CategoryInfo); |
56 }; | 67 }; |
57 | 68 |
58 } // namespace ntp_snippets | 69 } // namespace ntp_snippets |
59 | 70 |
60 #endif // COMPONENTS_NTP_SNIPPETS_CATEGORY_INFO_H_ | 71 #endif // COMPONENTS_NTP_SNIPPETS_CATEGORY_INFO_H_ |
OLD | NEW |