Chromium Code Reviews| Index: components/dom_distiller/content/browser/distillable_page_utils_android.cc |
| diff --git a/components/dom_distiller/content/browser/distillable_page_utils_android.cc b/components/dom_distiller/content/browser/distillable_page_utils_android.cc |
| index 56dfffaf18ec47497acac7f153272cbd42e6989d..2e75ce2fbafe5c7a877766e7ac4adce9aecb4f9b 100644 |
| --- a/components/dom_distiller/content/browser/distillable_page_utils_android.cc |
| +++ b/components/dom_distiller/content/browser/distillable_page_utils_android.cc |
| @@ -22,6 +22,14 @@ void OnIsPageDistillableResult( |
| base::android::AttachCurrentThread(), callback_holder->obj(), |
| isDistillable); |
| } |
| + |
| +void OnIsPageDistillableUpdate( |
| + ScopedJavaGlobalRef<jobject>* callback_holder, |
| + bool isDistillable, bool isLast) { |
| + Java_DistillablePageUtils_callOnIsPageDistillableUpdate( |
| + base::android::AttachCurrentThread(), callback_holder->obj(), |
| + isDistillable, isLast); |
| +} |
| } // namespace |
| static void IsPageDistillable(JNIEnv* env, |
| @@ -46,6 +54,26 @@ static void IsPageDistillable(JNIEnv* env, |
| base::Bind(OnIsPageDistillableResult, base::Passed(&callback_holder))); |
| } |
| +static void SetDelegate(JNIEnv* env, |
| + const JavaParamRef<jclass>& jcaller, |
| + const JavaParamRef<jobject>& webContents, |
| + const JavaParamRef<jobject>& callback) { |
| + content::WebContents* web_contents( |
| + content::WebContents::FromJavaWebContents(webContents)); |
| + if (!web_contents) { |
| + return; |
| + } |
| + |
| + // FIXME(wychen): check memory management |
| + ScopedJavaGlobalRef<jobject>* callback_holder( |
|
mdjones
2015/11/05 01:09:12
Try extending jobject to log when it is destructed
wychen
2015/11/12 05:39:28
Turned out to be more difficult than I thought. Sk
|
| + new ScopedJavaGlobalRef<jobject>()); |
| + callback_holder->Reset(env, callback); |
| + |
| + DistillabilityDelegate delegate = |
| + base::Bind(OnIsPageDistillableUpdate, base::Owned(callback_holder)); |
| + setDelegate(web_contents, delegate); |
| +} |
| + |
| bool RegisterDistillablePageUtils(JNIEnv* env) { |
| return RegisterNativesImpl(env); |
| } |