Chromium Code Reviews| 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 supports a "More" button. The button either triggers |
| 42 // a fixed action (like opening a native page) or, if there is no such fixed | 43 // a fixed action (like opening a native page) or, if there is no such fixed |
| 43 // action, it queries the provider for more suggestions. | 44 // action, it queries the provider for more suggestions. |
| 44 bool has_more_button() const { return has_more_button_; } | 45 bool has_more_button() const { return has_more_button_; } |
|
Marc Treib
2016/10/26 12:39:01
(Unrelated to this change, but:) Both the comment
dgn
2016/10/26 14:05:40
Yes, that would be a nice follow up CL. or "always
Marc Treib
2016/10/26 14:29:09
I updated the comment and added a TODO for now.
dgn
2016/10/26 16:00:33
Oh nvm. It is directly provided from c++ when crea
| |
| 45 | 46 |
| 46 // Whether this category should be shown if it offers no suggestions. | 47 // Whether this category should be shown if it offers no suggestions. |
| 47 bool show_if_empty() const { return show_if_empty_; } | 48 bool show_if_empty() const { return show_if_empty_; } |
| 48 | 49 |
| 50 // The message to show if there are no suggestions in this category. Note that | |
| 51 // this matters even if |show_if_empty()| is false: The message still shows | |
| 52 // up when the user dismisses all suggestions in the category. | |
| 53 const base::string16& no_suggestions_message() const { | |
| 54 return no_suggestions_message_; | |
| 55 } | |
| 56 | |
| 49 private: | 57 private: |
| 50 base::string16 title_; | 58 base::string16 title_; |
| 51 ContentSuggestionsCardLayout card_layout_; | 59 ContentSuggestionsCardLayout card_layout_; |
| 52 bool has_more_button_; | 60 bool has_more_button_; |
| 53 bool show_if_empty_; | 61 bool show_if_empty_; |
| 62 base::string16 no_suggestions_message_; | |
| 54 | 63 |
| 55 DISALLOW_COPY_AND_ASSIGN(CategoryInfo); | 64 DISALLOW_COPY_AND_ASSIGN(CategoryInfo); |
| 56 }; | 65 }; |
| 57 | 66 |
| 58 } // namespace ntp_snippets | 67 } // namespace ntp_snippets |
| 59 | 68 |
| 60 #endif // COMPONENTS_NTP_SNIPPETS_CATEGORY_INFO_H_ | 69 #endif // COMPONENTS_NTP_SNIPPETS_CATEGORY_INFO_H_ |
| OLD | NEW |