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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 pdf_settings->SetInteger(kSettingMarginsType, printing::NO_MARGINS); | 56 pdf_settings->SetInteger(kSettingMarginsType, printing::NO_MARGINS); |
57 pdf_settings->SetBoolean(kSettingCollate, true); | 57 pdf_settings->SetBoolean(kSettingCollate, true); |
58 pdf_settings->SetInteger(kSettingCopies, 1); | 58 pdf_settings->SetInteger(kSettingCopies, 1); |
59 pdf_settings->SetInteger(kSettingColor, printing::COLOR); | 59 pdf_settings->SetInteger(kSettingColor, printing::COLOR); |
60 pdf_settings->SetInteger(kSettingDuplexMode, printing::SIMPLEX); | 60 pdf_settings->SetInteger(kSettingDuplexMode, printing::SIMPLEX); |
61 pdf_settings->SetBoolean(kSettingLandscape, false); | 61 pdf_settings->SetBoolean(kSettingLandscape, false); |
62 pdf_settings->SetString(kSettingDeviceName, ""); | 62 pdf_settings->SetString(kSettingDeviceName, ""); |
63 pdf_settings->SetBoolean(kSettingPrintToPDF, true); | 63 pdf_settings->SetBoolean(kSettingPrintToPDF, true); |
64 pdf_settings->SetBoolean(kSettingCloudPrintDialog, false); | 64 pdf_settings->SetBoolean(kSettingCloudPrintDialog, false); |
65 pdf_settings->SetBoolean(kSettingPrintWithPrivet, false); | 65 pdf_settings->SetBoolean(kSettingPrintWithPrivet, false); |
| 66 pdf_settings->SetBoolean(kSettingPrintWithExtension, false); |
66 return UpdatePrintSettings(*pdf_settings); | 67 return UpdatePrintSettings(*pdf_settings); |
67 } | 68 } |
68 | 69 |
69 PrintingContext::Result PrintingContext::UpdatePrintSettings( | 70 PrintingContext::Result PrintingContext::UpdatePrintSettings( |
70 const base::DictionaryValue& job_settings) { | 71 const base::DictionaryValue& job_settings) { |
71 ResetSettings(); | 72 ResetSettings(); |
72 | 73 |
73 if (!PrintSettingsFromJobSettings(job_settings, &settings_)) { | 74 if (!PrintSettingsFromJobSettings(job_settings, &settings_)) { |
74 NOTREACHED(); | 75 NOTREACHED(); |
75 return OnError(); | 76 return OnError(); |
76 } | 77 } |
77 | 78 |
78 bool print_to_pdf = false; | 79 bool print_to_pdf = false; |
79 bool is_cloud_dialog = false; | 80 bool is_cloud_dialog = false; |
80 bool print_with_privet = false; | 81 bool print_with_privet = false; |
| 82 bool print_with_extension = false; |
81 | 83 |
82 if (!job_settings.GetBoolean(kSettingPrintToPDF, &print_to_pdf) || | 84 if (!job_settings.GetBoolean(kSettingPrintToPDF, &print_to_pdf) || |
83 !job_settings.GetBoolean(kSettingCloudPrintDialog, &is_cloud_dialog) || | 85 !job_settings.GetBoolean(kSettingCloudPrintDialog, &is_cloud_dialog) || |
84 !job_settings.GetBoolean(kSettingPrintWithPrivet, &print_with_privet)) { | 86 !job_settings.GetBoolean(kSettingPrintWithPrivet, &print_with_privet) || |
| 87 !job_settings.GetBoolean(kSettingPrintWithExtension, |
| 88 &print_with_extension)) { |
85 NOTREACHED(); | 89 NOTREACHED(); |
86 return OnError(); | 90 return OnError(); |
87 } | 91 } |
88 | 92 |
89 bool print_to_cloud = job_settings.HasKey(kSettingCloudPrintId); | 93 bool print_to_cloud = job_settings.HasKey(kSettingCloudPrintId); |
90 bool open_in_external_preview = | 94 bool open_in_external_preview = |
91 job_settings.HasKey(kSettingOpenPDFInPreview); | 95 job_settings.HasKey(kSettingOpenPDFInPreview); |
92 | 96 |
93 if (!open_in_external_preview && (print_to_pdf || print_to_cloud || | 97 if (!open_in_external_preview && |
94 is_cloud_dialog || print_with_privet)) { | 98 (print_to_pdf || print_to_cloud || is_cloud_dialog || print_with_privet || |
| 99 print_with_extension)) { |
95 settings_.set_dpi(kDefaultPdfDpi); | 100 settings_.set_dpi(kDefaultPdfDpi); |
96 gfx::Size paper_size(GetPdfPaperSizeDeviceUnits()); | 101 gfx::Size paper_size(GetPdfPaperSizeDeviceUnits()); |
97 if (!settings_.requested_media().size_microns.IsEmpty()) { | 102 if (!settings_.requested_media().size_microns.IsEmpty()) { |
98 float deviceMicronsPerDeviceUnit = | 103 float deviceMicronsPerDeviceUnit = |
99 (kHundrethsMMPerInch * 10.0f) / settings_.device_units_per_inch(); | 104 (kHundrethsMMPerInch * 10.0f) / settings_.device_units_per_inch(); |
100 paper_size = gfx::Size(settings_.requested_media().size_microns.width() / | 105 paper_size = gfx::Size(settings_.requested_media().size_microns.width() / |
101 deviceMicronsPerDeviceUnit, | 106 deviceMicronsPerDeviceUnit, |
102 settings_.requested_media().size_microns.height() / | 107 settings_.requested_media().size_microns.height() / |
103 deviceMicronsPerDeviceUnit); | 108 deviceMicronsPerDeviceUnit); |
104 } | 109 } |
105 gfx::Rect paper_rect(0, 0, paper_size.width(), paper_size.height()); | 110 gfx::Rect paper_rect(0, 0, paper_size.width(), paper_size.height()); |
106 if (print_to_cloud || print_with_privet) { | 111 if (print_to_cloud || print_with_privet) { |
107 paper_rect.Inset( | 112 paper_rect.Inset( |
108 kCloudPrintMarginInch * settings_.device_units_per_inch(), | 113 kCloudPrintMarginInch * settings_.device_units_per_inch(), |
109 kCloudPrintMarginInch * settings_.device_units_per_inch()); | 114 kCloudPrintMarginInch * settings_.device_units_per_inch()); |
110 } | 115 } |
111 settings_.SetPrinterPrintableArea(paper_size, paper_rect, true); | 116 settings_.SetPrinterPrintableArea(paper_size, paper_rect, true); |
112 return OK; | 117 return OK; |
113 } | 118 } |
114 | 119 |
115 bool show_system_dialog = false; | 120 bool show_system_dialog = false; |
116 job_settings.GetBoolean(printing::kSettingShowSystemDialog, | 121 job_settings.GetBoolean(printing::kSettingShowSystemDialog, |
117 &show_system_dialog); | 122 &show_system_dialog); |
118 | 123 |
119 return UpdatePrinterSettings(open_in_external_preview, show_system_dialog); | 124 return UpdatePrinterSettings(open_in_external_preview, show_system_dialog); |
120 } | 125 } |
121 | 126 |
122 } // namespace printing | 127 } // namespace printing |
OLD | NEW |