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

Unified Diff: components/ntp_snippets/content_suggestion.cc

Issue 2421463002: FetchMore functionality backend (Closed)
Patch Set: NTBR. Rebasing a lot. Created 4 years, 1 month 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/content_suggestion.cc
diff --git a/components/ntp_snippets/content_suggestion.cc b/components/ntp_snippets/content_suggestion.cc
index 1b2c3e475cb559f8d6fec97f75021de15f3d81b1..e9cfff5da1791dfd29b5c8f3ed35a69e137bd947 100644
--- a/components/ntp_snippets/content_suggestion.cc
+++ b/components/ntp_snippets/content_suggestion.cc
@@ -2,7 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <utility>
+
+#include "base/strings/utf_string_conversions.h"
#include "components/ntp_snippets/content_suggestion.h"
+#include "components/ntp_snippets/remote/ntp_snippet.h"
namespace ntp_snippets {
@@ -23,6 +27,21 @@ ContentSuggestion::ContentSuggestion(Category category,
const GURL& url)
: id_(category, id_within_category), url_(url), score_(0) {}
+ContentSuggestion ContentSuggestion::FromSnippet(Category category,
+ const NTPSnippet* snippet) {
vitaliii 2016/11/01 23:29:57 Why is this a pointer? I guess a constant link wou
fhorschig 2016/11/02 05:05:27 Dropped. (see declaration).
+ ContentSuggestion suggestion(category, snippet->id(),
+ snippet->best_source().url);
+ suggestion.set_amp_url(snippet->best_source().amp_url);
+ suggestion.set_title(base::UTF8ToUTF16(snippet->title()));
+ suggestion.set_snippet_text(base::UTF8ToUTF16(snippet->snippet()));
+ suggestion.set_publish_date(snippet->publish_date());
+ suggestion.set_publisher_name(
+ base::UTF8ToUTF16(snippet->best_source().publisher_name));
+ suggestion.set_score(snippet->score());
+
+ return suggestion;
+}
+
ContentSuggestion::ContentSuggestion(ContentSuggestion&&) = default;
ContentSuggestion& ContentSuggestion::operator=(ContentSuggestion&&) = default;

Powered by Google App Engine
This is Rietveld 408576698