Chromium Code Reviews| Index: components/ntp_snippets/remote/ntp_snippets_fetcher.cc |
| diff --git a/components/ntp_snippets/remote/ntp_snippets_fetcher.cc b/components/ntp_snippets/remote/ntp_snippets_fetcher.cc |
| index 2de69441bbe8a0557c1d8b5b07e92d7e3c6609c8..64f49a087c3056cfa0a750e54096a70298185621 100644 |
| --- a/components/ntp_snippets/remote/ntp_snippets_fetcher.cc |
| +++ b/components/ntp_snippets/remote/ntp_snippets_fetcher.cc |
| @@ -153,6 +153,7 @@ bool UsesChromeContentSuggestionsAPI(const GURL& endpoint) { |
| // Creates snippets from dictionary values in |list| and adds them to |
| // |snippets|. Returns true on success, false if anything went wrong. |
| bool AddSnippetsFromListValue(bool content_suggestions_api, |
| + int remote_category_id, |
| const base::ListValue& list, |
| NTPSnippet::PtrVector* snippets) { |
| for (const auto& value : list) { |
| @@ -163,7 +164,8 @@ bool AddSnippetsFromListValue(bool content_suggestions_api, |
| std::unique_ptr<NTPSnippet> snippet; |
| if (content_suggestions_api) { |
| - snippet = NTPSnippet::CreateFromContentSuggestionsDictionary(*dict); |
| + snippet = NTPSnippet::CreateFromContentSuggestionsDictionary( |
| + *dict, remote_category_id); |
| } else { |
| snippet = NTPSnippet::CreateFromChromeReaderDictionary(*dict); |
| } |
| @@ -633,7 +635,8 @@ bool NTPSnippetsFetcher::JsonToSnippets(const base::Value& parsed, |
| category_factory_->FromKnownCategory(KnownCategories::ARTICLES))); |
| const base::ListValue* recos = nullptr; |
| return top_dict->GetList("recos", &recos) && |
| - AddSnippetsFromListValue(/* content_suggestions_api = */ false, |
| + AddSnippetsFromListValue(/*content_suggestions_api=*/false, |
| + /*remote_category_id=*/-1, // unused |
|
Bernhard Bauer
2016/10/10 13:54:54
Nit: Maybe put the value into a variable kUnusedRe
Marc Treib
2016/10/10 15:54:48
Done.
|
| *recos, &categories->back().snippets); |
| } |
| @@ -645,17 +648,17 @@ bool NTPSnippetsFetcher::JsonToSnippets(const base::Value& parsed, |
| for (const auto& v : *categories_value) { |
| std::string utf8_title; |
| - int category_id = -1; |
| + int remote_category_id = -1; |
| const base::DictionaryValue* category_value = nullptr; |
| if (!(v->GetAsDictionary(&category_value) && |
| category_value->GetString("localizedTitle", &utf8_title) && |
| - category_value->GetInteger("id", &category_id) && |
| - (category_id > 0))) { |
| + category_value->GetInteger("id", &remote_category_id) && |
| + (remote_category_id > 0))) { |
| return false; |
| } |
| categories->push_back(FetchedCategory( |
| - category_factory_->FromRemoteCategory(category_id))); |
| + category_factory_->FromRemoteCategory(remote_category_id))); |
| categories->back().localized_title = base::UTF8ToUTF16(utf8_title); |
| const base::ListValue* suggestions = nullptr; |
| @@ -665,8 +668,8 @@ bool NTPSnippetsFetcher::JsonToSnippets(const base::Value& parsed, |
| continue; |
| } |
| if (!AddSnippetsFromListValue( |
| - /* content_suggestions_api = */ true, *suggestions, |
| - &categories->back().snippets)) { |
| + /*content_suggestions_api=*/true, remote_category_id, |
| + *suggestions, &categories->back().snippets)) { |
| return false; |
| } |
| } |