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

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

Issue 1248643004: Test distillability without JavaScript (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@early
Patch Set: fix browsertest, merge webkit CL, merge http://crrev.com/1403413004 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
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..00b69ba6686d8ee4df9585935df8416857d44a25 100644
--- a/components/dom_distiller/content/browser/distillable_page_utils_android.cc
+++ b/components/dom_distiller/content/browser/distillable_page_utils_android.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
+#include "components/dom_distiller/content/browser/distillability_driver.h"
#include "components/dom_distiller/content/browser/distillable_page_utils.h"
#include "content/public/browser/web_contents.h"
#include "jni/DistillablePageUtils_jni.h"
@@ -16,34 +17,32 @@ namespace dom_distiller {
namespace android {
namespace {
void OnIsPageDistillableResult(
- scoped_ptr<ScopedJavaGlobalRef<jobject>> callback_holder,
- bool isDistillable) {
+ ScopedJavaGlobalRef<jobject>* callback_holder,
+ bool isDistillable, bool isLast) {
Java_DistillablePageUtils_callOnIsPageDistillableResult(
base::android::AttachCurrentThread(), callback_holder->obj(),
- isDistillable);
+ isDistillable, isLast);
}
} // namespace
-static void IsPageDistillable(JNIEnv* env,
+static void SetCallback(JNIEnv* env,
const JavaParamRef<jclass>& jcaller,
const JavaParamRef<jobject>& webContents,
- jboolean is_mobile_optimized,
const JavaParamRef<jobject>& callback) {
content::WebContents* web_contents(
content::WebContents::FromJavaWebContents(webContents));
- scoped_ptr<ScopedJavaGlobalRef<jobject>> callback_holder(
- new ScopedJavaGlobalRef<jobject>());
- callback_holder->Reset(env, callback);
-
if (!web_contents) {
- base::MessageLoop::current()->PostTask(
- FROM_HERE, base::Bind(OnIsPageDistillableResult,
- base::Passed(&callback_holder), false));
return;
}
- IsDistillablePage(
- web_contents, is_mobile_optimized,
- base::Bind(OnIsPageDistillableResult, base::Passed(&callback_holder)));
+
+ // FIXME(wychen): check memory management
+ ScopedJavaGlobalRef<jobject>* callback_holder(
+ new ScopedJavaGlobalRef<jobject>());
+ callback_holder->Reset(env, callback);
+
+ base::Callback<void(bool, bool)> cb =
+ base::Bind(OnIsPageDistillableResult, base::Owned(callback_holder));
+ setCallback(web_contents, cb);
}
bool RegisterDistillablePageUtils(JNIEnv* env) {

Powered by Google App Engine
This is Rietveld 408576698