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_win.h" | 5 #include "printing/printing_context_win.h" |
6 | 6 |
7 #include <winspool.h> | 7 #include <winspool.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 : PrintingContext(app_locale), | 206 : PrintingContext(app_locale), |
207 context_(NULL), | 207 context_(NULL), |
208 dialog_box_(NULL), | 208 dialog_box_(NULL), |
209 print_dialog_func_(&PrintDlgEx) { | 209 print_dialog_func_(&PrintDlgEx) { |
210 } | 210 } |
211 | 211 |
212 PrintingContextWin::~PrintingContextWin() { | 212 PrintingContextWin::~PrintingContextWin() { |
213 ReleaseContext(); | 213 ReleaseContext(); |
214 } | 214 } |
215 | 215 |
216 void PrintingContextWin::AskUserForSettings(gfx::NativeView view, | 216 void PrintingContextWin::AskUserForSettings( |
217 int max_pages, | 217 gfx::NativeView view, int max_pages, bool has_selection, |
218 bool has_selection, | 218 const PrintSettingsCallback& callback) { |
219 PrintSettingsCallback* callback) { | |
220 #if !defined(USE_AURA) | 219 #if !defined(USE_AURA) |
221 DCHECK(!in_print_job_); | 220 DCHECK(!in_print_job_); |
222 dialog_box_dismissed_ = false; | 221 dialog_box_dismissed_ = false; |
223 | 222 |
224 HWND window; | 223 HWND window; |
225 if (!view || !IsWindow(view)) { | 224 if (!view || !IsWindow(view)) { |
226 // TODO(maruel): bug 1214347 Get the right browser window instead. | 225 // TODO(maruel): bug 1214347 Get the right browser window instead. |
227 window = GetDesktopWindow(); | 226 window = GetDesktopWindow(); |
228 } else { | 227 } else { |
229 window = GetAncestor(view, GA_ROOTOWNER); | 228 window = GetAncestor(view, GA_ROOTOWNER); |
(...skipping 30 matching lines...) Expand all Loading... |
260 dialog_options.nMinPage = 1; | 259 dialog_options.nMinPage = 1; |
261 dialog_options.nMaxPage = max_pages; | 260 dialog_options.nMaxPage = max_pages; |
262 dialog_options.lpPageRanges = ranges; | 261 dialog_options.lpPageRanges = ranges; |
263 } else { | 262 } else { |
264 // No need to bother, we don't know how many pages are available. | 263 // No need to bother, we don't know how many pages are available. |
265 dialog_options.Flags |= PD_NOPAGENUMS; | 264 dialog_options.Flags |= PD_NOPAGENUMS; |
266 } | 265 } |
267 | 266 |
268 if ((*print_dialog_func_)(&dialog_options) != S_OK) { | 267 if ((*print_dialog_func_)(&dialog_options) != S_OK) { |
269 ResetSettings(); | 268 ResetSettings(); |
270 callback->Run(FAILED); | 269 callback.Run(FAILED); |
271 } | 270 } |
272 | 271 |
273 // TODO(maruel): Support PD_PRINTTOFILE. | 272 // TODO(maruel): Support PD_PRINTTOFILE. |
274 callback->Run(ParseDialogResultEx(dialog_options)); | 273 callback.Run(ParseDialogResultEx(dialog_options)); |
275 delete callback; | |
276 #endif | 274 #endif |
277 } | 275 } |
278 | 276 |
279 PrintingContext::Result PrintingContextWin::UseDefaultSettings() { | 277 PrintingContext::Result PrintingContextWin::UseDefaultSettings() { |
280 DCHECK(!in_print_job_); | 278 DCHECK(!in_print_job_); |
281 | 279 |
282 PRINTDLG dialog_options = { sizeof(PRINTDLG) }; | 280 PRINTDLG dialog_options = { sizeof(PRINTDLG) }; |
283 dialog_options.Flags = PD_RETURNDC | PD_RETURNDEFAULT; | 281 dialog_options.Flags = PD_RETURNDC | PD_RETURNDEFAULT; |
284 if (PrintDlg(&dialog_options)) | 282 if (PrintDlg(&dialog_options)) |
285 return ParseDialogResult(dialog_options); | 283 return ParseDialogResult(dialog_options); |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 if (buf_size) { | 804 if (buf_size) { |
807 buffer->reset(new uint8[buf_size]); | 805 buffer->reset(new uint8[buf_size]); |
808 memset(buffer->get(), 0, buf_size); | 806 memset(buffer->get(), 0, buf_size); |
809 if (!GetPrinter(printer, level, buffer->get(), buf_size, &buf_size)) { | 807 if (!GetPrinter(printer, level, buffer->get(), buf_size, &buf_size)) { |
810 buffer->reset(); | 808 buffer->reset(); |
811 } | 809 } |
812 } | 810 } |
813 } | 811 } |
814 | 812 |
815 } // namespace printing | 813 } // namespace printing |
OLD | NEW |