summaryrefslogtreecommitdiffstats
path: root/android_webview
diff options
context:
space:
mode:
authortimvolodine <timvolodine@chromium.org>2015-08-07 06:05:21 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-07 13:05:54 +0000
commitd72d37dfbf6a2c2a7417ce6a6ed5d6231de096a7 (patch)
tree357e39a66b849510be8bd94ee9131d166c2981a3 /android_webview
parent0ffadce32916c6c4d7343b2d263d8e75606b7311 (diff)
downloadchromium_src-d72d37dfbf6a2c2a7417ce6a6ed5d6231de096a7.zip
chromium_src-d72d37dfbf6a2c2a7417ce6a6ed5d6231de096a7.tar.gz
chromium_src-d72d37dfbf6a2c2a7417ce6a6ed5d6231de096a7.tar.bz2
[Android WebView] Don't store unnecessary copy of print_settings in aw_pdf_exporter.
There is no need to keep a copy of the print_settings in aw_pdf_exporter anymore because it is owned by AwPrintManager now. BUG=465802 Review URL: https://codereview.chromium.org/1253423003 Cr-Commit-Position: refs/heads/master@{#342340}
Diffstat (limited to 'android_webview')
-rw-r--r--android_webview/native/aw_pdf_exporter.cc22
-rw-r--r--android_webview/native/aw_pdf_exporter.h7
2 files changed, 15 insertions, 14 deletions
diff --git a/android_webview/native/aw_pdf_exporter.cc b/android_webview/native/aw_pdf_exporter.cc
index da477ce..48fa9f9 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) {
diff --git a/android_webview/native/aw_pdf_exporter.h b/android_webview/native/aw_pdf_exporter.h
index d9f3a6b..f2513f8 100644
--- a/android_webview/native/aw_pdf_exporter.h
+++ b/android_webview/native/aw_pdf_exporter.h
@@ -10,7 +10,6 @@
#include "base/android/jni_weak_ref.h"
#include "base/android/scoped_java_ref.h"
#include "base/basictypes.h"
-#include "base/memory/scoped_ptr.h"
#include "skia/ext/refptr.h"
namespace content {
@@ -37,14 +36,14 @@ class AwPdfExporter {
jobject cancel_signal);
private:
- void CreatePdfSettings(JNIEnv* env, jobject obj);
+ void InitPdfSettings(JNIEnv* env,
+ jobject obj,
+ printing::PrintSettings& settings);
void DidExportPdf(int fd, bool success);
JavaObjectWeakGlobalRef java_ref_;
content::WebContents* web_contents_;
- scoped_ptr<printing::PrintSettings> print_settings_;
-
DISALLOW_COPY_AND_ASSIGN(AwPdfExporter);
};