Add hpack_fuzz_wrapper to chromium_builder_asan (re-apply).
[chromium-blink-merge.git] / android_webview / common / print_messages.h
blob32d5790ba872eec0238b007c3480e0c704125c5a
1 // Copyright 2013 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 // TODO(sgurun) copied from chrome/common. Remove after crbug.com/322276
10 #include <string>
11 #include <vector>
13 #include "base/memory/shared_memory.h"
14 #include "base/values.h"
15 #include "ipc/ipc_message_macros.h"
16 #include "printing/page_size_margins.h"
17 #include "printing/print_job_constants.h"
18 #include "third_party/WebKit/public/web/WebPrintScalingOption.h"
19 #include "ui/gfx/native_widget_types.h"
20 #include "ui/gfx/rect.h"
22 #ifndef AW_COMMON_PRINT_MESSAGES_H_
23 #define AW_COMMON_PRINT_MESSAGES_H_
25 struct PrintMsg_Print_Params {
26 PrintMsg_Print_Params();
27 ~PrintMsg_Print_Params();
29 // Resets the members of the struct to 0.
30 void Reset();
32 gfx::Size page_size;
33 gfx::Size content_size;
34 gfx::Rect printable_area;
35 int margin_top;
36 int margin_left;
37 double dpi;
38 double min_shrink;
39 double max_shrink;
40 int desired_dpi;
41 int document_cookie;
42 bool selection_only;
43 bool supports_alpha_blend;
44 int32 preview_ui_id;
45 int preview_request_id;
46 bool is_first_request;
47 blink::WebPrintScalingOption print_scaling_option;
48 bool print_to_pdf;
49 bool display_header_footer;
50 base::string16 title;
51 base::string16 url;
52 bool should_print_backgrounds;
55 struct PrintMsg_PrintPages_Params {
56 PrintMsg_PrintPages_Params();
57 ~PrintMsg_PrintPages_Params();
59 // Resets the members of the struct to 0.
60 void Reset();
62 PrintMsg_Print_Params params;
63 std::vector<int> pages;
66 struct PrintHostMsg_RequestPrintPreview_Params {
67 PrintHostMsg_RequestPrintPreview_Params();
68 ~PrintHostMsg_RequestPrintPreview_Params();
69 bool is_modifiable;
70 bool webnode_only;
71 bool has_selection;
72 bool selection_only;
75 #endif // AW_COMMON_PRINT_MESSAGES_H_
77 #define IPC_MESSAGE_START PrintMsgStart
79 IPC_ENUM_TRAITS(printing::MarginType)
80 IPC_ENUM_TRAITS(blink::WebPrintScalingOption)
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 // True when we can reuse existing preview data. |metafile_data_handle| and
189 // |data_size| should not be used when this is true.
190 IPC_STRUCT_MEMBER(bool, reuse_existing_data)
192 // A shared memory handle to metafile data.
193 IPC_STRUCT_MEMBER(base::SharedMemoryHandle, metafile_data_handle)
195 // Size of metafile data.
196 IPC_STRUCT_MEMBER(uint32, data_size)
198 // Cookie for the document to ensure correctness.
199 IPC_STRUCT_MEMBER(int, document_cookie)
201 // Store the expected pages count.
202 IPC_STRUCT_MEMBER(int, expected_pages_count)
204 // Whether the preview can be modified.
205 IPC_STRUCT_MEMBER(bool, modifiable)
207 // The id of the preview request.
208 IPC_STRUCT_MEMBER(int, preview_request_id)
209 IPC_STRUCT_END()
211 // Parameters to describe a rendered preview page.
212 IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewPage_Params)
213 // A shared memory handle to metafile data for a draft document of the page.
214 IPC_STRUCT_MEMBER(base::SharedMemoryHandle, metafile_data_handle)
216 // Size of metafile data.
217 IPC_STRUCT_MEMBER(uint32, data_size)
219 // |page_number| is zero-based and can be |printing::INVALID_PAGE_INDEX| if it
220 // is just a check.
221 IPC_STRUCT_MEMBER(int, page_number)
223 // The id of the preview request.
224 IPC_STRUCT_MEMBER(int, preview_request_id)
225 IPC_STRUCT_END()
227 // Parameters sent along with the page count.
228 IPC_STRUCT_BEGIN(PrintHostMsg_DidGetPreviewPageCount_Params)
229 // Cookie for the document to ensure correctness.
230 IPC_STRUCT_MEMBER(int, document_cookie)
232 // Total page count.
233 IPC_STRUCT_MEMBER(int, page_count)
235 // Indicates whether the previewed document is modifiable.
236 IPC_STRUCT_MEMBER(bool, is_modifiable)
238 // The id of the preview request.
239 IPC_STRUCT_MEMBER(int, preview_request_id)
241 // Indicates whether the existing preview data needs to be cleared or not.
242 IPC_STRUCT_MEMBER(bool, clear_preview_data)
243 IPC_STRUCT_END()
245 // Parameters to describe a rendered page.
246 IPC_STRUCT_BEGIN(PrintHostMsg_DidPrintPage_Params)
247 // A shared memory handle to the EMF data. This data can be quite large so a
248 // memory map needs to be used.
249 IPC_STRUCT_MEMBER(base::SharedMemoryHandle, metafile_data_handle)
251 // Size of the metafile data.
252 IPC_STRUCT_MEMBER(uint32, data_size)
254 // Cookie for the document to ensure correctness.
255 IPC_STRUCT_MEMBER(int, document_cookie)
257 // Page number.
258 IPC_STRUCT_MEMBER(int, page_number)
260 // Shrink factor used to render this page.
261 IPC_STRUCT_MEMBER(double, actual_shrink)
263 // The size of the page the page author specified.
264 IPC_STRUCT_MEMBER(gfx::Size, page_size)
266 // The printable area the page author specified.
267 IPC_STRUCT_MEMBER(gfx::Rect, content_area)
268 IPC_STRUCT_END()
270 // Parameters for the IPC message ViewHostMsg_ScriptedPrint
271 IPC_STRUCT_BEGIN(PrintHostMsg_ScriptedPrint_Params)
272 IPC_STRUCT_MEMBER(int, cookie)
273 IPC_STRUCT_MEMBER(int, expected_pages_count)
274 IPC_STRUCT_MEMBER(bool, has_selection)
275 IPC_STRUCT_MEMBER(printing::MarginType, margin_type)
276 IPC_STRUCT_END()
279 // Messages sent from the browser to the renderer.
281 // Tells the render view to initiate print preview for the entire document.
282 IPC_MESSAGE_ROUTED1(PrintMsg_InitiatePrintPreview, bool /* selection_only */)
284 // Tells the render frame to initiate printing or print preview for a particular
285 // node, depending on which mode the render frame is in.
286 IPC_MESSAGE_ROUTED0(PrintMsg_PrintNodeUnderContextMenu)
288 // Tells the renderer to print the print preview tab's PDF plugin without
289 // showing the print dialog. (This is the final step in the print preview
290 // workflow.)
291 IPC_MESSAGE_ROUTED1(PrintMsg_PrintForPrintPreview,
292 base::DictionaryValue /* settings */)
294 // Tells the render view to switch the CSS to print media type, renders every
295 // requested pages and switch back the CSS to display media type.
296 IPC_MESSAGE_ROUTED0(PrintMsg_PrintPages)
298 // Tells the render view that printing is done so it can clean up.
299 IPC_MESSAGE_ROUTED1(PrintMsg_PrintingDone,
300 bool /* success */)
302 // Tells the render view whether scripted printing is blocked or not.
303 IPC_MESSAGE_ROUTED1(PrintMsg_SetScriptedPrintingBlocked,
304 bool /* blocked */)
306 // Tells the render view to switch the CSS to print media type, renders every
307 // requested pages for print preview using the given |settings|. This gets
308 // called multiple times as the user updates settings.
309 IPC_MESSAGE_ROUTED1(PrintMsg_PrintPreview,
310 base::DictionaryValue /* settings */)
312 // Like PrintMsg_PrintPages, but using the print preview document's frame/node.
313 IPC_MESSAGE_ROUTED0(PrintMsg_PrintForSystemDialog)
315 // Tells a renderer to stop blocking script initiated printing.
316 IPC_MESSAGE_ROUTED0(PrintMsg_ResetScriptedPrintCount)
318 // Messages sent from the renderer to the browser.
320 #if defined(OS_WIN)
321 // Duplicates a shared memory handle from the renderer to the browser. Then
322 // the renderer can flush the handle.
323 IPC_SYNC_MESSAGE_ROUTED1_1(PrintHostMsg_DuplicateSection,
324 base::SharedMemoryHandle /* renderer handle */,
325 base::SharedMemoryHandle /* browser handle */)
326 #endif
328 // Check if printing is enabled.
329 IPC_SYNC_MESSAGE_ROUTED0_1(PrintHostMsg_IsPrintingEnabled,
330 bool /* is_enabled */)
332 // Tells the browser that the renderer is done calculating the number of
333 // rendered pages according to the specified settings.
334 IPC_MESSAGE_ROUTED2(PrintHostMsg_DidGetPrintedPagesCount,
335 int /* rendered document cookie */,
336 int /* number of rendered pages */)
338 // Sends the document cookie of the current printer query to the browser.
339 IPC_MESSAGE_ROUTED1(PrintHostMsg_DidGetDocumentCookie,
340 int /* rendered document cookie */)
342 // Tells the browser that the print dialog has been shown.
343 IPC_MESSAGE_ROUTED0(PrintHostMsg_DidShowPrintDialog)
345 // Sends back to the browser the rendered "printed page" that was requested by
346 // a ViewMsg_PrintPage message or from scripted printing. The memory handle in
347 // this message is already valid in the browser process.
348 IPC_MESSAGE_ROUTED1(PrintHostMsg_DidPrintPage,
349 PrintHostMsg_DidPrintPage_Params /* page content */)
351 // The renderer wants to know the default print settings.
352 IPC_SYNC_MESSAGE_ROUTED0_1(PrintHostMsg_GetDefaultPrintSettings,
353 PrintMsg_Print_Params /* default_settings */)
355 // The renderer wants to update the current print settings with new
356 // |job_settings|.
357 IPC_SYNC_MESSAGE_ROUTED2_1(PrintHostMsg_UpdatePrintSettings,
358 int /* document_cookie */,
359 base::DictionaryValue /* job_settings */,
360 PrintMsg_PrintPages_Params /* current_settings */)
362 // It's the renderer that controls the printing process when it is generated
363 // by javascript. This step is about showing UI to the user to select the
364 // final print settings. The output parameter is the same as
365 // ViewMsg_PrintPages which is executed implicitly.
366 IPC_SYNC_MESSAGE_ROUTED1_1(PrintHostMsg_ScriptedPrint,
367 PrintHostMsg_ScriptedPrint_Params,
368 PrintMsg_PrintPages_Params
369 /* settings chosen by the user*/)
371 #if defined(OS_ANDROID)
372 // Asks the browser to create a temporary file for the renderer to fill
373 // in resulting NativeMetafile in printing.
374 IPC_SYNC_MESSAGE_ROUTED0_2(PrintHostMsg_AllocateTempFileForPrinting,
375 base::FileDescriptor /* temp file fd */,
376 int /* fd in browser*/)
377 IPC_MESSAGE_ROUTED1(PrintHostMsg_TempFileForPrintingWritten,
378 int /* fd in browser */)
379 #endif
380 // Asks the browser to do print preview.
381 IPC_MESSAGE_ROUTED1(PrintHostMsg_RequestPrintPreview,
382 PrintHostMsg_RequestPrintPreview_Params /* params */)
384 // Notify the browser the number of pages in the print preview document.
385 IPC_MESSAGE_ROUTED1(PrintHostMsg_DidGetPreviewPageCount,
386 PrintHostMsg_DidGetPreviewPageCount_Params /* params */)
388 // Notify the browser of the default page layout according to the currently
389 // selected printer and page size.
390 // |printable_area_in_points| Specifies the printable area in points.
391 // |has_custom_page_size_style| is true when the printing frame has a custom
392 // page size css otherwise false.
393 IPC_MESSAGE_ROUTED3(PrintHostMsg_DidGetDefaultPageLayout,
394 printing::PageSizeMargins /* page layout in points */,
395 gfx::Rect /* printable area in points */,
396 bool /* has custom page size style */)
398 // Notify the browser a print preview page has been rendered.
399 IPC_MESSAGE_ROUTED1(PrintHostMsg_DidPreviewPage,
400 PrintHostMsg_DidPreviewPage_Params /* params */)
402 // Asks the browser whether the print preview has been cancelled.
403 IPC_SYNC_MESSAGE_ROUTED2_1(PrintHostMsg_CheckForCancel,
404 int32 /* PrintPreviewUI ID */,
405 int /* request id */,
406 bool /* print preview cancelled */)
408 // Sends back to the browser the complete rendered document (non-draft mode,
409 // used for printing) that was requested by a PrintMsg_PrintPreview message.
410 // The memory handle in this message is already valid in the browser process.
411 IPC_MESSAGE_ROUTED1(PrintHostMsg_MetafileReadyForPrinting,
412 PrintHostMsg_DidPreviewDocument_Params /* params */)
414 // Tell the browser printing failed.
415 IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintingFailed,
416 int /* document cookie */)
418 // Tell the browser print preview failed.
419 IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintPreviewFailed,
420 int /* document cookie */)
422 // Tell the browser print preview was cancelled.
423 IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintPreviewCancelled,
424 int /* document cookie */)
426 // Tell the browser print preview found the selected printer has invalid
427 // settings (which typically caused by disconnected network printer or printer
428 // driver is bogus).
429 IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintPreviewInvalidPrinterSettings,
430 int /* document cookie */)
432 // Run a nested message loop in the renderer until print preview for
433 // window.print() finishes.
434 IPC_SYNC_MESSAGE_ROUTED0_0(PrintHostMsg_SetupScriptedPrintPreview)
436 // Tell the browser to show the print preview, when the document is sufficiently
437 // loaded such that the renderer can determine whether it is modifiable or not.
438 IPC_MESSAGE_ROUTED1(PrintHostMsg_ShowScriptedPrintPreview,
439 bool /* is_modifiable */)
441 // Notify the browser that the PDF in the initiator renderer has disabled print
442 // scaling option.
443 IPC_MESSAGE_ROUTED0(PrintHostMsg_PrintPreviewScalingDisabled)