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/renderer_host/print_manager.h" | |
hush (inactive)
2015/01/14 01:55:47
we still need print manager in this file?
sgurun-gerrit only
2015/01/14 02:03:17
aw_pdf_exporter.h includes it since it implements
| |
8 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
9 #include "base/logging.h" | 8 #include "base/logging.h" |
10 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
11 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
12 #include "jni/AwPdfExporter_jni.h" | 11 #include "jni/AwPdfExporter_jni.h" |
13 #include "printing/print_settings.h" | 12 #include "printing/print_settings.h" |
14 #include "printing/units.h" | 13 #include "printing/units.h" |
15 | 14 |
16 using base::android::AttachCurrentThread; | 15 using base::android::AttachCurrentThread; |
17 using base::android::ScopedJavaGlobalRef; | 16 using base::android::ScopedJavaGlobalRef; |
(...skipping 23 matching lines...) Expand all Loading... | |
41 // Clear the Java peer's weak pointer to |this| object. | 40 // Clear the Java peer's weak pointer to |this| object. |
42 Java_AwPdfExporter_setNativeAwPdfExporter(env, obj.obj(), 0); | 41 Java_AwPdfExporter_setNativeAwPdfExporter(env, obj.obj(), 0); |
43 } | 42 } |
44 | 43 |
45 void AwPdfExporter::ExportToPdf(JNIEnv* env, | 44 void AwPdfExporter::ExportToPdf(JNIEnv* env, |
46 jobject obj, | 45 jobject obj, |
47 int fd, | 46 int fd, |
48 jobject cancel_signal) { | 47 jobject cancel_signal) { |
49 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
50 CreatePdfSettings(env, obj); | 49 CreatePdfSettings(env, obj); |
51 print_manager_.reset( | 50 PrintManager* print_manager = |
52 new PrintManager(web_contents_, print_settings_.get(), fd, this)); | 51 PrintManager::CreateForWebContents( |
53 if (!print_manager_->PrintNow()) | 52 web_contents_, print_settings_.get(), fd, this); |
53 print_manager = | |
boliu
2015/01/14 01:41:02
Why call CreateForWebContents with the exact same
hush (inactive)
2015/01/14 01:55:47
print_manager is assigned 2 times?
sgurun-gerrit only
2015/01/14 02:03:17
Done.
sgurun-gerrit only
2015/01/14 02:03:17
Done.
| |
54 PrintManager::CreateForWebContents( | |
55 web_contents_, print_settings_.get(), fd, this); | |
56 if (!print_manager->PrintNow()) | |
54 DidExportPdf(false); | 57 DidExportPdf(false); |
55 } | 58 } |
56 | 59 |
57 namespace { | 60 namespace { |
58 // Converts from 1/1000 of inches to device units using DPI. | 61 // Converts from 1/1000 of inches to device units using DPI. |
59 int MilsToDots(int val, int dpi) { | 62 int MilsToDots(int val, int dpi) { |
60 return static_cast<int>(ConvertUnitDouble(val, 1000.0, dpi)); | 63 return static_cast<int>(ConvertUnitDouble(val, 1000.0, dpi)); |
61 } | 64 } |
62 | 65 |
63 } // anonymous namespace | 66 } // anonymous namespace |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 // TODO(sgurun) implement. Needs connecting with the |cancel_signal| passed | 111 // TODO(sgurun) implement. Needs connecting with the |cancel_signal| passed |
109 // in the constructor. | 112 // in the constructor. |
110 return false; | 113 return false; |
111 } | 114 } |
112 | 115 |
113 bool RegisterAwPdfExporter(JNIEnv* env) { | 116 bool RegisterAwPdfExporter(JNIEnv* env) { |
114 return RegisterNativesImpl(env); | 117 return RegisterNativesImpl(env); |
115 } | 118 } |
116 | 119 |
117 } // namespace android_webview | 120 } // namespace android_webview |
OLD | NEW |