| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "printing/printing_context.h" | 5 #include "printing/printing_context.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "printing/page_setup.h" | 9 #include "printing/page_setup.h" |
| 10 #include "printing/page_size_margins.h" | 10 #include "printing/page_size_margins.h" |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 } | 89 } |
| 90 | 90 |
| 91 bool print_to_cloud = job_settings.HasKey(kSettingCloudPrintId); | 91 bool print_to_cloud = job_settings.HasKey(kSettingCloudPrintId); |
| 92 bool open_in_external_preview = | 92 bool open_in_external_preview = |
| 93 job_settings.HasKey(kSettingOpenPDFInPreview); | 93 job_settings.HasKey(kSettingOpenPDFInPreview); |
| 94 | 94 |
| 95 if (!open_in_external_preview && (print_to_pdf || print_to_cloud || | 95 if (!open_in_external_preview && (print_to_pdf || print_to_cloud || |
| 96 is_cloud_dialog || print_with_privet)) { | 96 is_cloud_dialog || print_with_privet)) { |
| 97 settings_.set_dpi(kDefaultPdfDpi); | 97 settings_.set_dpi(kDefaultPdfDpi); |
| 98 gfx::Size paper_size(GetPdfPaperSizeDeviceUnits()); | 98 gfx::Size paper_size(GetPdfPaperSizeDeviceUnits()); |
| 99 const base::DictionaryValue* media_size = NULL; | 99 if (!settings_.requested_media().size_microns.IsEmpty()) { |
| 100 if (job_settings.GetDictionary(kSettingMediaSize, &media_size)) { | 100 float deviceMicronsPerDeviceUnit = |
| 101 int width_microns = 0; | 101 (kHundrethsMMPerInch * 10.0f) / settings_.device_units_per_inch(); |
| 102 int height_microns = 0; | 102 paper_size = gfx::Size(settings_.requested_media().size_microns.width() / |
| 103 if (media_size->GetInteger(kSettingMediaSizeWidthMicrons, | 103 deviceMicronsPerDeviceUnit, |
| 104 &width_microns) && | 104 settings_.requested_media().size_microns.height() / |
| 105 media_size->GetInteger(kSettingMediaSizeHeightMicrons, | 105 deviceMicronsPerDeviceUnit); |
| 106 &height_microns)) { | |
| 107 float deviceMicronsPerDeviceUnit = | |
| 108 (kHundrethsMMPerInch * 10.0f) / settings_.device_units_per_inch(); | |
| 109 paper_size = gfx::Size(width_microns / deviceMicronsPerDeviceUnit, | |
| 110 height_microns / deviceMicronsPerDeviceUnit); | |
| 111 } | |
| 112 } | 106 } |
| 113 gfx::Rect paper_rect(0, 0, paper_size.width(), paper_size.height()); | 107 gfx::Rect paper_rect(0, 0, paper_size.width(), paper_size.height()); |
| 114 if (print_to_cloud || print_with_privet) { | 108 if (print_to_cloud || print_with_privet) { |
| 115 paper_rect.Inset( | 109 paper_rect.Inset( |
| 116 kCloudPrintMarginInch * settings_.device_units_per_inch(), | 110 kCloudPrintMarginInch * settings_.device_units_per_inch(), |
| 117 kCloudPrintMarginInch * settings_.device_units_per_inch()); | 111 kCloudPrintMarginInch * settings_.device_units_per_inch()); |
| 118 } | 112 } |
| 119 settings_.SetPrinterPrintableArea(paper_size, paper_rect, true); | 113 settings_.SetPrinterPrintableArea(paper_size, paper_rect, true); |
| 120 return OK; | 114 return OK; |
| 121 } | 115 } |
| 122 | 116 |
| 123 return UpdatePrinterSettings(open_in_external_preview); | 117 return UpdatePrinterSettings(open_in_external_preview); |
| 124 } | 118 } |
| 125 | 119 |
| 126 } // namespace printing | 120 } // namespace printing |
| OLD | NEW |