| 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 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 const ContentSuggestion::ID& suggestion_id) { | 427 const ContentSuggestion::ID& suggestion_id) { |
| 428 if (observer_.is_null()) | 428 if (observer_.is_null()) |
| 429 return; | 429 return; |
| 430 | 430 |
| 431 JNIEnv* env = base::android::AttachCurrentThread(); | 431 JNIEnv* env = base::android::AttachCurrentThread(); |
| 432 Java_SnippetsBridge_onSuggestionInvalidated( | 432 Java_SnippetsBridge_onSuggestionInvalidated( |
| 433 env, observer_.obj(), static_cast<int>(suggestion_id.category().id()), | 433 env, observer_.obj(), static_cast<int>(suggestion_id.category().id()), |
| 434 ConvertUTF8ToJavaString(env, suggestion_id.id_within_category()).obj()); | 434 ConvertUTF8ToJavaString(env, suggestion_id.id_within_category()).obj()); |
| 435 } | 435 } |
| 436 | 436 |
| 437 void NTPSnippetsBridge::OnFullRefreshRequired() { |
| 438 if (observer_.is_null()) { |
| 439 return; |
| 440 } |
| 441 |
| 442 JNIEnv* env = base::android::AttachCurrentThread(); |
| 443 Java_SnippetsBridge_onFullRefreshRequired(env, observer_.obj()); |
| 444 } |
| 445 |
| 437 void NTPSnippetsBridge::ContentSuggestionsServiceShutdown() { | 446 void NTPSnippetsBridge::ContentSuggestionsServiceShutdown() { |
| 438 observer_.Reset(); | 447 observer_.Reset(); |
| 439 content_suggestions_service_observer_.Remove(content_suggestions_service_); | 448 content_suggestions_service_observer_.Remove(content_suggestions_service_); |
| 440 } | 449 } |
| 441 | 450 |
| 442 void NTPSnippetsBridge::OnImageFetched(ScopedJavaGlobalRef<jobject> callback, | 451 void NTPSnippetsBridge::OnImageFetched(ScopedJavaGlobalRef<jobject> callback, |
| 443 const gfx::Image& image) { | 452 const gfx::Image& image) { |
| 444 ScopedJavaLocalRef<jobject> j_bitmap; | 453 ScopedJavaLocalRef<jobject> j_bitmap; |
| 445 if (!image.IsEmpty()) | 454 if (!image.IsEmpty()) |
| 446 j_bitmap = gfx::ConvertToJavaBitmap(image.ToSkBitmap()); | 455 j_bitmap = gfx::ConvertToJavaBitmap(image.ToSkBitmap()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 466 } | 475 } |
| 467 | 476 |
| 468 Category NTPSnippetsBridge::CategoryFromIDValue(jint id) { | 477 Category NTPSnippetsBridge::CategoryFromIDValue(jint id) { |
| 469 return content_suggestions_service_->category_factory()->FromIDValue(id); | 478 return content_suggestions_service_->category_factory()->FromIDValue(id); |
| 470 } | 479 } |
| 471 | 480 |
| 472 // static | 481 // static |
| 473 bool NTPSnippetsBridge::Register(JNIEnv* env) { | 482 bool NTPSnippetsBridge::Register(JNIEnv* env) { |
| 474 return RegisterNativesImpl(env); | 483 return RegisterNativesImpl(env); |
| 475 } | 484 } |
| OLD | NEW |