Adding a router class to handle messages that expect responses.
[chromium-blink-merge.git] / chrome / utility / printing_handler.h
blob805c1e30d728b149505ea0a7d4f52b3296958232
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"
13 #if !defined(ENABLE_FULL_PRINTING)
14 #error "Full printing must be enabled"
15 #endif
17 namespace printing {
18 class PdfRenderSettings;
19 struct PwgRasterSettings;
20 struct PageRange;
23 // Dispatches IPCs for printing.
24 class PrintingHandler : public UtilityMessageHandler {
25 public:
26 PrintingHandler();
27 virtual ~PrintingHandler();
29 static void PreSandboxStartup();
31 // IPC::Listener:
32 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
34 private:
35 // IPC message handlers.
36 #if defined(WIN_PDF_METAFILE_FOR_PRINTING)
37 void OnRenderPDFPagesToMetafile(
38 IPC::PlatformFileForTransit pdf_transit,
39 const base::FilePath& metafile_path,
40 const printing::PdfRenderSettings& settings,
41 const std::vector<printing::PageRange>& page_ranges);
42 #endif
43 void OnRenderPDFPagesToPWGRaster(
44 IPC::PlatformFileForTransit pdf_transit,
45 const printing::PdfRenderSettings& settings,
46 const printing::PwgRasterSettings& bitmap_settings,
47 IPC::PlatformFileForTransit bitmap_transit);
49 #if defined(WIN_PDF_METAFILE_FOR_PRINTING)
50 // Helper method for Windows.
51 // |highest_rendered_page_number| is set to -1 on failure to render any page.
52 // |page_ranges| is both input and output. If supplied as input, only the
53 // specified pages will be rendered. If an empty vector is supplied it will
54 // be filled with a range of all pages that were rendered.
55 bool RenderPDFToWinMetafile(
56 base::File pdf_file,
57 const base::FilePath& metafile_path,
58 const printing::PdfRenderSettings& settings,
59 std::vector<printing::PageRange>* page_ranges,
60 int* highest_rendered_page_number,
61 double* scale_factor);
62 #endif
64 bool RenderPDFPagesToPWGRaster(
65 base::File pdf_file,
66 const printing::PdfRenderSettings& settings,
67 const printing::PwgRasterSettings& bitmap_settings,
68 base::File bitmap_file);
70 void OnGetPrinterCapsAndDefaults(const std::string& printer_name);
71 void OnGetPrinterSemanticCapsAndDefaults(const std::string& printer_name);
73 DISALLOW_COPY_AND_ASSIGN(PrintingHandler);
76 #endif // CHROME_UTILITY_PRINTING_HANDLER_H_