Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: chrome/utility/printing_handler.h

Issue 2477283002: Convert printing IPCs to Mojo
Patch Set: Fix more Windows compile errors Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 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 #ifndef CHROME_UTILITY_PRINTING_HANDLER_H_ 5 #ifndef CHROME_UTILITY_PRINTING_HANDLER_H_
6 #define CHROME_UTILITY_PRINTING_HANDLER_H_ 6 #define CHROME_UTILITY_PRINTING_HANDLER_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
11 #include "chrome/utility/utility_message_handler.h" 11 #include "components/printing/common/printing.mojom.h"
12 #include "ipc/ipc_platform_file.h" 12 #include "ipc/ipc_platform_file.h"
13 #include "mojo/public/cpp/bindings/interface_request.h"
13 #include "printing/features/features.h" 14 #include "printing/features/features.h"
14 #include "printing/pdf_render_settings.h" 15 #include "printing/pdf_render_settings.h"
15 16
16 #if !BUILDFLAG(ENABLE_PRINT_PREVIEW) && \ 17 #if !BUILDFLAG(ENABLE_PRINT_PREVIEW) && \
17 !(BUILDFLAG(ENABLE_BASIC_PRINTING) && defined(OS_WIN)) 18 !(BUILDFLAG(ENABLE_BASIC_PRINTING) && defined(OS_WIN))
18 #error "Windows basic printing or print preview must be enabled" 19 #error "Windows basic printing or print preview must be enabled"
19 #endif 20 #endif
20 21
21 namespace printing { 22 namespace printing {
22 23
23 struct PwgRasterSettings; 24 struct PwgRasterSettings;
24 25
25 // Dispatches IPCs for printing. 26 // Dispatches IPCs for printing.
26 class PrintingHandler : public UtilityMessageHandler { 27 class PrintingHandler : public mojom::Printing {
27 public: 28 public:
28 PrintingHandler(); 29 explicit PrintingHandler(mojom::FontPreCachingPtr font_pre_caching);
29 ~PrintingHandler() override; 30 ~PrintingHandler() override;
30 31
31 // IPC::Listener: 32 static void Create(mojom::PrintingFactoryRequest request);
32 bool OnMessageReceived(const IPC::Message& message) override;
33 33
34 private: 34 private:
35 // IPC message handlers. 35 class PrintingHandlerFactory : public mojom::PrintingFactory {
36 #if defined(OS_WIN) 36 public:
37 void OnRenderPDFPagesToMetafile(IPC::PlatformFileForTransit pdf_transit, 37 // mojom::PrintingFactory:
38 const PdfRenderSettings& settings, 38 void MakePrinting(mojom::PrintingRequest request,
39 bool print_text_with_gdi); 39 mojom::FontPreCachingPtr font_pre_caching) override;
40 void OnRenderPDFPagesToMetafileGetPage( 40 };
41
42 // mojom::Printing:
43 void RenderPDFPagesToMetafiles(
44 base::File pdf_file,
45 const PdfRenderSettings& settings,
46 bool print_text_with_gdi,
47 const RenderPDFPagesToMetafilesCallback& callback) override;
48 void RenderPDFPagesToMetafilesGetPage(
41 int page_number, 49 int page_number,
42 IPC::PlatformFileForTransit output_file); 50 base::File emf_file,
43 void OnRenderPDFPagesToMetafileStop(); 51 const RenderPDFPagesToMetafilesGetPageCallback& callback) override;
44 #endif // OS_WIN 52 void RenderPDFPagesToPWGRaster(
45 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) 53 base::File pdf,
46 void OnRenderPDFPagesToPWGRaster(IPC::PlatformFileForTransit pdf_transit, 54 const PdfRenderSettings& settings,
47 const PdfRenderSettings& settings, 55 const PwgRasterSettings& bitmap_settings,
48 const PwgRasterSettings& bitmap_settings, 56 base::File bitmap,
49 IPC::PlatformFileForTransit bitmap_transit); 57 const RenderPDFPagesToPWGRasterCallback& callback) override;
50 #endif // ENABLE_PRINT_PREVIEW 58
59 // Called when the Mojo connection is closed. Causes the utility process to
60 // stop conversion and exit.
61 void OnConnectionClosed();
51 62
52 #if defined(OS_WIN) 63 #if defined(OS_WIN)
53 int LoadPDF(base::File pdf_file); 64 int LoadPDF(base::File pdf_file);
54 bool RenderPdfPageToMetafile(int page_number, 65 bool RenderPdfPageToMetafile(int page_number,
55 base::File output_file, 66 base::File output_file,
56 float* scale_factor); 67 float* scale_factor);
57 #endif // OS_WIN 68 #endif // OS_WIN
58 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) 69 #if BUILDFLAG(ENABLE_PRINT_PREVIEW)
59 bool RenderPDFPagesToPWGRaster(base::File pdf_file, 70 bool RenderPDFPagesToPWGRaster(base::File pdf_file,
60 const PdfRenderSettings& settings, 71 const PdfRenderSettings& settings,
61 const PwgRasterSettings& bitmap_settings, 72 const PwgRasterSettings& bitmap_settings,
62 base::File bitmap_file); 73 base::File bitmap_file);
74 #endif // ENABLE_PRINT_PREVIEW
63 75
64 void OnGetPrinterCapsAndDefaults(const std::string& printer_name); 76 // mojom::Printing:
65 void OnGetPrinterSemanticCapsAndDefaults(const std::string& printer_name); 77 void GetPrinterCapsAndDefaults(
66 #endif // ENABLE_PRINT_PREVIEW 78 const std::string& printer_name,
79 const GetPrinterCapsAndDefaultsCallback& callback) override;
80 void GetPrinterSemanticCapsAndDefaults(
81 const std::string& printer_name,
82 const GetPrinterSemanticCapsAndDefaultsCallback& callback) override;
67 83
68 #if defined(OS_WIN) 84 #if defined(OS_WIN)
69 std::vector<char> pdf_data_; 85 std::vector<char> pdf_data_;
70 PdfRenderSettings pdf_rendering_settings_; 86 PdfRenderSettings pdf_rendering_settings_;
71 #endif 87 #endif
72 88
89 mojom::FontPreCachingPtr font_pre_caching_;
90
73 DISALLOW_COPY_AND_ASSIGN(PrintingHandler); 91 DISALLOW_COPY_AND_ASSIGN(PrintingHandler);
74 }; 92 };
75 93
76 } // namespace printing 94 } // namespace printing
77 95
78 #endif // CHROME_UTILITY_PRINTING_HANDLER_H_ 96 #endif // CHROME_UTILITY_PRINTING_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698