From 92ab8ce04d850a59aa3d1b49ba2986845102baf3 Mon Sep 17 00:00:00 2001 From: vitalybuka Date: Tue, 26 Aug 2014 16:41:45 -0700 Subject: Use document from preview for System Dialog printing on Windows. System dialog shows only properties of selected printers, no system dialog with printers. Removed global Ctrl+Shift+P shortcut on windows. BUG=374321 Review URL: https://codereview.chromium.org/480303002 Cr-Commit-Position: refs/heads/master@{#292032} --- printing/backend/win_helper.cc | 32 ++++++++++++++++++++++++++++++++ printing/backend/win_helper.h | 8 ++++++++ 2 files changed, 40 insertions(+) (limited to 'printing/backend') diff --git a/printing/backend/win_helper.cc b/printing/backend/win_helper.cc index 6aba7c6..db8d735 100644 --- a/printing/backend/win_helper.cc +++ b/printing/backend/win_helper.cc @@ -488,4 +488,36 @@ scoped_ptr CreateDevMode(HANDLE printer, return out.Pass(); } +scoped_ptr PromptDevMode( + HANDLE printer, + const base::string16& printer_name, + DEVMODE* in, + HWND window, + bool* canceled) { + LONG buffer_size = + DocumentProperties(window, + printer, + const_cast(printer_name.c_str()), + NULL, + NULL, + 0); + if (buffer_size < static_cast(sizeof(DEVMODE))) + return scoped_ptr(); + scoped_ptr out( + reinterpret_cast(malloc(buffer_size))); + DWORD flags = (in ? (DM_IN_BUFFER) : 0) | DM_OUT_BUFFER | DM_IN_PROMPT; + LONG result = DocumentProperties(window, + printer, + const_cast(printer_name.c_str()), + out.get(), + in, + flags); + if (canceled) + *canceled = (result == IDCANCEL); + if (result != IDOK) + return scoped_ptr(); + CHECK_GE(buffer_size, out.get()->dmSize + out.get()->dmDriverExtra); + return out.Pass(); +} + } // namespace printing diff --git a/printing/backend/win_helper.h b/printing/backend/win_helper.h index 18d0355..c6665f4 100644 --- a/printing/backend/win_helper.h +++ b/printing/backend/win_helper.h @@ -186,6 +186,14 @@ PRINTING_EXPORT scoped_ptr CreateDevMode( HANDLE printer, DEVMODE* in); +// Prompts for new DEVMODE. If |in| is not NULL copy settings from there. +PRINTING_EXPORT scoped_ptr PromptDevMode( + HANDLE printer, + const base::string16& printer_name, + DEVMODE* in, + HWND window, + bool* canceled); + } // namespace printing #endif // PRINTING_BACKEND_WIN_HELPER_H_ -- cgit v1.1