Transfer Password sync to use new sync API.
[chromium-blink-merge.git] / chrome / common / print_messages.h
blob29f7af2fcad43ae70f1ead8d8754d9bd5635d643
1 // Copyright (c) 2012 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 // IPC messages for printing.
6 // Multiply-included message file, hence no include guard.
8 #include <string>
9 #include <vector>
11 #include "base/memory/shared_memory.h"
12 #include "base/values.h"
13 #include "ipc/ipc_message_macros.h"
14 #include "printing/page_size_margins.h"
15 #include "printing/print_job_constants.h"
16 #include "third_party/WebKit/public/web/WebPrintScalingOption.h"
17 #include "ui/gfx/native_widget_types.h"
18 #include "ui/gfx/rect.h"
20 #ifndef CHROME_COMMON_PRINT_MESSAGES_H_
21 #define CHROME_COMMON_PRINT_MESSAGES_H_
23 struct PrintMsg_Print_Params {
24 PrintMsg_Print_Params();
25 ~PrintMsg_Print_Params();
27 // Resets the members of the struct to 0.
28 void Reset();
30 gfx::Size page_size;
31 gfx::Size content_size;
32 gfx::Rect printable_area;
33 int margin_top;
34 int margin_left;
35 double dpi;
36 double min_shrink;
37 double max_shrink;
38 int desired_dpi;
39 int document_cookie;
40 bool selection_only;
41 bool supports_alpha_blend;
42 int32 preview_ui_id;
43 int preview_request_id;
44 bool is_first_request;
45 blink::WebPrintScalingOption print_scaling_option;
46 bool print_to_pdf;
47 bool display_header_footer;
48 base::string16 title;
49 base::string16 url;
50 bool should_print_backgrounds;
53 struct PrintMsg_PrintPages_Params {
54 PrintMsg_PrintPages_Params();
55 ~PrintMsg_PrintPages_Params();
57 // Resets the members of the struct to 0.
58 void Reset();
60 PrintMsg_Print_Params params;
61 std::vector<int> pages;
64 struct PrintHostMsg_RequestPrintPreview_Params {
65 PrintHostMsg_RequestPrintPreview_Params();
66 ~PrintHostMsg_RequestPrintPreview_Params();
67 bool is_modifiable;
68 bool webnode_only;
69 bool has_selection;
70 bool selection_only;
73 #endif // CHROME_COMMON_PRINT_MESSAGES_H_
75 #define IPC_MESSAGE_START PrintMsgStart
77 IPC_ENUM_TRAITS_MAX_VALUE(printing::MarginType,
78 printing::MARGIN_TYPE_LAST)
79 IPC_ENUM_TRAITS_MAX_VALUE(blink::WebPrintScalingOption,
80 blink::WebPrintScalingOptionLast)
82 // Parameters for a render request.
83 IPC_STRUCT_TRAITS_BEGIN(PrintMsg_Print_Params)
84 // Physical size of the page, including non-printable margins,
85 // in pixels according to dpi.
86 IPC_STRUCT_TRAITS_MEMBER(page_size)
88 // In pixels according to dpi_x and dpi_y.
89 IPC_STRUCT_TRAITS_MEMBER(content_size)
91 // Physical printable area of the page in pixels according to dpi.
92 IPC_STRUCT_TRAITS_MEMBER(printable_area)
94 // The y-offset of the printable area, in pixels according to dpi.
95 IPC_STRUCT_TRAITS_MEMBER(margin_top)
97 // The x-offset of the printable area, in pixels according to dpi.
98 IPC_STRUCT_TRAITS_MEMBER(margin_left)
100 // Specifies dots per inch.
101 IPC_STRUCT_TRAITS_MEMBER(dpi)
103 // Minimum shrink factor. See PrintSettings::min_shrink for more information.
104 IPC_STRUCT_TRAITS_MEMBER(min_shrink)
106 // Maximum shrink factor. See PrintSettings::max_shrink for more information.
107 IPC_STRUCT_TRAITS_MEMBER(max_shrink)
109 // Desired apparent dpi on paper.
110 IPC_STRUCT_TRAITS_MEMBER(desired_dpi)
112 // Cookie for the document to ensure correctness.
113 IPC_STRUCT_TRAITS_MEMBER(document_cookie)
115 // Should only print currently selected text.
116 IPC_STRUCT_TRAITS_MEMBER(selection_only)
118 // Does the printer support alpha blending?
119 IPC_STRUCT_TRAITS_MEMBER(supports_alpha_blend)
121 // *** Parameters below are used only for print preview. ***
123 // The print preview ui associated with this request.
124 IPC_STRUCT_TRAITS_MEMBER(preview_ui_id)
126 // The id of the preview request.
127 IPC_STRUCT_TRAITS_MEMBER(preview_request_id)
129 // True if this is the first preview request.
130 IPC_STRUCT_TRAITS_MEMBER(is_first_request)
132 // Specifies the page scaling option for preview printing.
133 IPC_STRUCT_TRAITS_MEMBER(print_scaling_option)
135 // True if print to pdf is requested.
136 IPC_STRUCT_TRAITS_MEMBER(print_to_pdf)
138 // Specifies if the header and footer should be rendered.
139 IPC_STRUCT_TRAITS_MEMBER(display_header_footer)
141 // Title string to be printed as header if requested by the user.
142 IPC_STRUCT_TRAITS_MEMBER(title)
144 // URL string to be printed as footer if requested by the user.
145 IPC_STRUCT_TRAITS_MEMBER(url)
147 // True if print backgrounds is requested by the user.
148 IPC_STRUCT_TRAITS_MEMBER(should_print_backgrounds)
149 IPC_STRUCT_TRAITS_END()
151 IPC_STRUCT_BEGIN(PrintMsg_PrintPage_Params)
152 // Parameters to render the page as a printed page. It must always be the same
153 // value for all the document.
154 IPC_STRUCT_MEMBER(PrintMsg_Print_Params, params)
156 // The page number is the indicator of the square that should be rendered
157 // according to the layout specified in PrintMsg_Print_Params.
158 IPC_STRUCT_MEMBER(int, page_number)
159 IPC_STRUCT_END()
161 IPC_STRUCT_TRAITS_BEGIN(PrintHostMsg_RequestPrintPreview_Params)
162 IPC_STRUCT_TRAITS_MEMBER(is_modifiable)
163 IPC_STRUCT_TRAITS_MEMBER(webnode_only)
164 IPC_STRUCT_TRAITS_MEMBER(has_selection)
165 IPC_STRUCT_TRAITS_MEMBER(selection_only)
166 IPC_STRUCT_TRAITS_END()
168 IPC_STRUCT_TRAITS_BEGIN(printing::PageSizeMargins)
169 IPC_STRUCT_TRAITS_MEMBER(content_width)
170 IPC_STRUCT_TRAITS_MEMBER(content_height)
171 IPC_STRUCT_TRAITS_MEMBER(margin_left)
172 IPC_STRUCT_TRAITS_MEMBER(margin_right)
173 IPC_STRUCT_TRAITS_MEMBER(margin_top)
174 IPC_STRUCT_TRAITS_MEMBER(margin_bottom)
175 IPC_STRUCT_TRAITS_END()
177 IPC_STRUCT_TRAITS_BEGIN(PrintMsg_PrintPages_Params)
178 // Parameters to render the page as a printed page. It must always be the same
179 // value for all the document.
180 IPC_STRUCT_TRAITS_MEMBER(params)
182 // If empty, this means a request to render all the printed pages.
183 IPC_STRUCT_TRAITS_MEMBER(pages)
184 IPC_STRUCT_TRAITS_END()
186 // Parameters to describe a rendered document.
187 IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewDocument_Params)
188 // A shared memory handle to metafile data.
189 IPC_STRUCT_MEMBER(base::SharedMemoryHandle, metafile_data_handle)
191 // Size of metafile data.
192 IPC_STRUCT_MEMBER(uint32, data_size)
194 // Cookie for the document to ensure correctness.
195 IPC_STRUCT_MEMBER(int, document_cookie)
197 // Store the expected pages count.
198 IPC_STRUCT_MEMBER(int, expected_pages_count)
200 // Whether the preview can be modified.
201 IPC_STRUCT_MEMBER(bool, modifiable)
203 // The id of the preview request.
204 IPC_STRUCT_MEMBER(int, preview_request_id)
205 IPC_STRUCT_END()
207 // Parameters to describe a rendered preview page.
208 IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewPage_Params)
209 // A shared memory handle to metafile data for a draft document of the page.
210 IPC_STRUCT_MEMBER(base::SharedMemoryHandle, metafile_data_handle)
212 // Size of metafile data.
213 IPC_STRUCT_MEMBER(uint32, data_size)
215 // |page_number| is zero-based and can be |printing::INVALID_PAGE_INDEX| if it
216 // is just a check.
217 IPC_STRUCT_MEMBER(int, page_number)
219 // The id of the preview request.
220 IPC_STRUCT_MEMBER(int, preview_request_id)
221 IPC_STRUCT_END()
223 // Parameters sent along with the page count.
224 IPC_STRUCT_BEGIN(PrintHostMsg_DidGetPreviewPageCount_Params)
225 // Cookie for the document to ensure correctness.
226 IPC_STRUCT_MEMBER(int, document_cookie)
228 // Total page count.
229 IPC_STRUCT_MEMBER(int, page_count)
231 // Indicates whether the previewed document is modifiable.
232 IPC_STRUCT_MEMBER(bool, is_modifiable)
234 // The id of the preview request.
235 IPC_STRUCT_MEMBER(int, preview_request_id)
237 // Indicates whether the existing preview data needs to be cleared or not.
238 IPC_STRUCT_MEMBER(bool, clear_preview_data)
239 IPC_STRUCT_END()
241 // Parameters to describe a rendered page.
242 IPC_STRUCT_BEGIN(PrintHostMsg_DidPrintPage_Params)
243 // A shared memory handle to the EMF data. This data can be quite large so a
244 // memory map needs to be used.
245 IPC_STRUCT_MEMBER(base::SharedMemoryHandle, metafile_data_handle)
247 // Size of the metafile data.
248 IPC_STRUCT_MEMBER(uint32, data_size)
250 // Cookie for the document to ensure correctness.
251 IPC_STRUCT_MEMBER(int, document_cookie)
253 // Page number.
254 IPC_STRUCT_MEMBER(int, page_number)
256 // Shrink factor used to render this page.
257 IPC_STRUCT_MEMBER(double, actual_shrink)
259 // The size of the page the page author specified.
260 IPC_STRUCT_MEMBER(gfx::Size, page_size)
262 // The printable area the page author specified.
263 IPC_STRUCT_MEMBER(gfx::Rect, content_area)
264 IPC_STRUCT_END()
266 // Parameters for the IPC message ViewHostMsg_ScriptedPrint
267 IPC_STRUCT_BEGIN(PrintHostMsg_ScriptedPrint_Params)
268 IPC_STRUCT_MEMBER(int, cookie)
269 IPC_STRUCT_MEMBER(int, expected_pages_count)
270 IPC_STRUCT_MEMBER(bool, has_selection)
271 IPC_STRUCT_MEMBER(printing::MarginType, margin_type)
272 IPC_STRUCT_END()
275 // Messages sent from the browser to the renderer.
277 // Tells the render view to initiate print preview for the entire document.
278 IPC_MESSAGE_ROUTED1(PrintMsg_InitiatePrintPreview, bool /* selection_only */)
280 // Tells the render view to initiate printing or print preview for a particular
281 // node, depending on which mode the render view is in.
282 IPC_MESSAGE_ROUTED0(PrintMsg_PrintNodeUnderContextMenu)
284 // Tells the renderer to print the print preview tab's PDF plugin without
285 // showing the print dialog. (This is the final step in the print preview
286 // workflow.)
287 IPC_MESSAGE_ROUTED1(PrintMsg_PrintForPrintPreview,
288 base::DictionaryValue /* settings */)
290 // Tells the render view to switch the CSS to print media type, renders every
291 // requested pages and switch back the CSS to display media type.
292 IPC_MESSAGE_ROUTED0(PrintMsg_PrintPages)
294 // Tells the render view that printing is done so it can clean up.
295 IPC_MESSAGE_ROUTED1(PrintMsg_PrintingDone,
296 bool /* success */)
298 // Tells the render view whether scripted printing is blocked or not.
299 IPC_MESSAGE_ROUTED1(PrintMsg_SetScriptedPrintingBlocked,
300 bool /* blocked */)
302 // Tells the render view to switch the CSS to print media type, renders every
303 // requested pages for print preview using the given |settings|. This gets
304 // called multiple times as the user updates settings.
305 IPC_MESSAGE_ROUTED1(PrintMsg_PrintPreview,
306 base::DictionaryValue /* settings */)
308 // Like PrintMsg_PrintPages, but using the print preview document's frame/node.
309 IPC_MESSAGE_ROUTED0(PrintMsg_PrintForSystemDialog)
311 // Tells a renderer to stop blocking script initiated printing.
312 IPC_MESSAGE_ROUTED0(PrintMsg_ResetScriptedPrintCount)
314 // Messages sent from the renderer to the browser.
316 #if defined(OS_WIN)
317 // Duplicates a shared memory handle from the renderer to the browser. Then
318 // the renderer can flush the handle.
319 IPC_SYNC_MESSAGE_ROUTED1_1(PrintHostMsg_DuplicateSection,
320 base::SharedMemoryHandle /* renderer handle */,
321 base::SharedMemoryHandle /* browser handle */)
322 #endif
324 // Check if printing is enabled.
325 IPC_SYNC_MESSAGE_ROUTED0_1(PrintHostMsg_IsPrintingEnabled,
326 bool /* is_enabled */)
328 // Tells the browser that the renderer is done calculating the number of
329 // rendered pages according to the specified settings.
330 IPC_MESSAGE_ROUTED2(PrintHostMsg_DidGetPrintedPagesCount,
331 int /* rendered document cookie */,
332 int /* number of rendered pages */)
334 // Sends the document cookie of the current printer query to the browser.
335 IPC_MESSAGE_ROUTED1(PrintHostMsg_DidGetDocumentCookie,
336 int /* rendered document cookie */)
338 // Tells the browser that the print dialog has been shown.
339 IPC_MESSAGE_ROUTED0(PrintHostMsg_DidShowPrintDialog)
341 // Sends back to the browser the rendered "printed page" that was requested by
342 // a ViewMsg_PrintPage message or from scripted printing. The memory handle in
343 // this message is already valid in the browser process.
344 IPC_MESSAGE_ROUTED1(PrintHostMsg_DidPrintPage,
345 PrintHostMsg_DidPrintPage_Params /* page content */)
347 // The renderer wants to know the default print settings.
348 IPC_SYNC_MESSAGE_ROUTED0_1(PrintHostMsg_GetDefaultPrintSettings,
349 PrintMsg_Print_Params /* default_settings */)
351 // The renderer wants to update the current print settings with new
352 // |job_settings|.
353 IPC_SYNC_MESSAGE_ROUTED2_1(PrintHostMsg_UpdatePrintSettings,
354 int /* document_cookie */,
355 base::DictionaryValue /* job_settings */,
356 PrintMsg_PrintPages_Params /* current_settings */)
358 // It's the renderer that controls the printing process when it is generated
359 // by javascript. This step is about showing UI to the user to select the
360 // final print settings. The output parameter is the same as
361 // ViewMsg_PrintPages which is executed implicitly.
362 IPC_SYNC_MESSAGE_ROUTED1_1(PrintHostMsg_ScriptedPrint,
363 PrintHostMsg_ScriptedPrint_Params,
364 PrintMsg_PrintPages_Params
365 /* settings chosen by the user*/)
367 #if defined(OS_CHROMEOS) || defined(OS_ANDROID)
368 // Asks the browser to create a temporary file for the renderer to fill
369 // in resulting NativeMetafile in printing.
370 IPC_SYNC_MESSAGE_CONTROL1_2(PrintHostMsg_AllocateTempFileForPrinting,
371 int /* render_view_id */,
372 base::FileDescriptor /* temp file fd */,
373 int /* fd in browser*/) // Used only by Chrome OS.
374 IPC_MESSAGE_CONTROL2(PrintHostMsg_TempFileForPrintingWritten,
375 int /* render_view_id */,
376 int /* fd in browser */) // Used only by Chrome OS.
377 #endif
379 // Asks the browser to do print preview.
380 IPC_MESSAGE_ROUTED1(PrintHostMsg_RequestPrintPreview,
381 PrintHostMsg_RequestPrintPreview_Params /* params */)
383 // Notify the browser the number of pages in the print preview document.
384 IPC_MESSAGE_ROUTED1(PrintHostMsg_DidGetPreviewPageCount,
385 PrintHostMsg_DidGetPreviewPageCount_Params /* params */)
387 // Notify the browser of the default page layout according to the currently
388 // selected printer and page size.
389 // |printable_area_in_points| Specifies the printable area in points.
390 // |has_custom_page_size_style| is true when the printing frame has a custom
391 // page size css otherwise false.
392 IPC_MESSAGE_ROUTED3(PrintHostMsg_DidGetDefaultPageLayout,
393 printing::PageSizeMargins /* page layout in points */,
394 gfx::Rect /* printable area in points */,
395 bool /* has custom page size style */)
397 // Notify the browser a print preview page has been rendered.
398 IPC_MESSAGE_ROUTED1(PrintHostMsg_DidPreviewPage,
399 PrintHostMsg_DidPreviewPage_Params /* params */)
401 // Asks the browser whether the print preview has been cancelled.
402 IPC_SYNC_MESSAGE_ROUTED2_1(PrintHostMsg_CheckForCancel,
403 int32 /* PrintPreviewUI ID */,
404 int /* request id */,
405 bool /* print preview cancelled */)
407 // Sends back to the browser the complete rendered document (non-draft mode,
408 // used for printing) that was requested by a PrintMsg_PrintPreview message.
409 // The memory handle in this message is already valid in the browser process.
410 IPC_MESSAGE_ROUTED1(PrintHostMsg_MetafileReadyForPrinting,
411 PrintHostMsg_DidPreviewDocument_Params /* params */)
413 // Tell the browser printing failed.
414 IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintingFailed,
415 int /* document cookie */)
417 // Tell the browser print preview failed.
418 IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintPreviewFailed,
419 int /* document cookie */)
421 // Tell the browser print preview was cancelled.
422 IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintPreviewCancelled,
423 int /* document cookie */)
425 // Tell the browser print preview found the selected printer has invalid
426 // settings (which typically caused by disconnected network printer or printer
427 // driver is bogus).
428 IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintPreviewInvalidPrinterSettings,
429 int /* document cookie */)
431 // Run a nested message loop in the renderer until print preview for
432 // window.print() finishes.
433 IPC_SYNC_MESSAGE_ROUTED0_0(PrintHostMsg_SetupScriptedPrintPreview)
435 // Tell the browser to show the print preview, when the document is sufficiently
436 // loaded such that the renderer can determine whether it is modifiable or not.
437 IPC_MESSAGE_ROUTED1(PrintHostMsg_ShowScriptedPrintPreview,
438 bool /* is_modifiable */)
440 // Notify the browser that the PDF in the initiator renderer has disabled print
441 // scaling option.
442 IPC_MESSAGE_ROUTED0(PrintHostMsg_PrintPreviewScalingDisabled)