Chromium Code Reviews| 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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 const JavaParamRef<jstring>& id_within_category, | 224 const JavaParamRef<jstring>& id_within_category, |
| 225 const JavaParamRef<jobject>& j_callback) { | 225 const JavaParamRef<jobject>& j_callback) { |
| 226 base::android::ScopedJavaGlobalRef<jobject> callback(j_callback); | 226 base::android::ScopedJavaGlobalRef<jobject> callback(j_callback); |
| 227 content_suggestions_service_->FetchSuggestionImage( | 227 content_suggestions_service_->FetchSuggestionImage( |
| 228 ContentSuggestion::ID(Category::FromIDValue(j_category_id), | 228 ContentSuggestion::ID(Category::FromIDValue(j_category_id), |
| 229 ConvertJavaStringToUTF8(env, id_within_category)), | 229 ConvertJavaStringToUTF8(env, id_within_category)), |
| 230 base::Bind(&NTPSnippetsBridge::OnImageFetched, | 230 base::Bind(&NTPSnippetsBridge::OnImageFetched, |
| 231 weak_ptr_factory_.GetWeakPtr(), callback)); | 231 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 232 } | 232 } |
| 233 | 233 |
| 234 void NTPSnippetsBridge::FetchSuggestionFavicon( | |
| 235 JNIEnv* env, | |
| 236 const JavaParamRef<jobject>& obj, | |
| 237 jint j_category_id, | |
| 238 const JavaParamRef<jstring>& id_within_category, | |
| 239 jint j_minimum_size_in_pixel, | |
| 240 jint j_desired_size_in_pixel, | |
| 241 const JavaParamRef<jobject>& j_callback) { | |
| 242 base::android::ScopedJavaGlobalRef<jobject> callback(j_callback); | |
|
Michael van Ouwerkerk
2017/03/28 11:23:56
There's a using statement for ScopedJavaGlobalRef,
jkrcal
2017/03/28 13:12:53
Done (for much more).
| |
| 243 content_suggestions_service_->FetchSuggestionFavicon( | |
| 244 ContentSuggestion::ID(Category::FromIDValue(j_category_id), | |
| 245 ConvertJavaStringToUTF8(env, id_within_category)), | |
| 246 j_minimum_size_in_pixel, j_desired_size_in_pixel, | |
| 247 base::Bind(&NTPSnippetsBridge::OnImageFetched, | |
| 248 weak_ptr_factory_.GetWeakPtr(), callback)); | |
| 249 } | |
| 250 | |
| 234 void NTPSnippetsBridge::Fetch( | 251 void NTPSnippetsBridge::Fetch( |
| 235 JNIEnv* env, | 252 JNIEnv* env, |
| 236 const JavaParamRef<jobject>& obj, | 253 const JavaParamRef<jobject>& obj, |
| 237 jint j_category_id, | 254 jint j_category_id, |
| 238 const JavaParamRef<jobjectArray>& j_displayed_suggestions) { | 255 const JavaParamRef<jobjectArray>& j_displayed_suggestions) { |
| 239 std::vector<std::string> known_suggestion_ids; | 256 std::vector<std::string> known_suggestion_ids; |
| 240 AppendJavaStringArrayToStringVector(env, j_displayed_suggestions, | 257 AppendJavaStringArrayToStringVector(env, j_displayed_suggestions, |
| 241 &known_suggestion_ids); | 258 &known_suggestion_ids); |
| 242 | 259 |
| 243 Category category = Category::FromIDValue(j_category_id); | 260 Category category = Category::FromIDValue(j_category_id); |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 480 JNIEnv* env = AttachCurrentThread(); | 497 JNIEnv* env = AttachCurrentThread(); |
| 481 Java_SnippetsBridge_onMoreSuggestions( | 498 Java_SnippetsBridge_onMoreSuggestions( |
| 482 env, bridge_, category.id(), | 499 env, bridge_, category.id(), |
| 483 ToJavaSuggestionList(env, category, suggestions)); | 500 ToJavaSuggestionList(env, category, suggestions)); |
| 484 } | 501 } |
| 485 | 502 |
| 486 // static | 503 // static |
| 487 bool NTPSnippetsBridge::Register(JNIEnv* env) { | 504 bool NTPSnippetsBridge::Register(JNIEnv* env) { |
| 488 return RegisterNativesImpl(env); | 505 return RegisterNativesImpl(env); |
| 489 } | 506 } |
| OLD | NEW |