Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Unified Diff: components/dom_distiller/content/browser/distillable_page_utils_android.cc

Issue 1414283006: Hook up new distillability signal to DistillablePageUtils (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@agent
Patch Set: merge depend Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/dom_distiller/content/browser/distillable_page_utils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « components/dom_distiller/content/browser/distillable_page_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698