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

Unified Diff: components/ntp_snippets/ntp_snippet.cc

Issue 2059203002: Add ContentSuggestion, ContentSuggestionCategory and ContentSuggestionProviderType (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed includes Created 4 years, 6 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
« no previous file with comments | « components/ntp_snippets/ntp_snippet.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_snippets/ntp_snippet.cc
diff --git a/components/ntp_snippets/ntp_snippet.cc b/components/ntp_snippets/ntp_snippet.cc
index d56528508a59eab0073c5c12937c836b0f4f33e8..125ec5199b2b1af20af0e86179699b262bc62455 100644
--- a/components/ntp_snippets/ntp_snippet.cc
+++ b/components/ntp_snippets/ntp_snippet.cc
@@ -8,6 +8,9 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/values.h"
+#include "components/ntp_snippets/content_suggestion.h"
+#include "components/ntp_snippets/content_suggestion_category.h"
+#include "components/ntp_snippets/content_suggestions_provider_type.h"
#include "components/ntp_snippets/proto/ntp_snippets.pb.h"
namespace {
@@ -250,6 +253,19 @@ SnippetProto NTPSnippet::ToProto() const {
return result;
}
+std::unique_ptr<ContentSuggestion> NTPSnippet::ToContentSuggestion() const {
+ std::unique_ptr<ContentSuggestion> result(new ContentSuggestion(
+ id_, ContentSuggestionsProviderType::ARTICLES,
+ ContentSuggestionCategory::ARTICLE, best_source().url));
+ result->set_amp_url(best_source().amp_url);
+ result->set_title(title_);
+ result->set_snippet_text(snippet_);
+ result->set_publish_date(publish_date_);
+ result->set_publisher_name(best_source().publisher_name);
+ result->set_score(score_);
+ return result;
+}
+
// static
base::Time NTPSnippet::TimeFromJsonString(const std::string& timestamp_str) {
int64_t timestamp;
« no previous file with comments | « components/ntp_snippets/ntp_snippet.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698