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_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 28 matching lines...) Expand all Loading... | |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 // Contains additional data which is only available for recent tab suggestions. | 41 // Contains additional data which is only available for recent tab suggestions. |
| 42 struct RecentTabSuggestionExtra { | 42 struct RecentTabSuggestionExtra { |
| 43 // Corresponding tab identifier. | 43 // Corresponding tab identifier. |
| 44 int tab_id; | 44 int tab_id; |
| 45 // Underlying offline page identifier. | 45 // Underlying offline page identifier. |
| 46 int64_t offline_page_id = 0; | 46 int64_t offline_page_id = 0; |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 // ReadingListSuggestionExtra contains additional data which is only available | |
| 50 // for Reading List suggestions. | |
| 51 struct ReadingListSuggestionExtra { | |
| 52 // State of the distillation a suggestion. This is a duplicate of | |
| 53 // ReadingListEntry::DistillationState and should be kept sync. It is | |
| 54 // duplicated here to prevent a dependence on ReadingList. | |
| 55 enum class ReadingListSuggestionDistilledState { | |
| 56 PROCESSING, | |
| 57 SUCCESS, | |
| 58 FAILURE | |
| 59 }; | |
| 60 | |
| 61 // State of the distillation of the suggestion. | |
| 62 ReadingListSuggestionDistilledState distilled_state; | |
|
Marc Treib
2017/03/29 08:24:58
nit: Give this a default value? (Can be inline " =
gambard
2017/03/29 09:54:07
Done.
| |
| 63 // URL of the page whose favicon should be displayed for this suggestion. | |
| 64 GURL favicon_page_url; | |
| 65 }; | |
| 66 | |
| 49 // Contains additional data for notification-worthy suggestions. | 67 // Contains additional data for notification-worthy suggestions. |
| 50 struct NotificationExtra { | 68 struct NotificationExtra { |
| 51 // Deadline for showing notification. If the deadline is past, the | 69 // Deadline for showing notification. If the deadline is past, the |
| 52 // notification is no longer fresh and no notification should be sent. If the | 70 // notification is no longer fresh and no notification should be sent. If the |
| 53 // deadline passes while a notification is up, it should be canceled. | 71 // deadline passes while a notification is up, it should be canceled. |
| 54 base::Time deadline; | 72 base::Time deadline; |
| 55 }; | 73 }; |
| 56 | 74 |
| 57 // A content suggestion for the new tab page, which can be an article or an | 75 // A content suggestion for the new tab page, which can be an article or an |
| 58 // offline page, for example. | 76 // offline page, for example. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 std::unique_ptr<DownloadSuggestionExtra> download_suggestion_extra); | 155 std::unique_ptr<DownloadSuggestionExtra> download_suggestion_extra); |
| 138 | 156 |
| 139 // Extra information for recent tab suggestions. Only available for | 157 // Extra information for recent tab suggestions. Only available for |
| 140 // KnownCategories::RECENT_TABS suggestions. | 158 // KnownCategories::RECENT_TABS suggestions. |
| 141 RecentTabSuggestionExtra* recent_tab_suggestion_extra() const { | 159 RecentTabSuggestionExtra* recent_tab_suggestion_extra() const { |
| 142 return recent_tab_suggestion_extra_.get(); | 160 return recent_tab_suggestion_extra_.get(); |
| 143 } | 161 } |
| 144 void set_recent_tab_suggestion_extra( | 162 void set_recent_tab_suggestion_extra( |
| 145 std::unique_ptr<RecentTabSuggestionExtra> recent_tab_suggestion_extra); | 163 std::unique_ptr<RecentTabSuggestionExtra> recent_tab_suggestion_extra); |
| 146 | 164 |
| 165 // Extra information for reading list suggestions. Only available for | |
| 166 // KnownCategories::READING_LIST suggestions. | |
| 167 ReadingListSuggestionExtra* reading_list_suggestion_extra() const { | |
| 168 return reading_list_suggestion_extra_.get(); | |
| 169 } | |
| 170 void set_reading_list_suggestion_extra( | |
| 171 std::unique_ptr<ReadingListSuggestionExtra> | |
| 172 reading_list_suggestion_extra); | |
| 173 | |
| 147 // Extra information for notifications. When absent, no notification should be | 174 // Extra information for notifications. When absent, no notification should be |
| 148 // sent for this suggestion. When present, a notification should be sent, | 175 // sent for this suggestion. When present, a notification should be sent, |
| 149 // unless other factors disallow it (examples: the extra parameters say to; | 176 // unless other factors disallow it (examples: the extra parameters say to; |
| 150 // notifications are disabled; Chrome is in the foreground). | 177 // notifications are disabled; Chrome is in the foreground). |
| 151 NotificationExtra* notification_extra() const { | 178 NotificationExtra* notification_extra() const { |
| 152 return notification_extra_.get(); | 179 return notification_extra_.get(); |
| 153 } | 180 } |
| 154 void set_notification_extra( | 181 void set_notification_extra( |
| 155 std::unique_ptr<NotificationExtra> notification_extra); | 182 std::unique_ptr<NotificationExtra> notification_extra); |
| 156 | 183 |
| 157 const base::Time& fetch_date() const { return fetch_date_; } | 184 const base::Time& fetch_date() const { return fetch_date_; } |
| 158 void set_fetch_date(const base::Time& fetch_date) { | 185 void set_fetch_date(const base::Time& fetch_date) { |
| 159 fetch_date_ = fetch_date; | 186 fetch_date_ = fetch_date; |
| 160 } | 187 } |
| 161 | 188 |
| 162 private: | 189 private: |
| 163 ID id_; | 190 ID id_; |
| 164 GURL url_; | 191 GURL url_; |
| 165 base::string16 title_; | 192 base::string16 title_; |
| 166 base::string16 snippet_text_; | 193 base::string16 snippet_text_; |
| 167 base::Time publish_date_; | 194 base::Time publish_date_; |
| 168 base::string16 publisher_name_; | 195 base::string16 publisher_name_; |
| 169 float score_; | 196 float score_; |
| 170 std::unique_ptr<DownloadSuggestionExtra> download_suggestion_extra_; | 197 std::unique_ptr<DownloadSuggestionExtra> download_suggestion_extra_; |
| 171 std::unique_ptr<RecentTabSuggestionExtra> recent_tab_suggestion_extra_; | 198 std::unique_ptr<RecentTabSuggestionExtra> recent_tab_suggestion_extra_; |
| 199 std::unique_ptr<ReadingListSuggestionExtra> reading_list_suggestion_extra_; | |
| 172 std::unique_ptr<NotificationExtra> notification_extra_; | 200 std::unique_ptr<NotificationExtra> notification_extra_; |
| 173 | 201 |
| 174 // The time when the remote suggestion was fetched from the server. This field | 202 // The time when the remote suggestion was fetched from the server. This field |
| 175 // is only populated when the ContentSuggestion is created from a | 203 // is only populated when the ContentSuggestion is created from a |
| 176 // RemoteSuggestion. | 204 // RemoteSuggestion. |
| 177 base::Time fetch_date_; | 205 base::Time fetch_date_; |
| 178 | 206 |
| 179 DISALLOW_COPY_AND_ASSIGN(ContentSuggestion); | 207 DISALLOW_COPY_AND_ASSIGN(ContentSuggestion); |
| 180 }; | 208 }; |
| 181 | 209 |
| 182 std::ostream& operator<<(std::ostream& os, const ContentSuggestion::ID& id); | 210 std::ostream& operator<<(std::ostream& os, const ContentSuggestion::ID& id); |
| 183 | 211 |
| 184 } // namespace ntp_snippets | 212 } // namespace ntp_snippets |
| 185 | 213 |
| 186 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTION_H_ | 214 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTION_H_ |
| OLD | NEW |