| 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_button(), |
| 175 info->show_if_empty()); | 175 info->show_if_empty(), |
| 176 ConvertUTF16ToJavaString(env, info->no_suggestions_message())); |
| 176 } | 177 } |
| 177 | 178 |
| 178 ScopedJavaLocalRef<jobject> NTPSnippetsBridge::GetSuggestionsForCategory( | 179 ScopedJavaLocalRef<jobject> NTPSnippetsBridge::GetSuggestionsForCategory( |
| 179 JNIEnv* env, | 180 JNIEnv* env, |
| 180 const base::android::JavaParamRef<jobject>& obj, | 181 const base::android::JavaParamRef<jobject>& obj, |
| 181 jint category) { | 182 jint category) { |
| 182 // Get layout for the category. | 183 // Get layout for the category. |
| 183 base::Optional<CategoryInfo> info = | 184 base::Optional<CategoryInfo> info = |
| 184 content_suggestions_service_->GetCategoryInfo( | 185 content_suggestions_service_->GetCategoryInfo( |
| 185 CategoryFromIDValue(category)); | 186 CategoryFromIDValue(category)); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 } | 390 } |
| 390 | 391 |
| 391 Category NTPSnippetsBridge::CategoryFromIDValue(jint id) { | 392 Category NTPSnippetsBridge::CategoryFromIDValue(jint id) { |
| 392 return content_suggestions_service_->category_factory()->FromIDValue(id); | 393 return content_suggestions_service_->category_factory()->FromIDValue(id); |
| 393 } | 394 } |
| 394 | 395 |
| 395 // static | 396 // static |
| 396 bool NTPSnippetsBridge::Register(JNIEnv* env) { | 397 bool NTPSnippetsBridge::Register(JNIEnv* env) { |
| 397 return RegisterNativesImpl(env); | 398 return RegisterNativesImpl(env); |
| 398 } | 399 } |
| OLD | NEW |