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

Unified Diff: printing/printing_context_no_system_dialog.cc

Issue 46623002: Move settings setup for PDF and cloud print into single location in PrintingContext (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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
Index: printing/printing_context_no_system_dialog.cc
diff --git a/printing/printing_context_no_system_dialog.cc b/printing/printing_context_no_system_dialog.cc
index 7fd2ceebeb7d0f31e6c8e053a6a88f4e7459a439..d66438611e78599a20372db6ad902fe9146ac640 100644
--- a/printing/printing_context_no_system_dialog.cc
+++ b/printing/printing_context_no_system_dialog.cc
@@ -41,13 +41,15 @@ PrintingContext::Result PrintingContextNoSystemDialog::UseDefaultSettings() {
DCHECK(!in_print_job_);
ResetSettings();
- // TODO(abodenha): Fetch these settings from the OS where possible. See
- // bug 102583.
- // TODO(sanjeevr): We need a better feedback loop between the cloud print
- // dialog and this code.
- int dpi = 300;
- gfx::Size physical_size_device_units;
- gfx::Rect printable_area_device_units;
+ settings_.set_dpi(kDefaultPdfDpi);
+ gfx::Size physical_size = GetPdfPaperSizeDeviceUnits();
+ // Assume full page is printable for now.
+ gfx::Rect printable_area(0, 0, physical_size.width(), physical_size.height());
+ settings_.SetPrinterPrintableArea(physical_size, printable_area, true);
+ return OK;
+}
+
+gfx::Size PrintingContextNoSystemDialog::GetPdfPaperSizeDeviceUnits() {
int32_t width = 0;
int32_t height = 0;
UErrorCode error = U_ZERO_ERROR;
@@ -56,30 +58,22 @@ PrintingContext::Result PrintingContextNoSystemDialog::UseDefaultSettings() {
// If the call failed, assume a paper size of 8.5 x 11 inches.
LOG(WARNING) << "ulocdata_getPaperSize failed, using 8.5 x 11, error: "
<< error;
- width = static_cast<int>(8.5 * dpi);
- height = static_cast<int>(11 * dpi);
+ width = static_cast<int>(
+ kLetterWidthInch * settings_.device_units_per_inch());
+ height = static_cast<int>(
+ kLetterHeightInch * settings_.device_units_per_inch());
} else {
// ulocdata_getPaperSize returns the width and height in mm.
// Convert this to pixels based on the dpi.
- width = static_cast<int>(ConvertUnitDouble(width, 25.4, 1.0) * dpi);
- height = static_cast<int>(ConvertUnitDouble(height, 25.4, 1.0) * dpi);
+ float multiplier = 100 * settings_.device_units_per_inch();
+ multiplier /= kHundrethsMMPerInch;
+ width *= multiplier;
+ height *= multiplier;
}
-
- physical_size_device_units.SetSize(width, height);
-
- // Assume full page is printable for now.
- printable_area_device_units.SetRect(0, 0, width, height);
-
- settings_.set_dpi(dpi);
- settings_.SetPrinterPrintableArea(physical_size_device_units,
- printable_area_device_units,
- dpi, true);
-
- return OK;
+ return gfx::Size(width, height);
}
PrintingContext::Result PrintingContextNoSystemDialog::UpdatePrinterSettings(
- bool target_is_pdf,
bool external_preview) {
return OK;
}

Powered by Google App Engine
This is Rietveld 408576698