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

Unified Diff: components/ntp_snippets/ntp_snippets_service.cc

Issue 1922083004: Allow fetching personalized snippets from ChromeReader. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: After code review #2 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
Index: components/ntp_snippets/ntp_snippets_service.cc
diff --git a/components/ntp_snippets/ntp_snippets_service.cc b/components/ntp_snippets/ntp_snippets_service.cc
index d66d3fa36de034ef36c723794294dd2b61a960f4..28db965ceb2ac159ad73cf6a571c9896d11c8a5d 100644
--- a/components/ntp_snippets/ntp_snippets_service.cc
+++ b/components/ntp_snippets/ntp_snippets_service.cc
@@ -130,8 +130,6 @@ std::set<std::string> GetSuggestionsHostsImpl(
return hosts;
}
-const char kContentInfo[] = "contentInfo";
-
// Parses snippets from |list| and adds them to |snippets|. Returns true on
// success, false if anything went wrong.
bool AddSnippetsFromListValue(const base::ListValue& list,
@@ -141,11 +139,8 @@ bool AddSnippetsFromListValue(const base::ListValue& list,
if (!value->GetAsDictionary(&dict))
return false;
- const base::DictionaryValue* content = nullptr;
- if (!dict->GetDictionary(kContentInfo, &content))
- return false;
std::unique_ptr<NTPSnippet> snippet =
- NTPSnippet::CreateFromDictionary(*content);
+ NTPSnippet::CreateFromDictionary(*dict);
if (!snippet)
return false;
@@ -158,8 +153,7 @@ std::unique_ptr<base::ListValue> SnippetsToListValue(
const NTPSnippetsService::NTPSnippetStorage& snippets) {
std::unique_ptr<base::ListValue> list(new base::ListValue);
for (const auto& snippet : snippets) {
- std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue);
- dict->Set(kContentInfo, snippet->ToDictionary());
+ std::unique_ptr<base::DictionaryValue> dict = snippet->ToDictionary();
list->Append(std::move(dict));
}
return list;
@@ -242,11 +236,15 @@ void NTPSnippetsService::FetchSnippetsFromHosts(
const std::set<std::string>& hosts) {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDontRestrict)) {
- snippets_fetcher_->FetchSnippets(std::set<std::string>(), kMaxSnippetCount);
+ snippets_fetcher_->FetchSnippets(std::set<std::string>(),
+ application_language_code_,
+ kMaxSnippetCount);
return;
}
if (!hosts.empty()) {
- snippets_fetcher_->FetchSnippets(hosts, kMaxSnippetCount);
+ snippets_fetcher_->FetchSnippets(hosts,
+ application_language_code_,
+ kMaxSnippetCount);
} else {
last_fetch_status_ = kStatusMessageEmptyHosts;
LoadingSnippetsFinished();

Powered by Google App Engine
This is Rietveld 408576698