OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_system_dialog_win.h" | 5 #include "printing/printing_context_system_dialog_win.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "printing/backend/win_helper.h" | 9 #include "printing/backend/win_helper.h" |
10 #include "printing/print_settings_initializer_win.h" | 10 #include "printing/print_settings_initializer_win.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 // get the wrong Z-order which will make the print dialog appear behind the | 89 // get the wrong Z-order which will make the print dialog appear behind the |
90 // browser frame (but still being modal) so neither the browser frame nor | 90 // browser frame (but still being modal) so neither the browser frame nor |
91 // the print dialog will get any input. See http://crbug.com/342697 | 91 // the print dialog will get any input. See http://crbug.com/342697 |
92 // http://crbug.com/180997 for details. | 92 // http://crbug.com/180997 for details. |
93 base::MessageLoop::ScopedNestableTaskAllower allow( | 93 base::MessageLoop::ScopedNestableTaskAllower allow( |
94 base::MessageLoop::current()); | 94 base::MessageLoop::current()); |
95 | 95 |
96 return PrintDlgEx(options); | 96 return PrintDlgEx(options); |
97 } | 97 } |
98 | 98 |
99 bool PrintingContextSytemDialogWin::InitializeSettings( | 99 bool PrintingContextSytemDialogWin::InitializeSettingsWithRanges( |
100 const DEVMODE& dev_mode, | 100 const DEVMODE& dev_mode, |
101 const std::wstring& new_device_name, | 101 const std::wstring& new_device_name, |
102 const PRINTPAGERANGE* ranges, | 102 const PRINTPAGERANGE* ranges, |
103 int number_ranges, | 103 int number_ranges, |
104 bool selection_only) { | 104 bool selection_only) { |
105 DCHECK(GetDeviceCaps(context(), CLIPCAPS)); | 105 DCHECK(GetDeviceCaps(context(), CLIPCAPS)); |
106 DCHECK(GetDeviceCaps(context(), RASTERCAPS) & RC_STRETCHDIB); | 106 DCHECK(GetDeviceCaps(context(), RASTERCAPS) & RC_STRETCHDIB); |
107 DCHECK(GetDeviceCaps(context(), RASTERCAPS) & RC_BITMAP64); | 107 DCHECK(GetDeviceCaps(context(), RASTERCAPS) & RC_BITMAP64); |
108 // Some printers don't advertise these. | 108 // Some printers don't advertise these. |
109 // DCHECK(GetDeviceCaps(context(), RASTERCAPS) & RC_SCALING); | 109 // DCHECK(GetDeviceCaps(context(), RASTERCAPS) & RC_SCALING); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 PRINTPAGERANGE* page_ranges = NULL; | 174 PRINTPAGERANGE* page_ranges = NULL; |
175 DWORD num_page_ranges = 0; | 175 DWORD num_page_ranges = 0; |
176 bool print_selection_only = false; | 176 bool print_selection_only = false; |
177 if (dialog_options.Flags & PD_PAGENUMS) { | 177 if (dialog_options.Flags & PD_PAGENUMS) { |
178 page_ranges = dialog_options.lpPageRanges; | 178 page_ranges = dialog_options.lpPageRanges; |
179 num_page_ranges = dialog_options.nPageRanges; | 179 num_page_ranges = dialog_options.nPageRanges; |
180 } | 180 } |
181 if (dialog_options.Flags & PD_SELECTION) { | 181 if (dialog_options.Flags & PD_SELECTION) { |
182 print_selection_only = true; | 182 print_selection_only = true; |
183 } | 183 } |
184 success = InitializeSettings(*dev_mode, | 184 success = |
185 device_name, | 185 InitializeSettingsWithRanges(*dev_mode, device_name, page_ranges, |
186 page_ranges, | 186 num_page_ranges, print_selection_only); |
187 num_page_ranges, | |
188 print_selection_only); | |
189 } | 187 } |
190 | 188 |
191 if (!success && dialog_options.hDC) { | 189 if (!success && dialog_options.hDC) { |
192 DeleteDC(dialog_options.hDC); | 190 DeleteDC(dialog_options.hDC); |
193 set_context(NULL); | 191 set_context(NULL); |
194 } | 192 } |
195 | 193 |
196 if (dev_mode) { | 194 if (dev_mode) { |
197 GlobalUnlock(dialog_options.hDevMode); | 195 GlobalUnlock(dialog_options.hDevMode); |
198 } | 196 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 device_name = reinterpret_cast<const wchar_t*>( | 238 device_name = reinterpret_cast<const wchar_t*>( |
241 reinterpret_cast<const wchar_t*>(dev_names) + | 239 reinterpret_cast<const wchar_t*>(dev_names) + |
242 dev_names->wDeviceOffset); | 240 dev_names->wDeviceOffset); |
243 GlobalUnlock(dialog_options.hDevNames); | 241 GlobalUnlock(dialog_options.hDevNames); |
244 } | 242 } |
245 } | 243 } |
246 | 244 |
247 bool success = false; | 245 bool success = false; |
248 if (dev_mode && !device_name.empty()) { | 246 if (dev_mode && !device_name.empty()) { |
249 set_context(dialog_options.hDC); | 247 set_context(dialog_options.hDC); |
250 success = InitializeSettings(*dev_mode, device_name, NULL, 0, false); | 248 success = |
| 249 InitializeSettingsWithRanges(*dev_mode, device_name, NULL, 0, false); |
251 } | 250 } |
252 | 251 |
253 if (!success && dialog_options.hDC) { | 252 if (!success && dialog_options.hDC) { |
254 DeleteDC(dialog_options.hDC); | 253 DeleteDC(dialog_options.hDC); |
255 set_context(NULL); | 254 set_context(NULL); |
256 } | 255 } |
257 | 256 |
258 if (dev_mode) { | 257 if (dev_mode) { |
259 GlobalUnlock(dialog_options.hDevMode); | 258 GlobalUnlock(dialog_options.hDevMode); |
260 } | 259 } |
261 | 260 |
262 if (dialog_options.hDevMode != NULL) | 261 if (dialog_options.hDevMode != NULL) |
263 GlobalFree(dialog_options.hDevMode); | 262 GlobalFree(dialog_options.hDevMode); |
264 if (dialog_options.hDevNames != NULL) | 263 if (dialog_options.hDevNames != NULL) |
265 GlobalFree(dialog_options.hDevNames); | 264 GlobalFree(dialog_options.hDevNames); |
266 | 265 |
267 return context() ? OK : FAILED; | 266 return context() ? OK : FAILED; |
268 } | 267 } |
269 | 268 |
270 } // namespace printing | 269 } // namespace printing |
OLD | NEW |