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

Unified Diff: components/ntp_snippets/ntp_snippets_fetcher.cc

Issue 2279483002: Allow category["suggestions"] to be absent. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Created 4 years, 4 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 | « no previous file | components/ntp_snippets/ntp_snippets_fetcher_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_snippets/ntp_snippets_fetcher.cc
diff --git a/components/ntp_snippets/ntp_snippets_fetcher.cc b/components/ntp_snippets/ntp_snippets_fetcher.cc
index c0018e7d816ad650ff06f25bdf664b5b64034e2e..8c75df86219eb15f78ed348af1226db462b3a64c 100644
--- a/components/ntp_snippets/ntp_snippets_fetcher.cc
+++ b/components/ntp_snippets/ntp_snippets_fetcher.cc
@@ -540,12 +540,14 @@ bool NTPSnippetsFetcher::JsonToSnippets(const base::Value& parsed,
const base::ListValue* suggestions = nullptr;
Marc Treib 2016/08/25 09:14:02 nit: Move this down to where it's used.
sfiera 2016/08/25 10:24:29 Done.
if (!(v->GetAsDictionary(&category_value) &&
category_value->GetInteger("id", &category_id) &&
- (category_id > 0) &&
- category_value->GetList("suggestions", &suggestions))) {
+ (category_id > 0))) {
return false;
}
Category category = category_factory_->FromRemoteCategory(category_id);
NTPSnippet::PtrVector* articles = &(*snippets)[category];
+ if (!category_value->GetList("suggestions", &suggestions)) {
tschumann 2016/08/24 21:35:22 let's document this case, e.g., // Categories are
Marc Treib 2016/08/25 09:14:02 +1 for comment
sfiera 2016/08/25 10:24:29 Done.
+ continue;
+ }
if (!AddSnippetsFromListValue(
/* content_suggestions_api = */ true, *suggestions, articles)) {
return false;
« no previous file with comments | « no previous file | components/ntp_snippets/ntp_snippets_fetcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698