1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_UTILITY_PRINTING_HANDLER_H_
6 #define CHROME_UTILITY_PRINTING_HANDLER_H_
8 #include "base/compiler_specific.h"
9 #include "base/macros.h"
10 #include "chrome/utility/utility_message_handler.h"
11 #include "ipc/ipc_platform_file.h"
12 #include "printing/pdf_render_settings.h"
14 #if !defined(ENABLE_PRINT_PREVIEW) && !defined(OS_WIN)
15 #error "Windows or full printing must be enabled"
19 class PdfRenderSettings
;
20 struct PwgRasterSettings
;
24 // Dispatches IPCs for printing.
25 class PrintingHandler
: public UtilityMessageHandler
{
28 ~PrintingHandler() override
;
30 static void PreSandboxStartup();
33 bool OnMessageReceived(const IPC::Message
& message
) override
;
36 // IPC message handlers.
38 void OnRenderPDFPagesToMetafile(IPC::PlatformFileForTransit pdf_transit
,
39 const printing::PdfRenderSettings
& settings
);
40 void OnRenderPDFPagesToMetafileGetPage(
42 IPC::PlatformFileForTransit output_file
);
43 void OnRenderPDFPagesToMetafileStop();
45 #if defined(ENABLE_PRINT_PREVIEW)
46 void OnRenderPDFPagesToPWGRaster(
47 IPC::PlatformFileForTransit pdf_transit
,
48 const printing::PdfRenderSettings
& settings
,
49 const printing::PwgRasterSettings
& bitmap_settings
,
50 IPC::PlatformFileForTransit bitmap_transit
);
51 #endif // ENABLE_PRINT_PREVIEW
54 int LoadPDF(base::File pdf_file
);
55 bool RenderPdfPageToMetafile(int page_number
,
56 base::File output_file
,
59 #if defined(ENABLE_PRINT_PREVIEW)
60 bool RenderPDFPagesToPWGRaster(
62 const printing::PdfRenderSettings
& settings
,
63 const printing::PwgRasterSettings
& bitmap_settings
,
64 base::File bitmap_file
);
66 void OnGetPrinterCapsAndDefaults(const std::string
& printer_name
);
67 void OnGetPrinterSemanticCapsAndDefaults(const std::string
& printer_name
);
68 #endif // ENABLE_PRINT_PREVIEW
71 std::vector
<char> pdf_data_
;
72 printing::PdfRenderSettings pdf_rendering_settings_
;
75 DISALLOW_COPY_AND_ASSIGN(PrintingHandler
);
78 #endif // CHROME_UTILITY_PRINTING_HANDLER_H_