Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(859)

Side by Side Diff: components/ntp_snippets/content_suggestion.h

Issue 2780793002: Add extra information for ReadingList ContentSuggestion (Closed)
Patch Set: Address comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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.
Olivier 2017/03/30 08:51:11 nit s/prevent/avoid/ ?
gambard 2017/03/30 08:59:09 Done.
55 enum class ReadingListSuggestionDistilledState {
56 PROCESSING,
Olivier 2017/03/30 08:51:11 The enums are not synced at the moment. can you co
gambard 2017/03/30 08:59:09 Done.
57 SUCCESS,
58 FAILURE
59 };
60
61 // State of the distillation of the suggestion.
62 ReadingListSuggestionDistilledState distilled_state =
63 ReadingListSuggestionDistilledState::PROCESSING;
64 // URL of the page whose favicon should be displayed for this suggestion.
65 GURL favicon_page_url;
66 };
67
49 // Contains additional data for notification-worthy suggestions. 68 // Contains additional data for notification-worthy suggestions.
50 struct NotificationExtra { 69 struct NotificationExtra {
51 // Deadline for showing notification. If the deadline is past, the 70 // Deadline for showing notification. If the deadline is past, the
52 // notification is no longer fresh and no notification should be sent. If the 71 // 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. 72 // deadline passes while a notification is up, it should be canceled.
54 base::Time deadline; 73 base::Time deadline;
55 }; 74 };
56 75
57 // A content suggestion for the new tab page, which can be an article or an 76 // A content suggestion for the new tab page, which can be an article or an
58 // offline page, for example. 77 // offline page, for example.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 std::unique_ptr<DownloadSuggestionExtra> download_suggestion_extra); 156 std::unique_ptr<DownloadSuggestionExtra> download_suggestion_extra);
138 157
139 // Extra information for recent tab suggestions. Only available for 158 // Extra information for recent tab suggestions. Only available for
140 // KnownCategories::RECENT_TABS suggestions. 159 // KnownCategories::RECENT_TABS suggestions.
141 RecentTabSuggestionExtra* recent_tab_suggestion_extra() const { 160 RecentTabSuggestionExtra* recent_tab_suggestion_extra() const {
142 return recent_tab_suggestion_extra_.get(); 161 return recent_tab_suggestion_extra_.get();
143 } 162 }
144 void set_recent_tab_suggestion_extra( 163 void set_recent_tab_suggestion_extra(
145 std::unique_ptr<RecentTabSuggestionExtra> recent_tab_suggestion_extra); 164 std::unique_ptr<RecentTabSuggestionExtra> recent_tab_suggestion_extra);
146 165
166 // Extra information for reading list suggestions. Only available for
167 // KnownCategories::READING_LIST suggestions.
168 ReadingListSuggestionExtra* reading_list_suggestion_extra() const {
169 return reading_list_suggestion_extra_.get();
170 }
171 void set_reading_list_suggestion_extra(
172 std::unique_ptr<ReadingListSuggestionExtra>
173 reading_list_suggestion_extra);
174
147 // Extra information for notifications. When absent, no notification should be 175 // Extra information for notifications. When absent, no notification should be
148 // sent for this suggestion. When present, a notification should be sent, 176 // sent for this suggestion. When present, a notification should be sent,
149 // unless other factors disallow it (examples: the extra parameters say to; 177 // unless other factors disallow it (examples: the extra parameters say to;
150 // notifications are disabled; Chrome is in the foreground). 178 // notifications are disabled; Chrome is in the foreground).
151 NotificationExtra* notification_extra() const { 179 NotificationExtra* notification_extra() const {
152 return notification_extra_.get(); 180 return notification_extra_.get();
153 } 181 }
154 void set_notification_extra( 182 void set_notification_extra(
155 std::unique_ptr<NotificationExtra> notification_extra); 183 std::unique_ptr<NotificationExtra> notification_extra);
156 184
157 const base::Time& fetch_date() const { return fetch_date_; } 185 const base::Time& fetch_date() const { return fetch_date_; }
158 void set_fetch_date(const base::Time& fetch_date) { 186 void set_fetch_date(const base::Time& fetch_date) {
159 fetch_date_ = fetch_date; 187 fetch_date_ = fetch_date;
160 } 188 }
161 189
162 private: 190 private:
163 ID id_; 191 ID id_;
164 GURL url_; 192 GURL url_;
165 base::string16 title_; 193 base::string16 title_;
166 base::string16 snippet_text_; 194 base::string16 snippet_text_;
167 base::Time publish_date_; 195 base::Time publish_date_;
168 base::string16 publisher_name_; 196 base::string16 publisher_name_;
169 float score_; 197 float score_;
170 std::unique_ptr<DownloadSuggestionExtra> download_suggestion_extra_; 198 std::unique_ptr<DownloadSuggestionExtra> download_suggestion_extra_;
171 std::unique_ptr<RecentTabSuggestionExtra> recent_tab_suggestion_extra_; 199 std::unique_ptr<RecentTabSuggestionExtra> recent_tab_suggestion_extra_;
200 std::unique_ptr<ReadingListSuggestionExtra> reading_list_suggestion_extra_;
172 std::unique_ptr<NotificationExtra> notification_extra_; 201 std::unique_ptr<NotificationExtra> notification_extra_;
173 202
174 // The time when the remote suggestion was fetched from the server. This field 203 // The time when the remote suggestion was fetched from the server. This field
175 // is only populated when the ContentSuggestion is created from a 204 // is only populated when the ContentSuggestion is created from a
176 // RemoteSuggestion. 205 // RemoteSuggestion.
177 base::Time fetch_date_; 206 base::Time fetch_date_;
178 207
179 DISALLOW_COPY_AND_ASSIGN(ContentSuggestion); 208 DISALLOW_COPY_AND_ASSIGN(ContentSuggestion);
180 }; 209 };
181 210
182 std::ostream& operator<<(std::ostream& os, const ContentSuggestion::ID& id); 211 std::ostream& operator<<(std::ostream& os, const ContentSuggestion::ID& id);
183 212
184 } // namespace ntp_snippets 213 } // namespace ntp_snippets
185 214
186 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTION_H_ 215 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698