| 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 | 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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 JNIEnv* env, | 164 JNIEnv* env, |
| 165 const base::android::JavaParamRef<jobject>& obj, | 165 const base::android::JavaParamRef<jobject>& obj, |
| 166 jint category) { | 166 jint category) { |
| 167 base::Optional<CategoryInfo> info = | 167 base::Optional<CategoryInfo> info = |
| 168 content_suggestions_service_->GetCategoryInfo( | 168 content_suggestions_service_->GetCategoryInfo( |
| 169 CategoryFromIDValue(category)); | 169 CategoryFromIDValue(category)); |
| 170 if (!info) | 170 if (!info) |
| 171 return base::android::ScopedJavaLocalRef<jobject>(env, nullptr); | 171 return base::android::ScopedJavaLocalRef<jobject>(env, nullptr); |
| 172 return Java_SnippetsBridge_createSuggestionsCategoryInfo( | 172 return Java_SnippetsBridge_createSuggestionsCategoryInfo( |
| 173 env, category, ConvertUTF16ToJavaString(env, info->title()), | 173 env, category, ConvertUTF16ToJavaString(env, info->title()), |
| 174 static_cast<int>(info->card_layout()), info->has_more_button(), | 174 static_cast<int>(info->card_layout()), info->has_more_action(), |
| 175 info->has_reload_action(), info->has_view_all_action(), |
| 175 info->show_if_empty(), | 176 info->show_if_empty(), |
| 176 ConvertUTF16ToJavaString(env, info->no_suggestions_message())); | 177 ConvertUTF16ToJavaString(env, info->no_suggestions_message())); |
| 177 } | 178 } |
| 178 | 179 |
| 179 ScopedJavaLocalRef<jobject> NTPSnippetsBridge::GetSuggestionsForCategory( | 180 ScopedJavaLocalRef<jobject> NTPSnippetsBridge::GetSuggestionsForCategory( |
| 180 JNIEnv* env, | 181 JNIEnv* env, |
| 181 const base::android::JavaParamRef<jobject>& obj, | 182 const base::android::JavaParamRef<jobject>& obj, |
| 182 jint category) { | 183 jint category) { |
| 183 // Get layout for the category. | 184 // Get layout for the category. |
| 184 base::Optional<CategoryInfo> info = | 185 base::Optional<CategoryInfo> info = |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 } | 391 } |
| 391 | 392 |
| 392 Category NTPSnippetsBridge::CategoryFromIDValue(jint id) { | 393 Category NTPSnippetsBridge::CategoryFromIDValue(jint id) { |
| 393 return content_suggestions_service_->category_factory()->FromIDValue(id); | 394 return content_suggestions_service_->category_factory()->FromIDValue(id); |
| 394 } | 395 } |
| 395 | 396 |
| 396 // static | 397 // static |
| 397 bool NTPSnippetsBridge::Register(JNIEnv* env) { | 398 bool NTPSnippetsBridge::Register(JNIEnv* env) { |
| 398 return RegisterNativesImpl(env); | 399 return RegisterNativesImpl(env); |
| 399 } | 400 } |
| OLD | NEW |