Home | History | Annotate | Download | only in common
      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.
      4 
      5 // Multiply-included message file, so no include guard.
      6 
      7 #include <string>
      8 #include <vector>
      9 
     10 #include "ipc/ipc_message_macros.h"
     11 #include "ipc/ipc_platform_file.h"
     12 #include "printing/backend/print_backend.h"
     13 #include "printing/page_range.h"
     14 #include "printing/pdf_render_settings.h"
     15 #include "printing/pwg_raster_settings.h"
     16 
     17 #if !defined(ENABLE_FULL_PRINTING)
     18 #error "Full printing must be enabled"
     19 #endif
     20 
     21 #define IPC_MESSAGE_START UtilityPrintingMsgStart
     22 
     23 IPC_STRUCT_TRAITS_BEGIN(printing::PageRange)
     24   IPC_STRUCT_TRAITS_MEMBER(from)
     25   IPC_STRUCT_TRAITS_MEMBER(to)
     26 IPC_STRUCT_TRAITS_END()
     27 
     28 IPC_STRUCT_TRAITS_BEGIN(printing::PrinterCapsAndDefaults)
     29   IPC_STRUCT_TRAITS_MEMBER(printer_capabilities)
     30   IPC_STRUCT_TRAITS_MEMBER(caps_mime_type)
     31   IPC_STRUCT_TRAITS_MEMBER(printer_defaults)
     32   IPC_STRUCT_TRAITS_MEMBER(defaults_mime_type)
     33 IPC_STRUCT_TRAITS_END()
     34 
     35 IPC_ENUM_TRAITS_MAX_VALUE(printing::ColorModel, printing::PROCESSCOLORMODEL_RGB)
     36 IPC_ENUM_TRAITS_MIN_MAX_VALUE(printing::DuplexMode,
     37                               printing::UNKNOWN_DUPLEX_MODE,
     38                               printing::SHORT_EDGE)
     39 
     40 IPC_STRUCT_TRAITS_BEGIN(printing::PrinterSemanticCapsAndDefaults::Paper)
     41   IPC_STRUCT_TRAITS_MEMBER(display_name)
     42   IPC_STRUCT_TRAITS_MEMBER(vendor_id)
     43   IPC_STRUCT_TRAITS_MEMBER(size_um)
     44 IPC_STRUCT_TRAITS_END()
     45 
     46 IPC_STRUCT_TRAITS_BEGIN(printing::PrinterSemanticCapsAndDefaults)
     47   IPC_STRUCT_TRAITS_MEMBER(collate_capable)
     48   IPC_STRUCT_TRAITS_MEMBER(collate_default)
     49   IPC_STRUCT_TRAITS_MEMBER(copies_capable)
     50   IPC_STRUCT_TRAITS_MEMBER(duplex_capable)
     51   IPC_STRUCT_TRAITS_MEMBER(duplex_default)
     52   IPC_STRUCT_TRAITS_MEMBER(color_changeable)
     53   IPC_STRUCT_TRAITS_MEMBER(color_default)
     54   IPC_STRUCT_TRAITS_MEMBER(color_model)
     55   IPC_STRUCT_TRAITS_MEMBER(bw_model)
     56   IPC_STRUCT_TRAITS_MEMBER(papers)
     57   IPC_STRUCT_TRAITS_MEMBER(default_paper)
     58   IPC_STRUCT_TRAITS_MEMBER(dpis)
     59   IPC_STRUCT_TRAITS_MEMBER(default_dpi)
     60 IPC_STRUCT_TRAITS_END()
     61 
     62 IPC_ENUM_TRAITS(printing::PwgRasterTransformType);
     63 
     64 IPC_STRUCT_TRAITS_BEGIN(printing::PwgRasterSettings)
     65   IPC_STRUCT_TRAITS_MEMBER(odd_page_transform)
     66   IPC_STRUCT_TRAITS_MEMBER(rotate_all_pages)
     67   IPC_STRUCT_TRAITS_MEMBER(reverse_page_order)
     68 IPC_STRUCT_TRAITS_END()
     69 
     70 //------------------------------------------------------------------------------
     71 // Utility process messages:
     72 // These are messages from the browser to the utility process.
     73 
     74 // Tell the utility process to render the given PDF into a PWGRaster.
     75 IPC_MESSAGE_CONTROL4(ChromeUtilityMsg_RenderPDFPagesToPWGRaster,
     76                      IPC::PlatformFileForTransit, /* Input PDF file */
     77                      printing::PdfRenderSettings, /* PDF render settings */
     78                      // PWG transform settings.
     79                      printing::PwgRasterSettings,
     80                      IPC::PlatformFileForTransit /* Output PWG file */)
     81 
     82 // Tells the utility process to get capabilities and defaults for the specified
     83 // printer. Used on Windows to isolate the service process from printer driver
     84 // crashes by executing this in a separate process. This does not run in a
     85 // sandbox.
     86 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_GetPrinterCapsAndDefaults,
     87                      std::string /* printer name */)
     88 
     89 // Tells the utility process to get capabilities and defaults for the specified
     90 // printer. Used on Windows to isolate the service process from printer driver
     91 // crashes by executing this in a separate process. This does not run in a
     92 // sandbox. Returns result as printing::PrinterSemanticCapsAndDefaults.
     93 IPC_MESSAGE_CONTROL1(ChromeUtilityMsg_GetPrinterSemanticCapsAndDefaults,
     94                      std::string /* printer name */)
     95 
     96 
     97 #if defined(WIN_PDF_METAFILE_FOR_PRINTING)
     98 // Tell the utility process to render the given PDF into a metafile.
     99 // The metafile path will have ".%d" inserted where the %d is the page number.
    100 // If no page range is specified, all pages will be converted.
    101 IPC_MESSAGE_CONTROL4(ChromeUtilityMsg_RenderPDFPagesToMetafiles,
    102                      IPC::PlatformFileForTransit,  // PDF file
    103                      base::FilePath,  // Base location for output metafile
    104                      printing::PdfRenderSettings,  // PDF render settings
    105                      std::vector<printing::PageRange>)
    106 #endif
    107 
    108 //------------------------------------------------------------------------------
    109 // Utility process host messages:
    110 // These are messages from the utility process to the browser.
    111 
    112 // Reply when the utility process has succeeded in rendering the PDF to PWG.
    113 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_RenderPDFPagesToPWGRaster_Succeeded)
    114 
    115 // Reply when an error occurred rendering the PDF to PWG.
    116 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_RenderPDFPagesToPWGRaster_Failed)
    117 
    118 // Reply when the utility process has succeeded in obtaining the printer
    119 // capabilities and defaults.
    120 IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Succeeded,
    121                      std::string /* printer name */,
    122                      printing::PrinterCapsAndDefaults)
    123 
    124 // Reply when the utility process has succeeded in obtaining the printer
    125 // semantic capabilities and defaults.
    126 IPC_MESSAGE_CONTROL2(
    127     ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Succeeded,
    128     std::string /* printer name */,
    129     printing::PrinterSemanticCapsAndDefaults)
    130 
    131 // Reply when the utility process has failed to obtain the printer
    132 // capabilities and defaults.
    133 IPC_MESSAGE_CONTROL1(ChromeUtilityHostMsg_GetPrinterCapsAndDefaults_Failed,
    134                      std::string /* printer name */)
    135 
    136 // Reply when the utility process has failed to obtain the printer
    137 // semantic capabilities and defaults.
    138 IPC_MESSAGE_CONTROL1(
    139   ChromeUtilityHostMsg_GetPrinterSemanticCapsAndDefaults_Failed,
    140   std::string /* printer name */)
    141 
    142 #if defined(WIN_PDF_METAFILE_FOR_PRINTING)
    143 // Reply when the utility process has succeeded in rendering the PDF.
    144 IPC_MESSAGE_CONTROL2(ChromeUtilityHostMsg_RenderPDFPagesToMetafiles_Succeeded,
    145                      std::vector<printing::PageRange>,  // Pages rendered
    146                      double)                            // Scale factor
    147 
    148 // Reply when an error occurred rendering the PDF.
    149 IPC_MESSAGE_CONTROL0(ChromeUtilityHostMsg_RenderPDFPagesToMetafile_Failed)
    150 #endif
    151