| OLD | NEW |
| 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 #include <utility> | 8 #include <utility> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 const base::android::JavaParamRef<jobject>& obj, | 196 const base::android::JavaParamRef<jobject>& obj, |
| 197 jint j_category_id) { | 197 jint j_category_id) { |
| 198 base::Optional<CategoryInfo> info = | 198 base::Optional<CategoryInfo> info = |
| 199 content_suggestions_service_->GetCategoryInfo( | 199 content_suggestions_service_->GetCategoryInfo( |
| 200 Category::FromIDValue(j_category_id)); | 200 Category::FromIDValue(j_category_id)); |
| 201 if (!info) { | 201 if (!info) { |
| 202 return base::android::ScopedJavaLocalRef<jobject>(env, nullptr); | 202 return base::android::ScopedJavaLocalRef<jobject>(env, nullptr); |
| 203 } | 203 } |
| 204 return Java_SnippetsBridge_createSuggestionsCategoryInfo( | 204 return Java_SnippetsBridge_createSuggestionsCategoryInfo( |
| 205 env, j_category_id, ConvertUTF16ToJavaString(env, info->title()), | 205 env, j_category_id, ConvertUTF16ToJavaString(env, info->title()), |
| 206 static_cast<int>(info->card_layout()), info->has_fetch_action(), | 206 static_cast<int>(info->card_layout()), |
| 207 info->has_view_all_action(), info->show_if_empty(), | 207 static_cast<int>(info->additional_action()), info->show_if_empty(), |
| 208 ConvertUTF16ToJavaString(env, info->no_suggestions_message())); | 208 ConvertUTF16ToJavaString(env, info->no_suggestions_message())); |
| 209 } | 209 } |
| 210 | 210 |
| 211 ScopedJavaLocalRef<jobject> NTPSnippetsBridge::GetSuggestionsForCategory( | 211 ScopedJavaLocalRef<jobject> NTPSnippetsBridge::GetSuggestionsForCategory( |
| 212 JNIEnv* env, | 212 JNIEnv* env, |
| 213 const base::android::JavaParamRef<jobject>& obj, | 213 const base::android::JavaParamRef<jobject>& obj, |
| 214 jint j_category_id) { | 214 jint j_category_id) { |
| 215 Category category = Category::FromIDValue(j_category_id); | 215 Category category = Category::FromIDValue(j_category_id); |
| 216 return ToJavaSuggestionList( | 216 return ToJavaSuggestionList( |
| 217 env, category, | 217 env, category, |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 JNIEnv* env = AttachCurrentThread(); | 480 JNIEnv* env = AttachCurrentThread(); |
| 481 Java_SnippetsBridge_onMoreSuggestions( | 481 Java_SnippetsBridge_onMoreSuggestions( |
| 482 env, bridge_, category.id(), | 482 env, bridge_, category.id(), |
| 483 ToJavaSuggestionList(env, category, suggestions)); | 483 ToJavaSuggestionList(env, category, suggestions)); |
| 484 } | 484 } |
| 485 | 485 |
| 486 // static | 486 // static |
| 487 bool NTPSnippetsBridge::Register(JNIEnv* env) { | 487 bool NTPSnippetsBridge::Register(JNIEnv* env) { |
| 488 return RegisterNativesImpl(env); | 488 return RegisterNativesImpl(env); |
| 489 } | 489 } |
| OLD | NEW |