Chromium Code Reviews| 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 1f0909290671e5b99efe52cb9d8630e2a48f1b50..d4bcfb9b1fd7ddb53d792d2aaa0062d81304aba7 100644 |
| --- a/components/ntp_snippets/ntp_snippets_service.cc |
| +++ b/components/ntp_snippets/ntp_snippets_service.cc |
| @@ -221,6 +221,8 @@ NTPSnippetsService::NTPSnippetsService( |
| RequestThrottler::RequestType::CONTENT_SUGGESTION_THUMBNAIL) { |
| // Articles category always exists; others will be added as needed. |
| categories_[articles_category_] = CategoryContent(); |
| + categories_[articles_category_].localized_title = |
| + l10n_util::GetStringUTF16(IDS_NTP_ARTICLE_SUGGESTIONS_SECTION_HEADER); |
| observer->OnCategoryStatusChanged(this, articles_category_, |
| categories_[articles_category_].status); |
| if (database_->IsErrorState()) { |
| @@ -306,12 +308,11 @@ CategoryStatus NTPSnippetsService::GetCategoryStatus(Category category) { |
| CategoryInfo NTPSnippetsService::GetCategoryInfo(Category category) { |
| DCHECK(categories_.find(category) != categories_.end()); |
| - // TODO(sfiera): pass back titles for server categories. |
| - return CategoryInfo( |
| - l10n_util::GetStringUTF16(IDS_NTP_ARTICLE_SUGGESTIONS_SECTION_HEADER), |
| - ContentSuggestionsCardLayout::FULL_CARD, |
| - /* has_more_button */ false, |
| - /* show_if_empty */ true); |
| + const CategoryContent& content = categories_[category]; |
| + return CategoryInfo(content.localized_title, |
| + ContentSuggestionsCardLayout::FULL_CARD, |
| + /* has_more_button */ false, |
| + /* show_if_empty */ true); |
| } |
| void NTPSnippetsService::DismissSuggestion(const std::string& suggestion_id) { |
| @@ -558,9 +559,13 @@ void NTPSnippetsService::OnFetchFinished( |
| // If snippets were fetched successfully, update our |categories_| from each |
| // category provided by the server. |
| if (snippets) { |
| - for (std::pair<const Category, NTPSnippet::PtrVector>& item : *snippets) { |
| - Category category = item.first; |
| - NTPSnippet::PtrVector& new_snippets = item.second; |
| + for (NTPSnippetsFetcher::FetchedCategory& fetched_category : *snippets) { |
| + Category category = fetched_category.category; |
| + NTPSnippet::PtrVector& new_snippets = fetched_category.snippets; |
|
Marc Treib
2016/08/25 16:33:11
This isn't really necessary anymore, now that we'r
sfiera
2016/08/26 09:16:15
Removed it. Kept category, because it's referred t
|
| + |
| + if (category != articles_category_) |
|
Marc Treib
2016/08/25 16:33:11
Braces if the body doesn't fit on one line
sfiera
2016/08/26 09:16:15
Done.
|
| + categories_[category].localized_title = |
| + fetched_category.localized_title; |
| DCHECK_LE(snippets->size(), static_cast<size_t>(kMaxSnippetCount)); |
| // TODO(sfiera): histograms for server categories. |