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..0b48f85c0bbe74dae25d658a4e33096bc0ad2309 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; |
+ } |
+ |
+ // TODO(wychen): check memory management |
+ ScopedJavaGlobalRef<jobject>* callback_holder( |
+ 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); |
} |