summaryrefslogtreecommitdiffstats
path: root/printing/printing_context.cc
diff options
context:
space:
mode:
authorvitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-04 18:34:29 +0000
committervitalybuka@chromium.org <vitalybuka@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-04 18:34:29 +0000
commit4c9054b4d4aad1c2b53e2d893e1928b836fad5f2 (patch)
tree9cd775f2aee0beb7e5fafe526630f123fdec03c1 /printing/printing_context.cc
parent08eb4c7b2d85c9b669d9864bc28d419fdd5198c1 (diff)
downloadchromium_src-4c9054b4d4aad1c2b53e2d893e1928b836fad5f2.zip
chromium_src-4c9054b4d4aad1c2b53e2d893e1928b836fad5f2.tar.gz
chromium_src-4c9054b4d4aad1c2b53e2d893e1928b836fad5f2.tar.bz2
Move settings setup for PDF and cloud print into single location in PrintingContext.
Hard-code CloudPrint printable area until we start to receive this data from server. BUG=305731 NOTRY=true Review URL: https://codereview.chromium.org/46623002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232741 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/printing_context.cc')
-rw-r--r--printing/printing_context.cc26
1 files changed, 23 insertions, 3 deletions
diff --git a/printing/printing_context.cc b/printing/printing_context.cc
index 9b3b8ae..40342e9 100644
--- a/printing/printing_context.cc
+++ b/printing/printing_context.cc
@@ -9,9 +9,14 @@
#include "printing/page_setup.h"
#include "printing/page_size_margins.h"
#include "printing/print_settings_initializer.h"
+#include "printing/units.h"
namespace printing {
+namespace {
+const float kCloudPrintMarginInch = 0.25;
+}
+
PrintingContext::PrintingContext(const std::string& app_locale)
: dialog_box_dismissed_(false),
in_print_job_(false),
@@ -66,9 +71,24 @@ PrintingContext::Result PrintingContext::UpdatePrintSettings(
bool open_in_external_preview =
job_settings.HasKey(kSettingOpenPDFInPreview);
- return UpdatePrinterSettings(
- print_to_pdf || is_cloud_dialog || print_to_cloud,
- open_in_external_preview);
+ if (!open_in_external_preview &&
+ (print_to_pdf || print_to_cloud || is_cloud_dialog)) {
+ settings_.set_dpi(kDefaultPdfDpi);
+ // Cloud print should get size and rect from capabilities received from
+ // server.
+ gfx::Size paper_size(GetPdfPaperSizeDeviceUnits());
+ gfx::Rect paper_rect(0, 0, paper_size.width(), paper_size.height());
+ if (print_to_cloud) {
+ paper_rect.Inset(
+ kCloudPrintMarginInch * settings_.device_units_per_inch(),
+ kCloudPrintMarginInch * settings_.device_units_per_inch());
+ }
+ DCHECK_EQ(settings_.device_units_per_inch(), kDefaultPdfDpi);
+ settings_.SetPrinterPrintableArea(paper_size, paper_rect, true);
+ return OK;
+ }
+
+ return UpdatePrinterSettings(open_in_external_preview);
}
} // namespace printing