OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/dom_distiller/content/browser/distillable_page_utils_androi
d.h" | 5 #include "components/dom_distiller/content/browser/distillable_page_utils_androi
d.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "components/dom_distiller/content/browser/distillable_page_utils.h" | 9 #include "components/dom_distiller/content/browser/distillable_page_utils.h" |
10 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
11 #include "jni/DistillablePageUtils_jni.h" | 11 #include "jni/DistillablePageUtils_jni.h" |
12 | 12 |
13 using base::android::ScopedJavaGlobalRef; | 13 using base::android::ScopedJavaGlobalRef; |
14 | 14 |
15 namespace dom_distiller { | 15 namespace dom_distiller { |
16 namespace android { | 16 namespace android { |
17 namespace { | 17 namespace { |
| 18 #if !defined(USE_AURA) |
18 void OnIsPageDistillableResult( | 19 void OnIsPageDistillableResult( |
19 scoped_ptr<ScopedJavaGlobalRef<jobject>> callback_holder, | 20 scoped_ptr<ScopedJavaGlobalRef<jobject>> callback_holder, |
20 bool isDistillable) { | 21 bool isDistillable) { |
21 Java_DistillablePageUtils_callOnIsPageDistillableResult( | 22 Java_DistillablePageUtils_callOnIsPageDistillableResult( |
22 base::android::AttachCurrentThread(), callback_holder->obj(), | 23 base::android::AttachCurrentThread(), callback_holder->obj(), |
23 isDistillable); | 24 isDistillable); |
24 } | 25 } |
| 26 #endif |
25 } // namespace | 27 } // namespace |
26 | 28 |
27 static void IsPageDistillable(JNIEnv* env, | 29 static void IsPageDistillable(JNIEnv* env, |
28 jclass jcaller, | 30 jclass jcaller, |
29 jobject webContents, | 31 jobject webContents, |
30 jboolean is_mobile_optimized, | 32 jboolean is_mobile_optimized, |
31 jobject callback) { | 33 jobject callback) { |
| 34 #if !defined(USE_AURA) |
32 content::WebContents* web_contents( | 35 content::WebContents* web_contents( |
33 content::WebContents::FromJavaWebContents(webContents)); | 36 content::WebContents::FromJavaWebContents(webContents)); |
34 scoped_ptr<ScopedJavaGlobalRef<jobject>> callback_holder( | 37 scoped_ptr<ScopedJavaGlobalRef<jobject>> callback_holder( |
35 new ScopedJavaGlobalRef<jobject>()); | 38 new ScopedJavaGlobalRef<jobject>()); |
36 callback_holder->Reset(env, callback); | 39 callback_holder->Reset(env, callback); |
37 | 40 |
38 if (!web_contents) { | 41 if (!web_contents) { |
39 base::MessageLoop::current()->PostTask( | 42 base::MessageLoop::current()->PostTask( |
40 FROM_HERE, base::Bind(OnIsPageDistillableResult, | 43 FROM_HERE, base::Bind(OnIsPageDistillableResult, |
41 base::Passed(&callback_holder), false)); | 44 base::Passed(&callback_holder), false)); |
42 return; | 45 return; |
43 } | 46 } |
44 IsDistillablePage( | 47 IsDistillablePage( |
45 web_contents, is_mobile_optimized, | 48 web_contents, is_mobile_optimized, |
46 base::Bind(OnIsPageDistillableResult, base::Passed(&callback_holder))); | 49 base::Bind(OnIsPageDistillableResult, base::Passed(&callback_holder))); |
| 50 #endif |
47 } | 51 } |
48 | 52 |
49 bool RegisterDistillablePageUtils(JNIEnv* env) { | 53 bool RegisterDistillablePageUtils(JNIEnv* env) { |
50 return RegisterNativesImpl(env); | 54 return RegisterNativesImpl(env); |
51 } | 55 } |
52 | 56 |
53 } | 57 } |
54 } | 58 } |
OLD | NEW |