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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/location.h" |
| 11 #include "base/single_thread_task_runner.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" |
11 #include "components/dom_distiller/content/browser/distillable_page_utils.h" | 13 #include "components/dom_distiller/content/browser/distillable_page_utils.h" |
12 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
13 #include "jni/DistillablePageUtils_jni.h" | 15 #include "jni/DistillablePageUtils_jni.h" |
14 | 16 |
15 using base::android::ScopedJavaGlobalRef; | 17 using base::android::ScopedJavaGlobalRef; |
16 | 18 |
17 namespace dom_distiller { | 19 namespace dom_distiller { |
18 namespace android { | 20 namespace android { |
19 namespace { | 21 namespace { |
20 void OnIsPageDistillableResult( | 22 void OnIsPageDistillableResult( |
(...skipping 18 matching lines...) Expand all Loading... |
39 const JavaParamRef<jobject>& webContents, | 41 const JavaParamRef<jobject>& webContents, |
40 jboolean is_mobile_optimized, | 42 jboolean is_mobile_optimized, |
41 const JavaParamRef<jobject>& callback) { | 43 const JavaParamRef<jobject>& callback) { |
42 content::WebContents* web_contents( | 44 content::WebContents* web_contents( |
43 content::WebContents::FromJavaWebContents(webContents)); | 45 content::WebContents::FromJavaWebContents(webContents)); |
44 std::unique_ptr<ScopedJavaGlobalRef<jobject>> callback_holder( | 46 std::unique_ptr<ScopedJavaGlobalRef<jobject>> callback_holder( |
45 new ScopedJavaGlobalRef<jobject>()); | 47 new ScopedJavaGlobalRef<jobject>()); |
46 callback_holder->Reset(env, callback); | 48 callback_holder->Reset(env, callback); |
47 | 49 |
48 if (!web_contents) { | 50 if (!web_contents) { |
49 base::MessageLoop::current()->PostTask( | 51 base::ThreadTaskRunnerHandle::Get()->PostTask( |
50 FROM_HERE, base::Bind(OnIsPageDistillableResult, | 52 FROM_HERE, base::Bind(OnIsPageDistillableResult, |
51 base::Passed(&callback_holder), false)); | 53 base::Passed(&callback_holder), false)); |
52 return; | 54 return; |
53 } | 55 } |
54 IsDistillablePage( | 56 IsDistillablePage( |
55 web_contents, is_mobile_optimized, | 57 web_contents, is_mobile_optimized, |
56 base::Bind(OnIsPageDistillableResult, base::Passed(&callback_holder))); | 58 base::Bind(OnIsPageDistillableResult, base::Passed(&callback_holder))); |
57 } | 59 } |
58 | 60 |
59 static void SetDelegate(JNIEnv* env, | 61 static void SetDelegate(JNIEnv* env, |
(...skipping 15 matching lines...) Expand all Loading... |
75 base::Bind(OnIsPageDistillableUpdate, base::Owned(callback_holder)); | 77 base::Bind(OnIsPageDistillableUpdate, base::Owned(callback_holder)); |
76 setDelegate(web_contents, delegate); | 78 setDelegate(web_contents, delegate); |
77 } | 79 } |
78 | 80 |
79 bool RegisterDistillablePageUtils(JNIEnv* env) { | 81 bool RegisterDistillablePageUtils(JNIEnv* env) { |
80 return RegisterNativesImpl(env); | 82 return RegisterNativesImpl(env); |
81 } | 83 } |
82 | 84 |
83 } | 85 } |
84 } | 86 } |
OLD | NEW |