diff options
author | sanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-17 17:48:24 +0000 |
---|---|---|
committer | sanjeevr@chromium.org <sanjeevr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-17 17:48:24 +0000 |
commit | 58310639ddc719c51bcd152966a01723ca16e4c5 (patch) | |
tree | 9960980d149c59317d177fb0f5032ab363025b4a /printing/backend | |
parent | 685dffb92f13c973310f36800384701122812e7b (diff) | |
download | chromium_src-58310639ddc719c51bcd152966a01723ca16e4c5.zip chromium_src-58310639ddc719c51bcd152966a01723ca16e4c5.tar.gz chromium_src-58310639ddc719c51bcd152966a01723ca16e4c5.tar.bz2 |
Added support to the Windows cloud print proxy to print XPS documents directly without any conversion (only works on Windows 7). The proxy uses the Accept: header to specify what data types it can accept.
BUG=None.
TEST=When the cloud print service supports this, submitting an XPS document should go through to the Win 7 proxy without any conversions.
Review URL: http://codereview.chromium.org/6523040
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@75286 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'printing/backend')
-rw-r--r-- | printing/backend/win_helper.cc | 53 | ||||
-rw-r--r-- | printing/backend/win_helper.h | 25 |
2 files changed, 78 insertions, 0 deletions
diff --git a/printing/backend/win_helper.cc b/printing/backend/win_helper.cc index e63b45f..b163a65 100644 --- a/printing/backend/win_helper.cc +++ b/printing/backend/win_helper.cc @@ -37,6 +37,17 @@ typedef HRESULT (WINAPI *PTMergeAndValidatePrintTicketProc)( BSTR* error_message); typedef HRESULT (WINAPI *PTReleaseMemoryProc)(PVOID buffer); typedef HRESULT (WINAPI *PTCloseProviderProc)(HPTPROVIDER provider); +typedef HRESULT (WINAPI *StartXpsPrintJobProc)( + const LPCWSTR printer_name, + const LPCWSTR job_name, + const LPCWSTR output_file_name, + HANDLE progress_event, + HANDLE completion_event, + UINT8 *printable_pages_on, + UINT32 printable_pages_on_count, + IXpsPrintJob **xps_print_job, + IXpsPrintJobStream **document_stream, + IXpsPrintJobStream **print_ticket_stream); PTOpenProviderProc g_open_provider_proc = NULL; PTGetPrintCapabilitiesProc g_get_print_capabilities_proc = NULL; @@ -45,6 +56,7 @@ PTConvertPrintTicketToDevModeProc g_convert_print_ticket_to_devmode_proc = NULL; PTMergeAndValidatePrintTicketProc g_merge_and_validate_print_ticket_proc = NULL; PTReleaseMemoryProc g_release_memory_proc = NULL; PTCloseProviderProc g_close_provider_proc = NULL; +StartXpsPrintJobProc g_start_xps_print_job_proc = NULL; } namespace printing { @@ -207,4 +219,45 @@ ScopedXPSInitializer::~ScopedXPSInitializer() { initialized_ = false; } +bool XPSPrintModule::Init() { + static bool initialized = InitImpl(); + return initialized; +} + +bool XPSPrintModule::InitImpl() { + HMODULE xpsprint_module = LoadLibrary(L"xpsprint.dll"); + if (xpsprint_module == NULL) + return false; + g_start_xps_print_job_proc = reinterpret_cast<StartXpsPrintJobProc>( + GetProcAddress(xpsprint_module, "StartXpsPrintJob")); + if (!g_start_xps_print_job_proc) { + NOTREACHED(); + return false; + } + return true; +} + +HRESULT XPSPrintModule::StartXpsPrintJob( + const LPCWSTR printer_name, + const LPCWSTR job_name, + const LPCWSTR output_file_name, + HANDLE progress_event, + HANDLE completion_event, + UINT8 *printable_pages_on, + UINT32 printable_pages_on_count, + IXpsPrintJob **xps_print_job, + IXpsPrintJobStream **document_stream, + IXpsPrintJobStream **print_ticket_stream) { + return g_start_xps_print_job_proc(printer_name, + job_name, + output_file_name, + progress_event, + completion_event, + printable_pages_on, + printable_pages_on_count, + xps_print_job, + document_stream, + print_ticket_stream); +} + } // namespace printing diff --git a/printing/backend/win_helper.h b/printing/backend/win_helper.h index 891f833..28e57f7 100644 --- a/printing/backend/win_helper.h +++ b/printing/backend/win_helper.h @@ -9,6 +9,7 @@ #include <objidl.h> #include <winspool.h> #include <prntvpt.h> +#include <xpsprint.h> #include "base/string16.h" @@ -70,6 +71,30 @@ class ScopedXPSInitializer { bool initialized_; }; +// Wrapper class to wrap the XPS Print APIs (these are different from the PTxxx +// which deal with the XML Print Schema). This is needed because these +// APIs are only available on Windows 7 and higher. +class XPSPrintModule { + public: + // All the other methods can ONLY be called after a successful call to Init. + // Init can be called many times and by multiple threads. + static bool Init(); + static HRESULT StartXpsPrintJob( + const LPCWSTR printer_name, + const LPCWSTR job_name, + const LPCWSTR output_file_name, + HANDLE progress_event, + HANDLE completion_event, + UINT8 *printable_pages_on, + UINT32 printable_pages_on_count, + IXpsPrintJob **xps_print_job, + IXpsPrintJobStream **document_stream, + IXpsPrintJobStream **print_ticket_stream); + private: + XPSPrintModule() { } + static bool InitImpl(); +}; + } // namespace printing #endif // PRINTING_BACKEND_WIN_HELPER_H_ |