OLD | NEW |
1 // Copyright (c) 2009 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_win.h" | 5 #include "printing/printing_context_win.h" |
6 | 6 |
7 #include <winspool.h> | 7 #include <winspool.h> |
8 | 8 |
9 #include "base/file_util.h" | |
10 #include "base/i18n/file_util_icu.h" | 9 #include "base/i18n/file_util_icu.h" |
11 #include "base/i18n/time_formatting.h" | 10 #include "base/i18n/time_formatting.h" |
12 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
13 #include "base/time.h" | 12 #include "base/time.h" |
14 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
15 #include "printing/print_settings_initializer_win.h" | 14 #include "printing/print_settings_initializer_win.h" |
16 #include "printing/printed_document.h" | 15 #include "printing/printed_document.h" |
17 #include "skia/ext/platform_device_win.h" | 16 #include "skia/ext/platform_device_win.h" |
18 | 17 |
19 using base::Time; | 18 using base::Time; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 dialog_options.nPageRanges = 1; | 180 dialog_options.nPageRanges = 1; |
182 dialog_options.nMaxPageRanges = arraysize(ranges); | 181 dialog_options.nMaxPageRanges = arraysize(ranges); |
183 dialog_options.nMinPage = 1; | 182 dialog_options.nMinPage = 1; |
184 dialog_options.nMaxPage = max_pages; | 183 dialog_options.nMaxPage = max_pages; |
185 dialog_options.lpPageRanges = ranges; | 184 dialog_options.lpPageRanges = ranges; |
186 } else { | 185 } else { |
187 // No need to bother, we don't know how many pages are available. | 186 // No need to bother, we don't know how many pages are available. |
188 dialog_options.Flags |= PD_NOPAGENUMS; | 187 dialog_options.Flags |= PD_NOPAGENUMS; |
189 } | 188 } |
190 | 189 |
191 { | 190 if ((*print_dialog_func_)(&dialog_options) != S_OK) { |
192 if ((*print_dialog_func_)(&dialog_options) != S_OK) { | 191 ResetSettings(); |
193 ResetSettings(); | 192 callback->Run(FAILED); |
194 callback->Run(FAILED); | |
195 } | |
196 } | 193 } |
| 194 |
197 // TODO(maruel): Support PD_PRINTTOFILE. | 195 // TODO(maruel): Support PD_PRINTTOFILE. |
198 callback->Run(ParseDialogResultEx(dialog_options)); | 196 callback->Run(ParseDialogResultEx(dialog_options)); |
199 } | 197 } |
200 | 198 |
201 PrintingContext::Result PrintingContextWin::UseDefaultSettings() { | 199 PrintingContext::Result PrintingContextWin::UseDefaultSettings() { |
202 DCHECK(!in_print_job_); | 200 DCHECK(!in_print_job_); |
203 | 201 |
204 PRINTDLG dialog_options = { sizeof(PRINTDLG) }; | 202 PRINTDLG dialog_options = { sizeof(PRINTDLG) }; |
205 dialog_options.Flags = PD_RETURNDC | PD_RETURNDEFAULT; | 203 dialog_options.Flags = PD_RETURNDC | PD_RETURNDEFAULT; |
206 if (PrintDlg(&dialog_options) == 0) { | 204 if (PrintDlg(&dialog_options) == 0) { |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
606 if (buf_size) { | 604 if (buf_size) { |
607 buffer->reset(new uint8[buf_size]); | 605 buffer->reset(new uint8[buf_size]); |
608 memset(buffer->get(), 0, buf_size); | 606 memset(buffer->get(), 0, buf_size); |
609 if (!GetPrinter(printer, level, buffer->get(), buf_size, &buf_size)) { | 607 if (!GetPrinter(printer, level, buffer->get(), buf_size, &buf_size)) { |
610 buffer->reset(); | 608 buffer->reset(); |
611 } | 609 } |
612 } | 610 } |
613 } | 611 } |
614 | 612 |
615 } // namespace printing | 613 } // namespace printing |
OLD | NEW |