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

Unified Diff: chrome/browser/android/ntp/ntp_snippets_bridge.cc

Issue 2184683002: Show content suggestions from all categories on the NTP (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge the two loops into one Created 4 years, 5 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/offline_pages/offline_page_suggestions_provider.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/ntp/ntp_snippets_bridge.cc
diff --git a/chrome/browser/android/ntp/ntp_snippets_bridge.cc b/chrome/browser/android/ntp/ntp_snippets_bridge.cc
index f6a6b5aad01e071a646229d1779f31953cc7388a..f8cf8eb12f790b72946202a15b90fdefc1bca783 100644
--- a/chrome/browser/android/ntp/ntp_snippets_bridge.cc
+++ b/chrome/browser/android/ntp/ntp_snippets_bridge.cc
@@ -147,19 +147,30 @@ void NTPSnippetsBridge::OnNewSuggestions() {
std::vector<int64_t> timestamps;
std::vector<std::string> publishers;
std::vector<float> scores;
- for (const ntp_snippets::ContentSuggestion& suggestion :
- content_suggestions_service_->GetSuggestionsForCategory(
- ContentSuggestionsCategory::ARTICLES)) {
- ids.push_back(suggestion.id());
- titles.push_back(suggestion.title());
- // The url from source_info is a url for a site that is one of the
- // HOST_RESTRICT parameters, so this is preferred.
- urls.push_back(suggestion.url().spec());
- amp_urls.push_back(suggestion.amp_url().spec());
- snippets.push_back(suggestion.snippet_text());
- timestamps.push_back(suggestion.publish_date().ToJavaTime());
- publishers.push_back(suggestion.publisher_name());
- scores.push_back(suggestion.score());
+
+ // Show all suggestions from all categories, even though we currently display
+ // them in a single section on the UI.
+ // TODO(pke): This is only for debugging new sections and will be replaced
+ // with proper multi-section UI support.
+ for (ContentSuggestionsCategory category :
+ content_suggestions_service_->GetCategories()) {
+ if (content_suggestions_service_->GetCategoryStatus(category) !=
+ ContentSuggestionsCategoryStatus::AVAILABLE) {
+ continue;
+ }
+ for (const ntp_snippets::ContentSuggestion& suggestion :
+ content_suggestions_service_->GetSuggestionsForCategory(category)) {
+ ids.push_back(suggestion.id());
+ titles.push_back(suggestion.title());
+ // The url from source_info is a url for a site that is one of the
+ // HOST_RESTRICT parameters, so this is preferred.
+ urls.push_back(suggestion.url().spec());
+ amp_urls.push_back(suggestion.amp_url().spec());
+ snippets.push_back(suggestion.snippet_text());
+ timestamps.push_back(suggestion.publish_date().ToJavaTime());
+ publishers.push_back(suggestion.publisher_name());
+ scores.push_back(suggestion.score());
+ }
}
JNIEnv* env = base::android::AttachCurrentThread();
« no previous file with comments | « no previous file | components/ntp_snippets/offline_pages/offline_page_suggestions_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698