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

Unified Diff: components/ntp_snippets/reading_list/reading_list_suggestions_provider.cc

Issue 2780793002: Add extra information for ReadingList ContentSuggestion (Closed)
Patch Set: Address comments Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: components/ntp_snippets/reading_list/reading_list_suggestions_provider.cc
diff --git a/components/ntp_snippets/reading_list/reading_list_suggestions_provider.cc b/components/ntp_snippets/reading_list/reading_list_suggestions_provider.cc
index c8ea627d2a8412eaff87daf7996c34745aadafc0..2cc1a016bae68df9733f986e7c4eead10a825ddf 100644
--- a/components/ntp_snippets/reading_list/reading_list_suggestions_provider.cc
+++ b/components/ntp_snippets/reading_list/reading_list_suggestions_provider.cc
@@ -8,9 +8,11 @@
#include <vector>
#include "base/bind.h"
+#include "base/memory/ptr_util.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
#include "components/ntp_snippets/category.h"
+#include "components/ntp_snippets/reading_list/reading_list_distillation_state_util.h"
#include "components/reading_list/core/reading_list_entry.h"
#include "components/reading_list/core/reading_list_model.h"
#include "components/strings/grit/components_strings.h"
@@ -149,13 +151,7 @@ void ReadingListSuggestionsProvider::FetchReadingListInternal() {
std::vector<ContentSuggestion> suggestions;
for (const ReadingListEntry* entry : entries) {
- ContentSuggestion suggestion(provided_category_, entry->URL().spec(),
- entry->URL());
-
- suggestion.set_title(base::UTF8ToUTF16(entry->Title()));
- suggestion.set_snippet_text(
- url_formatter::FormatUrl(entry->URL().GetOrigin()));
- suggestions.emplace_back(std::move(suggestion));
+ suggestions.emplace_back(ConvertEntry(entry));
}
NotifyStatusChanged(CategoryStatus::AVAILABLE);
@@ -163,6 +159,24 @@ void ReadingListSuggestionsProvider::FetchReadingListInternal() {
std::move(suggestions));
}
+ContentSuggestion ReadingListSuggestionsProvider::ConvertEntry(
+ const ReadingListEntry* entry) {
+ ContentSuggestion suggestion(provided_category_, entry->URL().spec(),
+ entry->URL());
+ suggestion.set_title(base::UTF8ToUTF16(entry->Title()));
+ suggestion.set_snippet_text(
Marc Treib 2017/03/29 08:24:58 As per the comment on the other CL, I think this s
gambard 2017/03/29 09:54:07 Wasn't rebased yet. Done.
+ url_formatter::FormatUrl(entry->URL().GetOrigin()));
+
+ auto extra = base::MakeUnique<ReadingListSuggestionExtra>();
+ extra->distilled_state =
+ SuggestionStateFromReadingListState(entry->DistilledState());
+ extra->favicon_page_url =
+ entry->DistilledURL().is_valid() ? entry->DistilledURL() : entry->URL();
+ suggestion.set_reading_list_suggestion_extra(std::move(extra));
+
+ return suggestion;
+}
+
void ReadingListSuggestionsProvider::NotifyStatusChanged(
CategoryStatus new_status) {
if (category_status_ == new_status) {

Powered by Google App Engine
This is Rietveld 408576698