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

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 comments and copyright headers in NTPSnippet, NTPSnippetsService and new Snippet classes, rem… 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
Index: components/ntp_snippets/ntp_snippet.cc
diff --git a/components/ntp_snippets/ntp_snippet.cc b/components/ntp_snippets/ntp_snippet.cc
index d7ca20c3392fd76c088a5de45aff7ebf92527627..5e2835e93bbdd433bbabf1ed8103044cb7c6887c 100644
--- a/components/ntp_snippets/ntp_snippet.cc
+++ b/components/ntp_snippets/ntp_snippet.cc
@@ -8,6 +8,9 @@
#include "base/strings/stringprintf.h"
#include "base/values.h"
#include "components/ntp_snippets/proto/ntp_snippets.pb.h"
+#include "components/ntp_snippets/snippet.h"
+#include "components/ntp_snippets/snippet_category.h"
+#include "components/ntp_snippets/snippet_provider_type.h"
namespace {
@@ -221,6 +224,19 @@ SnippetProto NTPSnippet::ToProto() const {
return result;
}
+std::unique_ptr<Snippet> NTPSnippet::ToSnippet() const {
+ std::unique_ptr<Snippet> result(new Snippet(
+ id_, SnippetProviderType::ARTICLES, SnippetCategory::ARTICLE));
+ result->set_url(best_source().url);
+ result->set_amp_url(best_source().amp_url);
+ result->set_title(title_);
+ result->set_text_extract(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;

Powered by Google App Engine
This is Rietveld 408576698