OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "android_webview/native/aw_pdf_exporter.h" | 5 #include "android_webview/native/aw_pdf_exporter.h" |
6 | 6 |
7 #include "android_webview/browser/aw_print_manager.h" | 7 #include "android_webview/browser/aw_print_manager.h" |
8 #include "base/android/jni_android.h" | 8 #include "base/android/jni_android.h" |
9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
10 #include "jni/AwPdfExporter_jni.h" | 10 #include "jni/AwPdfExporter_jni.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 Java_AwPdfExporter_setNativeAwPdfExporter( | 25 Java_AwPdfExporter_setNativeAwPdfExporter( |
26 env, obj, reinterpret_cast<intptr_t>(this)); | 26 env, obj, reinterpret_cast<intptr_t>(this)); |
27 } | 27 } |
28 | 28 |
29 AwPdfExporter::~AwPdfExporter() { | 29 AwPdfExporter::~AwPdfExporter() { |
30 JNIEnv* env = base::android::AttachCurrentThread(); | 30 JNIEnv* env = base::android::AttachCurrentThread(); |
31 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 31 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
32 if (obj.is_null()) | 32 if (obj.is_null()) |
33 return; | 33 return; |
34 // Clear the Java peer's weak pointer to |this| object. | 34 // Clear the Java peer's weak pointer to |this| object. |
35 Java_AwPdfExporter_setNativeAwPdfExporter(env, obj.obj(), 0); | 35 Java_AwPdfExporter_setNativeAwPdfExporter(env, obj, 0); |
36 } | 36 } |
37 | 37 |
38 void AwPdfExporter::ExportToPdf(JNIEnv* env, | 38 void AwPdfExporter::ExportToPdf(JNIEnv* env, |
39 const JavaParamRef<jobject>& obj, | 39 const JavaParamRef<jobject>& obj, |
40 int fd, | 40 int fd, |
41 const JavaParamRef<jobject>& cancel_signal) { | 41 const JavaParamRef<jobject>& cancel_signal) { |
42 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 42 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
43 printing::PrintSettings print_settings; | 43 printing::PrintSettings print_settings; |
44 InitPdfSettings(env, obj, print_settings); | 44 InitPdfSettings(env, obj, print_settings); |
45 AwPrintManager* print_manager = | 45 AwPrintManager* print_manager = |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 MilsToDots(Java_AwPdfExporter_getBottomMargin(env, obj), dpi); | 91 MilsToDots(Java_AwPdfExporter_getBottomMargin(env, obj), dpi); |
92 settings.SetCustomMargins(margins); | 92 settings.SetCustomMargins(margins); |
93 settings.set_should_print_backgrounds(true); | 93 settings.set_should_print_backgrounds(true); |
94 } | 94 } |
95 | 95 |
96 void AwPdfExporter::DidExportPdf(int fd, bool success) { | 96 void AwPdfExporter::DidExportPdf(int fd, bool success) { |
97 JNIEnv* env = base::android::AttachCurrentThread(); | 97 JNIEnv* env = base::android::AttachCurrentThread(); |
98 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 98 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
99 if (obj.is_null()) | 99 if (obj.is_null()) |
100 return; | 100 return; |
101 Java_AwPdfExporter_didExportPdf(env, obj.obj(), success); | 101 Java_AwPdfExporter_didExportPdf(env, obj, success); |
102 } | 102 } |
103 | 103 |
104 bool RegisterAwPdfExporter(JNIEnv* env) { | 104 bool RegisterAwPdfExporter(JNIEnv* env) { |
105 return RegisterNativesImpl(env); | 105 return RegisterNativesImpl(env); |
106 } | 106 } |
107 | 107 |
108 } // namespace android_webview | 108 } // namespace android_webview |
OLD | NEW |