| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 const base::android::JavaParamRef<jobject>& obj, | 134 const base::android::JavaParamRef<jobject>& obj, |
| 135 jint category) { | 135 jint category) { |
| 136 base::Optional<CategoryInfo> info = | 136 base::Optional<CategoryInfo> info = |
| 137 content_suggestions_service_->GetCategoryInfo( | 137 content_suggestions_service_->GetCategoryInfo( |
| 138 content_suggestions_service_->category_factory()->FromIDValue( | 138 content_suggestions_service_->category_factory()->FromIDValue( |
| 139 category)); | 139 category)); |
| 140 if (!info) | 140 if (!info) |
| 141 return base::android::ScopedJavaLocalRef<jobject>(env, nullptr); | 141 return base::android::ScopedJavaLocalRef<jobject>(env, nullptr); |
| 142 return Java_SnippetsBridge_createSuggestionsCategoryInfo( | 142 return Java_SnippetsBridge_createSuggestionsCategoryInfo( |
| 143 env, ConvertUTF16ToJavaString(env, info->title()), | 143 env, ConvertUTF16ToJavaString(env, info->title()), |
| 144 static_cast<int>(info->card_layout()), info->has_more_button()); | 144 static_cast<int>(info->card_layout()), info->has_more_button(), |
| 145 info->show_if_empty()); |
| 145 } | 146 } |
| 146 | 147 |
| 147 ScopedJavaLocalRef<jobject> NTPSnippetsBridge::GetSuggestionsForCategory( | 148 ScopedJavaLocalRef<jobject> NTPSnippetsBridge::GetSuggestionsForCategory( |
| 148 JNIEnv* env, | 149 JNIEnv* env, |
| 149 const base::android::JavaParamRef<jobject>& obj, | 150 const base::android::JavaParamRef<jobject>& obj, |
| 150 jint category) { | 151 jint category) { |
| 151 // Get layout for the category. | 152 // Get layout for the category. |
| 152 base::Optional<CategoryInfo> info = | 153 base::Optional<CategoryInfo> info = |
| 153 content_suggestions_service_->GetCategoryInfo( | 154 content_suggestions_service_->GetCategoryInfo( |
| 154 content_suggestions_service_->category_factory()->FromIDValue( | 155 content_suggestions_service_->category_factory()->FromIDValue( |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 if (!image.IsEmpty()) | 241 if (!image.IsEmpty()) |
| 241 j_bitmap = gfx::ConvertToJavaBitmap(image.ToSkBitmap()); | 242 j_bitmap = gfx::ConvertToJavaBitmap(image.ToSkBitmap()); |
| 242 | 243 |
| 243 base::android::RunCallbackAndroid(callback, j_bitmap); | 244 base::android::RunCallbackAndroid(callback, j_bitmap); |
| 244 } | 245 } |
| 245 | 246 |
| 246 // static | 247 // static |
| 247 bool NTPSnippetsBridge::Register(JNIEnv* env) { | 248 bool NTPSnippetsBridge::Register(JNIEnv* env) { |
| 248 return RegisterNativesImpl(env); | 249 return RegisterNativesImpl(env); |
| 249 } | 250 } |
| OLD | NEW |