Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Unified Diff: android_webview/native/aw_pdf_exporter.cc

Issue 1253423003: [Android WebView] Don't store unnecessary copy of print_settings in aw_pdf_exporter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « android_webview/native/aw_pdf_exporter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: android_webview/native/aw_pdf_exporter.cc
diff --git a/android_webview/native/aw_pdf_exporter.cc b/android_webview/native/aw_pdf_exporter.cc
index da477ce684977d0b06d08bf1d174bcf7c1b049c5..48fa9f991fbf6d830ff74121f6a168b39de43f31 100644
--- a/android_webview/native/aw_pdf_exporter.cc
+++ b/android_webview/native/aw_pdf_exporter.cc
@@ -37,10 +37,11 @@ void AwPdfExporter::ExportToPdf(JNIEnv* env,
int fd,
jobject cancel_signal) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
- CreatePdfSettings(env, obj);
+ printing::PrintSettings print_settings;
+ InitPdfSettings(env, obj, print_settings);
AwPrintManager* print_manager =
AwPrintManager::CreateForWebContents(
- web_contents_, *print_settings_, base::FileDescriptor(fd, false),
+ web_contents_, print_settings, base::FileDescriptor(fd, false),
base::Bind(&AwPdfExporter::DidExportPdf, base::Unretained(this)));
if (!print_manager->PrintNow())
@@ -54,8 +55,9 @@ int MilsToDots(int val, int dpi) {
}
} // anonymous namespace
-void AwPdfExporter::CreatePdfSettings(JNIEnv* env, jobject obj) {
- print_settings_.reset(new printing::PrintSettings);
+void AwPdfExporter::InitPdfSettings(JNIEnv* env,
+ jobject obj,
+ printing::PrintSettings& settings) {
int dpi = Java_AwPdfExporter_getDpi(env, obj);
int width = Java_AwPdfExporter_getPageWidth(env, obj);
int height = Java_AwPdfExporter_getPageHeight(env, obj);
@@ -68,12 +70,12 @@ void AwPdfExporter::CreatePdfSettings(JNIEnv* env, jobject obj) {
// Assume full page is printable for now.
printable_area_device_units.SetRect(0, 0, width_in_dots, height_in_dots);
- print_settings_->set_dpi(dpi);
+ settings.set_dpi(dpi);
// TODO(sgurun) verify that the value for newly added parameter for
// (i.e. landscape_needs_flip) is correct.
- print_settings_->SetPrinterPrintableArea(physical_size_device_units,
- printable_area_device_units,
- true);
+ settings.SetPrinterPrintableArea(physical_size_device_units,
+ printable_area_device_units,
+ true);
printing::PageMargins margins;
margins.left =
@@ -84,8 +86,8 @@ void AwPdfExporter::CreatePdfSettings(JNIEnv* env, jobject obj) {
MilsToDots(Java_AwPdfExporter_getTopMargin(env, obj), dpi);
margins.bottom =
MilsToDots(Java_AwPdfExporter_getBottomMargin(env, obj), dpi);
- print_settings_->SetCustomMargins(margins);
- print_settings_->set_should_print_backgrounds(true);
+ settings.SetCustomMargins(margins);
+ settings.set_should_print_backgrounds(true);
}
void AwPdfExporter::DidExportPdf(int fd, bool success) {
« no previous file with comments | « android_webview/native/aw_pdf_exporter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698