| 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 base::android::ScopedJavaLocalRef<jobject> NTPSnippetsBridge::GetCategoryInfo( | 172 base::android::ScopedJavaLocalRef<jobject> NTPSnippetsBridge::GetCategoryInfo( |
| 173 JNIEnv* env, | 173 JNIEnv* env, |
| 174 const base::android::JavaParamRef<jobject>& obj, | 174 const base::android::JavaParamRef<jobject>& obj, |
| 175 jint category) { | 175 jint category) { |
| 176 base::Optional<CategoryInfo> info = | 176 base::Optional<CategoryInfo> info = |
| 177 content_suggestions_service_->GetCategoryInfo( | 177 content_suggestions_service_->GetCategoryInfo( |
| 178 CategoryFromIDValue(category)); | 178 CategoryFromIDValue(category)); |
| 179 if (!info) | 179 if (!info) |
| 180 return base::android::ScopedJavaLocalRef<jobject>(env, nullptr); | 180 return base::android::ScopedJavaLocalRef<jobject>(env, nullptr); |
| 181 return Java_SnippetsBridge_createSuggestionsCategoryInfo( | 181 return Java_SnippetsBridge_createSuggestionsCategoryInfo( |
| 182 env, ConvertUTF16ToJavaString(env, info->title()), | 182 env, category, ConvertUTF16ToJavaString(env, info->title()), |
| 183 static_cast<int>(info->card_layout()), info->has_more_button(), | 183 static_cast<int>(info->card_layout()), info->has_more_button(), |
| 184 info->show_if_empty()); | 184 info->show_if_empty()); |
| 185 } | 185 } |
| 186 | 186 |
| 187 ScopedJavaLocalRef<jobject> NTPSnippetsBridge::GetSuggestionsForCategory( | 187 ScopedJavaLocalRef<jobject> NTPSnippetsBridge::GetSuggestionsForCategory( |
| 188 JNIEnv* env, | 188 JNIEnv* env, |
| 189 const base::android::JavaParamRef<jobject>& obj, | 189 const base::android::JavaParamRef<jobject>& obj, |
| 190 jint category) { | 190 jint category) { |
| 191 // Get layout for the category. | 191 // Get layout for the category. |
| 192 base::Optional<CategoryInfo> info = | 192 base::Optional<CategoryInfo> info = |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 403 } | 403 } |
| 404 | 404 |
| 405 Category NTPSnippetsBridge::CategoryFromIDValue(jint id) { | 405 Category NTPSnippetsBridge::CategoryFromIDValue(jint id) { |
| 406 return content_suggestions_service_->category_factory()->FromIDValue(id); | 406 return content_suggestions_service_->category_factory()->FromIDValue(id); |
| 407 } | 407 } |
| 408 | 408 |
| 409 // static | 409 // static |
| 410 bool NTPSnippetsBridge::Register(JNIEnv* env) { | 410 bool NTPSnippetsBridge::Register(JNIEnv* env) { |
| 411 return RegisterNativesImpl(env); | 411 return RegisterNativesImpl(env); |
| 412 } | 412 } |
| OLD | NEW |