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

Unified Diff: components/ntp_snippets/ntp_snippet.cc

Issue 1922083004: Allow fetching personalized snippets from ChromeReader. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Yet another unittest fix Created 4 years, 7 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') | components/ntp_snippets/ntp_snippets_constants.h » ('j') | 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 d5164c56a82a1a81fb4fa30f1f0247e7c162ee1c..c46e2dda6dc2ccd3d08857da875aea7b24f390c5 100644
--- a/components/ntp_snippets/ntp_snippet.cc
+++ b/components/ntp_snippets/ntp_snippet.cc
@@ -10,6 +10,7 @@
namespace {
+const char kScore[] = "score";
const char kContentInfo[] = "contentInfo";
const char kUrl[] = "url";
@@ -28,7 +29,8 @@ const char kAmpUrl[] = "ampUrl";
namespace ntp_snippets {
-NTPSnippet::NTPSnippet(const GURL& url) : url_(url), best_source_index_(0) {
+NTPSnippet::NTPSnippet(const GURL& url)
+ : url_(url), score_(0), best_source_index_(0) {
DCHECK(url_.is_valid());
}
@@ -142,6 +144,10 @@ std::unique_ptr<NTPSnippet> NTPSnippet::CreateFromDictionary(
return nullptr;
}
+ double score;
+ if (dict.GetDouble(kScore, &score))
+ snippet->set_score(score);
+
return snippet;
}
@@ -198,6 +204,8 @@ std::unique_ptr<base::DictionaryValue> NTPSnippet::ToDictionary() const {
std::unique_ptr<base::DictionaryValue> result(new base::DictionaryValue);
result->Set(kContentInfo, std::move(dict));
+ result->SetDouble(kScore, score_);
+
return result;
}
« no previous file with comments | « components/ntp_snippets/ntp_snippet.h ('k') | components/ntp_snippets/ntp_snippets_constants.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698