| 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 15 matching lines...) Expand all Loading... |
| 26 AwPdfExporter::~AwPdfExporter() { | 26 AwPdfExporter::~AwPdfExporter() { |
| 27 JNIEnv* env = base::android::AttachCurrentThread(); | 27 JNIEnv* env = base::android::AttachCurrentThread(); |
| 28 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 28 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 29 if (obj.is_null()) | 29 if (obj.is_null()) |
| 30 return; | 30 return; |
| 31 // Clear the Java peer's weak pointer to |this| object. | 31 // Clear the Java peer's weak pointer to |this| object. |
| 32 Java_AwPdfExporter_setNativeAwPdfExporter(env, obj.obj(), 0); | 32 Java_AwPdfExporter_setNativeAwPdfExporter(env, obj.obj(), 0); |
| 33 } | 33 } |
| 34 | 34 |
| 35 void AwPdfExporter::ExportToPdf(JNIEnv* env, | 35 void AwPdfExporter::ExportToPdf(JNIEnv* env, |
| 36 jobject obj, | 36 const JavaParamRef<jobject>& obj, |
| 37 int fd, | 37 int fd, |
| 38 jobject cancel_signal) { | 38 const JavaParamRef<jobject>& cancel_signal) { |
| 39 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 39 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 40 printing::PrintSettings print_settings; | 40 printing::PrintSettings print_settings; |
| 41 InitPdfSettings(env, obj, print_settings); | 41 InitPdfSettings(env, obj, print_settings); |
| 42 AwPrintManager* print_manager = | 42 AwPrintManager* print_manager = |
| 43 AwPrintManager::CreateForWebContents( | 43 AwPrintManager::CreateForWebContents( |
| 44 web_contents_, print_settings, base::FileDescriptor(fd, false), | 44 web_contents_, print_settings, base::FileDescriptor(fd, false), |
| 45 base::Bind(&AwPdfExporter::DidExportPdf, base::Unretained(this))); | 45 base::Bind(&AwPdfExporter::DidExportPdf, base::Unretained(this))); |
| 46 | 46 |
| 47 if (!print_manager->PrintNow()) | 47 if (!print_manager->PrintNow()) |
| 48 DidExportPdf(fd, false); | 48 DidExportPdf(fd, false); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 if (obj.is_null()) | 96 if (obj.is_null()) |
| 97 return; | 97 return; |
| 98 Java_AwPdfExporter_didExportPdf(env, obj.obj(), success); | 98 Java_AwPdfExporter_didExportPdf(env, obj.obj(), success); |
| 99 } | 99 } |
| 100 | 100 |
| 101 bool RegisterAwPdfExporter(JNIEnv* env) { | 101 bool RegisterAwPdfExporter(JNIEnv* env) { |
| 102 return RegisterNativesImpl(env); | 102 return RegisterNativesImpl(env); |
| 103 } | 103 } |
| 104 | 104 |
| 105 } // namespace android_webview | 105 } // namespace android_webview |
| OLD | NEW |