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

Side by Side 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: 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/ntp/ntp_snippets_bridge.h" 5 #include "chrome/browser/android/ntp/ntp_snippets_bridge.h"
6 6
7 #include <jni.h> 7 #include <jni.h>
8 8
9 #include "base/android/callback_android.h" 9 #include "base/android/callback_android.h"
10 #include "base/android/jni_android.h" 10 #include "base/android/jni_android.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // URL for the article. This will also be used to find the favicon for the 140 // URL for the article. This will also be used to find the favicon for the
141 // article. 141 // article.
142 std::vector<std::string> urls; 142 std::vector<std::string> urls;
143 // URL for the AMP version of the article if it exists. This will be used as 143 // URL for the AMP version of the article if it exists. This will be used as
144 // the URL to direct the user to on tap. 144 // the URL to direct the user to on tap.
145 std::vector<std::string> amp_urls; 145 std::vector<std::string> amp_urls;
146 std::vector<std::string> snippets; 146 std::vector<std::string> snippets;
147 std::vector<int64_t> timestamps; 147 std::vector<int64_t> timestamps;
148 std::vector<std::string> publishers; 148 std::vector<std::string> publishers;
149 std::vector<float> scores; 149 std::vector<float> scores;
150
151 // Show all other sections before ARTICLES, at most 5 suggestions per section.
Marc Treib 2016/07/26 12:54:08 Can you please add a TODO that this is a temporary
Philipp Keck 2016/07/26 13:55:58 Done.
152 for (ContentSuggestionsCategory category :
153 content_suggestions_service_->GetCategories()) {
154 if (category == ContentSuggestionsCategory::ARTICLES) {
155 continue;
156 }
157 if (content_suggestions_service_->GetCategoryStatus(category) !=
158 ContentSuggestionsCategoryStatus::AVAILABLE) {
159 continue;
160 }
161
162 int counter = 0;
Marc Treib 2016/07/26 12:54:08 Why the "at most 5" logic? Since this will only ha
Philipp Keck 2016/07/26 13:55:58 Ok I moved it there. Testing how an empty NTP beha
163 for (const ntp_snippets::ContentSuggestion& suggestion :
164 content_suggestions_service_->GetSuggestionsForCategory(category)) {
165 ids.push_back(suggestion.id());
166 titles.push_back(suggestion.title());
167 urls.push_back(suggestion.url().spec());
168 amp_urls.push_back(suggestion.amp_url().spec());
169 snippets.push_back(suggestion.snippet_text());
170 timestamps.push_back(suggestion.publish_date().ToJavaTime());
171 publishers.push_back(suggestion.publisher_name());
172 scores.push_back(suggestion.score());
173 if (5 == ++counter)
174 break;
175 }
176 }
177
178 // All article suggestions.
150 for (const ntp_snippets::ContentSuggestion& suggestion : 179 for (const ntp_snippets::ContentSuggestion& suggestion :
151 content_suggestions_service_->GetSuggestionsForCategory( 180 content_suggestions_service_->GetSuggestionsForCategory(
152 ContentSuggestionsCategory::ARTICLES)) { 181 ContentSuggestionsCategory::ARTICLES)) {
153 ids.push_back(suggestion.id()); 182 ids.push_back(suggestion.id());
154 titles.push_back(suggestion.title()); 183 titles.push_back(suggestion.title());
155 // The url from source_info is a url for a site that is one of the 184 // The url from source_info is a url for a site that is one of the
156 // HOST_RESTRICT parameters, so this is preferred. 185 // HOST_RESTRICT parameters, so this is preferred.
157 urls.push_back(suggestion.url().spec()); 186 urls.push_back(suggestion.url().spec());
158 amp_urls.push_back(suggestion.amp_url().spec()); 187 amp_urls.push_back(suggestion.amp_url().spec());
159 snippets.push_back(suggestion.snippet_text()); 188 snippets.push_back(suggestion.snippet_text());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 if (!image.IsEmpty()) 226 if (!image.IsEmpty())
198 j_bitmap = gfx::ConvertToJavaBitmap(image.ToSkBitmap()); 227 j_bitmap = gfx::ConvertToJavaBitmap(image.ToSkBitmap());
199 228
200 base::android::RunCallbackAndroid(callback, j_bitmap); 229 base::android::RunCallbackAndroid(callback, j_bitmap);
201 } 230 }
202 231
203 // static 232 // static
204 bool NTPSnippetsBridge::Register(JNIEnv* env) { 233 bool NTPSnippetsBridge::Register(JNIEnv* env) {
205 return RegisterNativesImpl(env); 234 return RegisterNativesImpl(env);
206 } 235 }
OLDNEW
« 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