OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/backend/win_helper.h" | 5 #include "printing/backend/win_helper.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/file_version_info.h" | 9 #include "base/file_version_info.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 DWORD flags = (in ? (DM_IN_BUFFER) : 0) | DM_OUT_BUFFER; | 481 DWORD flags = (in ? (DM_IN_BUFFER) : 0) | DM_OUT_BUFFER; |
482 if (DocumentProperties( | 482 if (DocumentProperties( |
483 NULL, printer, const_cast<wchar_t*>(L""), out.get(), in, flags) != | 483 NULL, printer, const_cast<wchar_t*>(L""), out.get(), in, flags) != |
484 IDOK) { | 484 IDOK) { |
485 return scoped_ptr<DEVMODE, base::FreeDeleter>(); | 485 return scoped_ptr<DEVMODE, base::FreeDeleter>(); |
486 } | 486 } |
487 CHECK_GE(buffer_size, out.get()->dmSize + out.get()->dmDriverExtra); | 487 CHECK_GE(buffer_size, out.get()->dmSize + out.get()->dmDriverExtra); |
488 return out.Pass(); | 488 return out.Pass(); |
489 } | 489 } |
490 | 490 |
| 491 scoped_ptr<DEVMODE, base::FreeDeleter> PromptDevMode( |
| 492 HANDLE printer, |
| 493 const base::string16& printer_name, |
| 494 DEVMODE* in, |
| 495 HWND window, |
| 496 bool* canceled) { |
| 497 LONG buffer_size = |
| 498 DocumentProperties(window, |
| 499 printer, |
| 500 const_cast<wchar_t*>(printer_name.c_str()), |
| 501 NULL, |
| 502 NULL, |
| 503 0); |
| 504 if (buffer_size < static_cast<int>(sizeof(DEVMODE))) |
| 505 return scoped_ptr<DEVMODE, base::FreeDeleter>(); |
| 506 scoped_ptr<DEVMODE, base::FreeDeleter> out( |
| 507 reinterpret_cast<DEVMODE*>(malloc(buffer_size))); |
| 508 DWORD flags = (in ? (DM_IN_BUFFER) : 0) | DM_OUT_BUFFER | DM_IN_PROMPT; |
| 509 LONG result = DocumentProperties(window, |
| 510 printer, |
| 511 const_cast<wchar_t*>(printer_name.c_str()), |
| 512 out.get(), |
| 513 in, |
| 514 flags); |
| 515 if (canceled) |
| 516 *canceled = (result == IDCANCEL); |
| 517 if (result != IDOK) |
| 518 return scoped_ptr<DEVMODE, base::FreeDeleter>(); |
| 519 CHECK_GE(buffer_size, out.get()->dmSize + out.get()->dmDriverExtra); |
| 520 return out.Pass(); |
| 521 } |
| 522 |
491 } // namespace printing | 523 } // namespace printing |
OLD | NEW |