 Chromium Code Reviews
 Chromium Code Reviews Issue 2780793002:
  Add extra information for ReadingList ContentSuggestion  (Closed)
    
  
    Issue 2780793002:
  Add extra information for ReadingList ContentSuggestion  (Closed) 
  | 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 | 
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" | 
| 12 #include "base/macros.h" | 12 #include "base/macros.h" | 
| 13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" | 
| 14 #include "base/time/time.h" | 14 #include "base/time/time.h" | 
| 15 #include "components/ntp_snippets/category.h" | 15 #include "components/ntp_snippets/category.h" | 
| 16 #include "url/gurl.h" | 16 #include "url/gurl.h" | 
| 17 | 17 | 
| 18 namespace ntp_snippets { | 18 namespace ntp_snippets { | 
| 19 | 19 | 
| 20 // ReadingListSuggestionExtra contains addition data which is only available for | |
| 
Marc Treib
2017/03/28 13:38:20
nit: s/addition/additional/
nit: Keep the order c
 
gambard
2017/03/29 06:51:24
Done.
 | |
| 21 // Reading List suggestions. | |
| 22 struct ReadingListSuggestionExtra { | |
| 23 // State of the distillation a suggestion. | |
| 
Olivier
2017/03/28 13:43:45
Whi not use ReadingListEntry::DistillationState ?
 
gambard
2017/03/29 06:51:24
I am not using ReadingListEntry::DistillationState
 | |
| 24 enum class ReadingListSuggestionDistilledState { | |
| 25 PROCESSING, | |
| 26 SUCCESS, | |
| 27 FAILURE | |
| 28 }; | |
| 29 | |
| 30 // State of the distillation of the suggestion. | |
| 31 ReadingListSuggestionDistilledState distilled_state; | |
| 32 // URL of the page whose favicon should be displayed for this suggestion. | |
| 33 GURL favicon_page_url; | |
| 
Marc Treib
2017/03/28 13:38:20
Can't this be derived from the URL?
Generally, +jk
 
gambard
2017/03/29 06:51:24
No, this is specific to ReadingList: you can have
 
Marc Treib
2017/03/29 08:24:58
Redirects are officially The Worst :(
Alright then
 | |
| 34 }; | |
| 35 | |
| 20 // DownloadSuggestionExtra contains additional data which is only available for | 36 // DownloadSuggestionExtra contains additional data which is only available for | 
| 21 // download suggestions. | 37 // download suggestions. | 
| 22 struct DownloadSuggestionExtra { | 38 struct DownloadSuggestionExtra { | 
| 23 DownloadSuggestionExtra(); | 39 DownloadSuggestionExtra(); | 
| 24 DownloadSuggestionExtra(const DownloadSuggestionExtra&); | 40 DownloadSuggestionExtra(const DownloadSuggestionExtra&); | 
| 25 ~DownloadSuggestionExtra(); | 41 ~DownloadSuggestionExtra(); | 
| 26 | 42 | 
| 27 // The GUID for the downloaded file. | 43 // The GUID for the downloaded file. | 
| 28 std::string download_guid; | 44 std::string download_guid; | 
| 29 // The file path of the downloaded file once download completes. | 45 // The file path of the downloaded file once download completes. | 
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 std::unique_ptr<DownloadSuggestionExtra> download_suggestion_extra); | 153 std::unique_ptr<DownloadSuggestionExtra> download_suggestion_extra); | 
| 138 | 154 | 
| 139 // Extra information for recent tab suggestions. Only available for | 155 // Extra information for recent tab suggestions. Only available for | 
| 140 // KnownCategories::RECENT_TABS suggestions. | 156 // KnownCategories::RECENT_TABS suggestions. | 
| 141 RecentTabSuggestionExtra* recent_tab_suggestion_extra() const { | 157 RecentTabSuggestionExtra* recent_tab_suggestion_extra() const { | 
| 142 return recent_tab_suggestion_extra_.get(); | 158 return recent_tab_suggestion_extra_.get(); | 
| 143 } | 159 } | 
| 144 void set_recent_tab_suggestion_extra( | 160 void set_recent_tab_suggestion_extra( | 
| 145 std::unique_ptr<RecentTabSuggestionExtra> recent_tab_suggestion_extra); | 161 std::unique_ptr<RecentTabSuggestionExtra> recent_tab_suggestion_extra); | 
| 146 | 162 | 
| 163 // Extra information for reading list suggestions. Only available for | |
| 164 // KnownCategories::READING_LIST suggestions. | |
| 165 ReadingListSuggestionExtra* reading_list_suggestion_extra() const { | |
| 166 return reading_list_suggestion_extra_.get(); | |
| 167 } | |
| 168 void set_reading_list_suggestion_extra( | |
| 169 std::unique_ptr<ReadingListSuggestionExtra> | |
| 170 reading_list_suggestion_extra); | |
| 171 | |
| 147 // Extra information for notifications. When absent, no notification should be | 172 // Extra information for notifications. When absent, no notification should be | 
| 148 // sent for this suggestion. When present, a notification should be sent, | 173 // sent for this suggestion. When present, a notification should be sent, | 
| 149 // unless other factors disallow it (examples: the extra parameters say to; | 174 // unless other factors disallow it (examples: the extra parameters say to; | 
| 150 // notifications are disabled; Chrome is in the foreground). | 175 // notifications are disabled; Chrome is in the foreground). | 
| 151 NotificationExtra* notification_extra() const { | 176 NotificationExtra* notification_extra() const { | 
| 152 return notification_extra_.get(); | 177 return notification_extra_.get(); | 
| 153 } | 178 } | 
| 154 void set_notification_extra( | 179 void set_notification_extra( | 
| 155 std::unique_ptr<NotificationExtra> notification_extra); | 180 std::unique_ptr<NotificationExtra> notification_extra); | 
| 156 | 181 | 
| 157 const base::Time& fetch_date() const { return fetch_date_; } | 182 const base::Time& fetch_date() const { return fetch_date_; } | 
| 158 void set_fetch_date(const base::Time& fetch_date) { | 183 void set_fetch_date(const base::Time& fetch_date) { | 
| 159 fetch_date_ = fetch_date; | 184 fetch_date_ = fetch_date; | 
| 160 } | 185 } | 
| 161 | 186 | 
| 162 private: | 187 private: | 
| 163 ID id_; | 188 ID id_; | 
| 164 GURL url_; | 189 GURL url_; | 
| 165 base::string16 title_; | 190 base::string16 title_; | 
| 166 base::string16 snippet_text_; | 191 base::string16 snippet_text_; | 
| 167 base::Time publish_date_; | 192 base::Time publish_date_; | 
| 168 base::string16 publisher_name_; | 193 base::string16 publisher_name_; | 
| 169 float score_; | 194 float score_; | 
| 170 std::unique_ptr<DownloadSuggestionExtra> download_suggestion_extra_; | 195 std::unique_ptr<DownloadSuggestionExtra> download_suggestion_extra_; | 
| 171 std::unique_ptr<RecentTabSuggestionExtra> recent_tab_suggestion_extra_; | 196 std::unique_ptr<RecentTabSuggestionExtra> recent_tab_suggestion_extra_; | 
| 197 std::unique_ptr<ReadingListSuggestionExtra> reading_list_suggestion_extra_; | |
| 172 std::unique_ptr<NotificationExtra> notification_extra_; | 198 std::unique_ptr<NotificationExtra> notification_extra_; | 
| 173 | 199 | 
| 174 // The time when the remote suggestion was fetched from the server. This field | 200 // The time when the remote suggestion was fetched from the server. This field | 
| 175 // is only populated when the ContentSuggestion is created from a | 201 // is only populated when the ContentSuggestion is created from a | 
| 176 // RemoteSuggestion. | 202 // RemoteSuggestion. | 
| 177 base::Time fetch_date_; | 203 base::Time fetch_date_; | 
| 178 | 204 | 
| 179 DISALLOW_COPY_AND_ASSIGN(ContentSuggestion); | 205 DISALLOW_COPY_AND_ASSIGN(ContentSuggestion); | 
| 180 }; | 206 }; | 
| 181 | 207 | 
| 182 std::ostream& operator<<(std::ostream& os, const ContentSuggestion::ID& id); | 208 std::ostream& operator<<(std::ostream& os, const ContentSuggestion::ID& id); | 
| 183 | 209 | 
| 184 } // namespace ntp_snippets | 210 } // namespace ntp_snippets | 
| 185 | 211 | 
| 186 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTION_H_ | 212 #endif // COMPONENTS_NTP_SNIPPETS_CONTENT_SUGGESTION_H_ | 
| OLD | NEW |