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

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

Issue 2477283002: Convert printing IPCs to Mojo
Patch Set: git cl format Created 4 years 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 "chrome/utility/utility_message_handler.h"
12 #include "components/printing/common/printing.mojom.h"
12 #include "ipc/ipc_platform_file.h" 13 #include "ipc/ipc_platform_file.h"
14 #include "mojo/public/cpp/bindings/interface_request.h"
13 #include "printing/features/features.h" 15 #include "printing/features/features.h"
14 #include "printing/pdf_render_settings.h" 16 #include "printing/pdf_render_settings.h"
15 17
16 #if !BUILDFLAG(ENABLE_PRINT_PREVIEW) && \ 18 #if !BUILDFLAG(ENABLE_PRINT_PREVIEW) && \
17 !(BUILDFLAG(ENABLE_BASIC_PRINTING) && defined(OS_WIN)) 19 !(BUILDFLAG(ENABLE_BASIC_PRINTING) && defined(OS_WIN))
18 #error "Windows basic printing or print preview must be enabled" 20 #error "Windows basic printing or print preview must be enabled"
19 #endif 21 #endif
20 22
21 namespace printing { 23 namespace printing {
22 24
23 struct PwgRasterSettings; 25 struct PwgRasterSettings;
24 26
25 // Dispatches IPCs for printing. 27 // Dispatches IPCs for printing.
26 class PrintingHandler : public UtilityMessageHandler { 28 class PrintingHandler : public UtilityMessageHandler, public mojom::Printing {
27 public: 29 public:
28 PrintingHandler(); 30 explicit PrintingHandler(mojom::FontPreCachingPtr font_pre_caching);
29 ~PrintingHandler() override; 31 ~PrintingHandler() override;
30 32
33 static void Create(mojom::PrintingFactoryRequest request);
34
31 // IPC::Listener: 35 // IPC::Listener:
32 bool OnMessageReceived(const IPC::Message& message) override; 36 bool OnMessageReceived(const IPC::Message& message) override;
33 37
34 private: 38 private:
35 // IPC message handlers. 39 // mojom::Printing:
36 #if defined(OS_WIN) 40 void RenderPDFPagesToMetafiles(
37 void OnRenderPDFPagesToMetafile(IPC::PlatformFileForTransit pdf_transit, 41 mojo::ScopedHandle pdf_transit,
38 const PdfRenderSettings& settings, 42 const PdfRenderSettings& settings,
39 bool print_text_with_gdi); 43 bool print_text_with_gdi,
40 void OnRenderPDFPagesToMetafileGetPage( 44 const RenderPDFPagesToMetafilesCallback& callback) override;
45 void RenderPDFPagesToMetafilesGetPage(
41 int page_number, 46 int page_number,
42 IPC::PlatformFileForTransit output_file); 47 mojo::ScopedHandle output_file,
43 void OnRenderPDFPagesToMetafileStop(); 48 const RenderPDFPagesToMetafilesGetPageCallback& callback) override;
44 #endif // OS_WIN 49 void RenderPDFPagesToMetafilesStop() override;
45 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) 50 void RenderPDFPagesToPWGRaster(
46 void OnRenderPDFPagesToPWGRaster(IPC::PlatformFileForTransit pdf_transit, 51 mojo::ScopedHandle pdf_transit,
47 const PdfRenderSettings& settings, 52 const PdfRenderSettings& settings,
48 const PwgRasterSettings& bitmap_settings, 53 const PwgRasterSettings& bitmap_settings,
49 IPC::PlatformFileForTransit bitmap_transit); 54 mojo::ScopedHandle bitmap_transit,
50 #endif // ENABLE_PRINT_PREVIEW 55 const RenderPDFPagesToPWGRasterCallback& callback) override;
51 56
52 #if defined(OS_WIN) 57 #if defined(OS_WIN)
53 int LoadPDF(base::File pdf_file); 58 int LoadPDF(base::File pdf_file);
54 bool RenderPdfPageToMetafile(int page_number, 59 bool RenderPdfPageToMetafile(int page_number,
55 base::File output_file, 60 base::File output_file,
56 float* scale_factor); 61 float* scale_factor);
57 #endif // OS_WIN 62 #endif // OS_WIN
58 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) 63 #if BUILDFLAG(ENABLE_PRINT_PREVIEW)
59 bool RenderPDFPagesToPWGRaster(base::File pdf_file, 64 bool RenderPDFPagesToPWGRaster(base::File pdf_file,
60 const PdfRenderSettings& settings, 65 const PdfRenderSettings& settings,
61 const PwgRasterSettings& bitmap_settings, 66 const PwgRasterSettings& bitmap_settings,
62 base::File bitmap_file); 67 base::File bitmap_file);
68 #endif // ENABLE_PRINT_PREVIEW
63 69
64 void OnGetPrinterCapsAndDefaults(const std::string& printer_name); 70 // mojom::Printing:
65 void OnGetPrinterSemanticCapsAndDefaults(const std::string& printer_name); 71 void GetPrinterCapsAndDefaults(
66 #endif // ENABLE_PRINT_PREVIEW 72 const std::string& printer_name,
73 const GetPrinterCapsAndDefaultsCallback& callback) override;
74 void GetPrinterSemanticCapsAndDefaults(
75 const std::string& printer_name,
76 const GetPrinterSemanticCapsAndDefaultsCallback& callback) override;
67 77
68 #if defined(OS_WIN) 78 #if defined(OS_WIN)
69 std::vector<char> pdf_data_; 79 std::vector<char> pdf_data_;
70 PdfRenderSettings pdf_rendering_settings_; 80 PdfRenderSettings pdf_rendering_settings_;
71 #endif 81 #endif
72 82
83 mojom::FontPreCachingPtr font_pre_caching_;
84
73 DISALLOW_COPY_AND_ASSIGN(PrintingHandler); 85 DISALLOW_COPY_AND_ASSIGN(PrintingHandler);
74 }; 86 };
75 87
76 } // namespace printing 88 } // namespace printing
77 89
78 #endif // CHROME_UTILITY_PRINTING_HANDLER_H_ 90 #endif // CHROME_UTILITY_PRINTING_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698