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

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
« no previous file with comments | « components/ntp_snippets/BUILD.gn ('k') | components/ntp_snippets/content_suggestion.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 the meaningful extract of
53 // ReadingListEntry::DistillationState for the suggestions. It is duplicated
54 // here to avoid a dependence on ReadingList.
55 enum class ReadingListSuggestionDistilledState { PENDING, SUCCESS, FAILURE };
56
57 // State of the distillation of the suggestion.
58 ReadingListSuggestionDistilledState distilled_state =
59 ReadingListSuggestionDistilledState::PENDING;
60 // URL of the page whose favicon should be displayed for this suggestion.
61 GURL favicon_page_url;
62 };
63
49 // Contains additional data for notification-worthy suggestions. 64 // Contains additional data for notification-worthy suggestions.
50 struct NotificationExtra { 65 struct NotificationExtra {
51 // Deadline for showing notification. If the deadline is past, the 66 // Deadline for showing notification. If the deadline is past, the
52 // notification is no longer fresh and no notification should be sent. If the 67 // 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. 68 // deadline passes while a notification is up, it should be canceled.
54 base::Time deadline; 69 base::Time deadline;
55 }; 70 };
56 71
57 // A content suggestion for the new tab page, which can be an article or an 72 // A content suggestion for the new tab page, which can be an article or an
58 // offline page, for example. 73 // offline page, for example.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 std::unique_ptr<DownloadSuggestionExtra> download_suggestion_extra); 152 std::unique_ptr<DownloadSuggestionExtra> download_suggestion_extra);
138 153
139 // Extra information for recent tab suggestions. Only available for 154 // Extra information for recent tab suggestions. Only available for
140 // KnownCategories::RECENT_TABS suggestions. 155 // KnownCategories::RECENT_TABS suggestions.
141 RecentTabSuggestionExtra* recent_tab_suggestion_extra() const { 156 RecentTabSuggestionExtra* recent_tab_suggestion_extra() const {
142 return recent_tab_suggestion_extra_.get(); 157 return recent_tab_suggestion_extra_.get();
143 } 158 }
144 void set_recent_tab_suggestion_extra( 159 void set_recent_tab_suggestion_extra(
145 std::unique_ptr<RecentTabSuggestionExtra> recent_tab_suggestion_extra); 160 std::unique_ptr<RecentTabSuggestionExtra> recent_tab_suggestion_extra);
146 161
162 // Extra information for reading list suggestions. Only available for
163 // KnownCategories::READING_LIST suggestions.
164 ReadingListSuggestionExtra* reading_list_suggestion_extra() const {
165 return reading_list_suggestion_extra_.get();
166 }
167 void set_reading_list_suggestion_extra(
168 std::unique_ptr<ReadingListSuggestionExtra>
169 reading_list_suggestion_extra);
170
147 // Extra information for notifications. When absent, no notification should be 171 // Extra information for notifications. When absent, no notification should be
148 // sent for this suggestion. When present, a notification should be sent, 172 // sent for this suggestion. When present, a notification should be sent,
149 // unless other factors disallow it (examples: the extra parameters say to; 173 // unless other factors disallow it (examples: the extra parameters say to;
150 // notifications are disabled; Chrome is in the foreground). 174 // notifications are disabled; Chrome is in the foreground).
151 NotificationExtra* notification_extra() const { 175 NotificationExtra* notification_extra() const {
152 return notification_extra_.get(); 176 return notification_extra_.get();
153 } 177 }
154 void set_notification_extra( 178 void set_notification_extra(
155 std::unique_ptr<NotificationExtra> notification_extra); 179 std::unique_ptr<NotificationExtra> notification_extra);
156 180
157 const base::Time& fetch_date() const { return fetch_date_; } 181 const base::Time& fetch_date() const { return fetch_date_; }
158 void set_fetch_date(const base::Time& fetch_date) { 182 void set_fetch_date(const base::Time& fetch_date) {
159 fetch_date_ = fetch_date; 183 fetch_date_ = fetch_date;
160 } 184 }
161 185
162 private: 186 private:
163 ID id_; 187 ID id_;
164 GURL url_; 188 GURL url_;
165 base::string16 title_; 189 base::string16 title_;
166 base::string16 snippet_text_; 190 base::string16 snippet_text_;
167 base::Time publish_date_; 191 base::Time publish_date_;
168 base::string16 publisher_name_; 192 base::string16 publisher_name_;
169 float score_; 193 float score_;
170 std::unique_ptr<DownloadSuggestionExtra> download_suggestion_extra_; 194 std::unique_ptr<DownloadSuggestionExtra> download_suggestion_extra_;
171 std::unique_ptr<RecentTabSuggestionExtra> recent_tab_suggestion_extra_; 195 std::unique_ptr<RecentTabSuggestionExtra> recent_tab_suggestion_extra_;
196 std::unique_ptr<ReadingListSuggestionExtra> reading_list_suggestion_extra_;
172 std::unique_ptr<NotificationExtra> notification_extra_; 197 std::unique_ptr<NotificationExtra> notification_extra_;
173 198
174 // The time when the remote suggestion was fetched from the server. This field 199 // The time when the remote suggestion was fetched from the server. This field
175 // is only populated when the ContentSuggestion is created from a 200 // is only populated when the ContentSuggestion is created from a
176 // RemoteSuggestion. 201 // RemoteSuggestion.
177 base::Time fetch_date_; 202 base::Time fetch_date_;
178 203
179 DISALLOW_COPY_AND_ASSIGN(ContentSuggestion); 204 DISALLOW_COPY_AND_ASSIGN(ContentSuggestion);
180 }; 205 };
181 206
182 std::ostream& operator<<(std::ostream& os, const ContentSuggestion::ID& id); 207 std::ostream& operator<<(std::ostream& os, const ContentSuggestion::ID& id);
183 208
184 } // namespace ntp_snippets 209 } // namespace ntp_snippets
185 210
186 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTION_H_ 211 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTION_H_
OLDNEW
« no previous file with comments | « components/ntp_snippets/BUILD.gn ('k') | components/ntp_snippets/content_suggestion.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698