| 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_CONTENT_SUGGESTION_H_ | 5 #ifndef COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTION_H_ |
| 6 #define COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTION_H_ | 6 #define COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTION_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 }; | 36 }; |
| 37 | 37 |
| 38 // Contains additional data which is only available for recent tab suggestions. | 38 // Contains additional data which is only available for recent tab suggestions. |
| 39 struct RecentTabSuggestionExtra { | 39 struct RecentTabSuggestionExtra { |
| 40 // Corresponding tab identifier. | 40 // Corresponding tab identifier. |
| 41 std::string tab_id; | 41 std::string tab_id; |
| 42 // Underlying offline page identifier. | 42 // Underlying offline page identifier. |
| 43 int64_t offline_page_id = 0; | 43 int64_t offline_page_id = 0; |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 // Contains additional data for notification-worthy suggestions. |
| 47 struct NotificationExtra { |
| 48 // Deadline for showing notification. If the deadline is past, the |
| 49 // notification is no longer fresh and no notification should be sent. If the |
| 50 // deadline passes while a notification is up, it should be canceled. |
| 51 base::Time deadline; |
| 52 }; |
| 53 |
| 46 // A content suggestion for the new tab page, which can be an article or an | 54 // A content suggestion for the new tab page, which can be an article or an |
| 47 // offline page, for example. | 55 // offline page, for example. |
| 48 class ContentSuggestion { | 56 class ContentSuggestion { |
| 49 public: | 57 public: |
| 50 class ID { | 58 class ID { |
| 51 public: | 59 public: |
| 52 ID(Category category, const std::string& id_within_category) | 60 ID(Category category, const std::string& id_within_category) |
| 53 : category_(category), id_within_category_(id_within_category) {} | 61 : category_(category), id_within_category_(id_within_category) {} |
| 54 | 62 |
| 55 Category category() const { return category_; } | 63 Category category() const { return category_; } |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 std::unique_ptr<DownloadSuggestionExtra> download_suggestion_extra); | 134 std::unique_ptr<DownloadSuggestionExtra> download_suggestion_extra); |
| 127 | 135 |
| 128 // Extra information for recent tab suggestions. Only available for | 136 // Extra information for recent tab suggestions. Only available for |
| 129 // KnownCategories::RECENT_TABS suggestions. | 137 // KnownCategories::RECENT_TABS suggestions. |
| 130 RecentTabSuggestionExtra* recent_tab_suggestion_extra() const { | 138 RecentTabSuggestionExtra* recent_tab_suggestion_extra() const { |
| 131 return recent_tab_suggestion_extra_.get(); | 139 return recent_tab_suggestion_extra_.get(); |
| 132 } | 140 } |
| 133 void set_recent_tab_suggestion_extra( | 141 void set_recent_tab_suggestion_extra( |
| 134 std::unique_ptr<RecentTabSuggestionExtra> recent_tab_suggestion_extra); | 142 std::unique_ptr<RecentTabSuggestionExtra> recent_tab_suggestion_extra); |
| 135 | 143 |
| 144 // Extra information for notifications. When absent, no notification should be |
| 145 // sent for this suggestion. When present, a notification should be sent, |
| 146 // unless other factors disallow it (examples: the extra parameters say to; |
| 147 // notifications are disabled; Chrome is in the foreground). |
| 148 NotificationExtra* notification_extra() const { |
| 149 return notification_extra_.get(); |
| 150 } |
| 151 void set_notification_extra( |
| 152 std::unique_ptr<NotificationExtra> notification_extra); |
| 153 |
| 136 private: | 154 private: |
| 137 ID id_; | 155 ID id_; |
| 138 GURL url_; | 156 GURL url_; |
| 139 base::string16 title_; | 157 base::string16 title_; |
| 140 base::string16 snippet_text_; | 158 base::string16 snippet_text_; |
| 141 base::Time publish_date_; | 159 base::Time publish_date_; |
| 142 base::string16 publisher_name_; | 160 base::string16 publisher_name_; |
| 143 float score_; | 161 float score_; |
| 144 std::unique_ptr<DownloadSuggestionExtra> download_suggestion_extra_; | 162 std::unique_ptr<DownloadSuggestionExtra> download_suggestion_extra_; |
| 145 std::unique_ptr<RecentTabSuggestionExtra> recent_tab_suggestion_extra_; | 163 std::unique_ptr<RecentTabSuggestionExtra> recent_tab_suggestion_extra_; |
| 164 std::unique_ptr<NotificationExtra> notification_extra_; |
| 146 | 165 |
| 147 DISALLOW_COPY_AND_ASSIGN(ContentSuggestion); | 166 DISALLOW_COPY_AND_ASSIGN(ContentSuggestion); |
| 148 }; | 167 }; |
| 149 | 168 |
| 150 std::ostream& operator<<(std::ostream& os, const ContentSuggestion::ID& id); | 169 std::ostream& operator<<(std::ostream& os, const ContentSuggestion::ID& id); |
| 151 | 170 |
| 152 } // namespace ntp_snippets | 171 } // namespace ntp_snippets |
| 153 | 172 |
| 154 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTION_H_ | 173 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTION_H_ |
| OLD | NEW |