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

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

Issue 2377663002: [NTP Snippets] Introduce ContentSuggestion::ID (Closed)
Patch Set: . Created 4 years, 3 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
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 6b0c9fe00bd9e6e1d94020e08bc2d7445652dc9c..2b0230530e6aa61383bd81e8cfe706c4d558750d 100644
--- a/chrome/browser/android/ntp/ntp_snippets_bridge.cc
+++ b/chrome/browser/android/ntp/ntp_snippets_bridge.cc
@@ -201,7 +201,8 @@ ScopedJavaLocalRef<jobject> NTPSnippetsBridge::GetSuggestionsForCategory(
Java_SnippetsBridge_createSuggestionList(env);
for (const ContentSuggestion& suggestion : suggestions) {
Java_SnippetsBridge_addSuggestion(
- env, result, category, ConvertUTF8ToJavaString(env, suggestion.id()),
+ env, result, category,
+ ConvertUTF8ToJavaString(env, suggestion.id().within_category_id()),
ConvertUTF16ToJavaString(env, suggestion.title()),
ConvertUTF16ToJavaString(env, suggestion.publisher_name()),
ConvertUTF16ToJavaString(env, suggestion.snippet_text()),
@@ -216,11 +217,13 @@ ScopedJavaLocalRef<jobject> NTPSnippetsBridge::GetSuggestionsForCategory(
void NTPSnippetsBridge::FetchSuggestionImage(
JNIEnv* env,
const JavaParamRef<jobject>& obj,
- const JavaParamRef<jstring>& suggestion_id,
+ jint category,
+ const JavaParamRef<jstring>& within_category_id,
const JavaParamRef<jobject>& j_callback) {
base::android::ScopedJavaGlobalRef<jobject> callback(j_callback);
content_suggestions_service_->FetchSuggestionImage(
- ConvertJavaStringToUTF8(env, suggestion_id),
+ ContentSuggestion::ID(CategoryFromIDValue(category),
+ ConvertJavaStringToUTF8(env, within_category_id)),
base::Bind(&NTPSnippetsBridge::OnImageFetched,
weak_ptr_factory_.GetWeakPtr(), callback));
}
@@ -228,9 +231,11 @@ void NTPSnippetsBridge::FetchSuggestionImage(
void NTPSnippetsBridge::DismissSuggestion(
JNIEnv* env,
const JavaParamRef<jobject>& obj,
- const JavaParamRef<jstring>& suggestion_id) {
+ jint category,
+ const JavaParamRef<jstring>& within_category_id) {
content_suggestions_service_->DismissSuggestion(
- ConvertJavaStringToUTF8(env, suggestion_id));
+ ContentSuggestion::ID(CategoryFromIDValue(category),
+ ConvertJavaStringToUTF8(env, within_category_id)));
}
void NTPSnippetsBridge::DismissCategory(JNIEnv* env,
@@ -357,15 +362,14 @@ void NTPSnippetsBridge::OnCategoryStatusChanged(Category category,
}
void NTPSnippetsBridge::OnSuggestionInvalidated(
- Category category,
- const std::string& suggestion_id) {
+ const ContentSuggestion::ID& suggestion_id) {
if (observer_.is_null())
return;
JNIEnv* env = base::android::AttachCurrentThread();
Java_SnippetsBridge_onSuggestionInvalidated(
- env, observer_.obj(), static_cast<int>(category.id()),
- ConvertUTF8ToJavaString(env, suggestion_id).obj());
+ env, observer_.obj(), static_cast<int>(suggestion_id.category().id()),
+ ConvertUTF8ToJavaString(env, suggestion_id.within_category_id()).obj());
}
void NTPSnippetsBridge::ContentSuggestionsServiceShutdown() {

Powered by Google App Engine
This is Rietveld 408576698