1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/dom_distiller/content/distillable_page_utils_android.h"
8 #include "base/message_loop/message_loop.h"
9 #include "components/dom_distiller/content/distillable_page_utils.h"
10 #include "content/public/browser/web_contents.h"
11 #include "jni/DistillablePageUtils_jni.h"
13 using base::android::ScopedJavaGlobalRef
;
15 namespace dom_distiller
{
18 void OnIsPageDistillableResult(
19 scoped_ptr
<ScopedJavaGlobalRef
<jobject
>> callback_holder
,
21 Java_DistillablePageUtils_callOnIsPageDistillableResult(
22 base::android::AttachCurrentThread(), callback_holder
->obj(),
27 static void IsPageDistillable(JNIEnv
* env
,
30 jboolean is_mobile_optimized
,
32 content::WebContents
* web_contents(
33 content::WebContents::FromJavaWebContents(webContents
));
34 scoped_ptr
<ScopedJavaGlobalRef
<jobject
>> callback_holder(
35 new ScopedJavaGlobalRef
<jobject
>());
36 callback_holder
->Reset(env
, callback
);
39 base::MessageLoop::current()->PostTask(
40 FROM_HERE
, base::Bind(OnIsPageDistillableResult
,
41 base::Passed(&callback_holder
), false));
45 web_contents
, is_mobile_optimized
,
46 base::Bind(OnIsPageDistillableResult
, base::Passed(&callback_holder
)));
49 bool RegisterDistillablePageUtils(JNIEnv
* env
) {
50 return RegisterNativesImpl(env
);