Battery Status API: add UMA logging for Linux.
[chromium-blink-merge.git] / android_webview / common / print_messages.h
blob6da90de8f5cdd7ea67bde06e3be4d6b74addb7fe
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/ipc/gfx_param_traits.h"
20 #include "ui/gfx/native_widget_types.h"
21 #include "ui/gfx/rect.h"
23 #ifndef AW_COMMON_PRINT_MESSAGES_H_
24 #define AW_COMMON_PRINT_MESSAGES_H_
26 struct PrintMsg_Print_Params {
27 PrintMsg_Print_Params();
28 ~PrintMsg_Print_Params();
30 // Resets the members of the struct to 0.
31 void Reset();
33 gfx::Size page_size;
34 gfx::Size content_size;
35 gfx::Rect printable_area;
36 int margin_top;
37 int margin_left;
38 double dpi;
39 double min_shrink;
40 double max_shrink;
41 int desired_dpi;
42 int document_cookie;
43 bool selection_only;
44 bool supports_alpha_blend;
45 int32 preview_ui_id;
46 int preview_request_id;
47 bool is_first_request;
48 blink::WebPrintScalingOption print_scaling_option;
49 bool print_to_pdf;
50 bool display_header_footer;
51 base::string16 title;
52 base::string16 url;
53 bool should_print_backgrounds;
56 struct PrintMsg_PrintPages_Params {
57 PrintMsg_PrintPages_Params();
58 ~PrintMsg_PrintPages_Params();
60 // Resets the members of the struct to 0.
61 void Reset();
63 PrintMsg_Print_Params params;
64 std::vector<int> pages;
67 struct PrintHostMsg_RequestPrintPreview_Params {
68 PrintHostMsg_RequestPrintPreview_Params();
69 ~PrintHostMsg_RequestPrintPreview_Params();
70 bool is_modifiable;
71 bool webnode_only;
72 bool has_selection;
73 bool selection_only;
76 #endif // AW_COMMON_PRINT_MESSAGES_H_
78 #define IPC_MESSAGE_START PrintMsgStart
80 IPC_ENUM_TRAITS(printing::MarginType)
81 IPC_ENUM_TRAITS(blink::WebPrintScalingOption)
83 // Parameters for a render request.
84 IPC_STRUCT_TRAITS_BEGIN(PrintMsg_Print_Params)
85 // Physical size of the page, including non-printable margins,
86 // in pixels according to dpi.
87 IPC_STRUCT_TRAITS_MEMBER(page_size)
89 // In pixels according to dpi_x and dpi_y.
90 IPC_STRUCT_TRAITS_MEMBER(content_size)
92 // Physical printable area of the page in pixels according to dpi.
93 IPC_STRUCT_TRAITS_MEMBER(printable_area)
95 // The y-offset of the printable area, in pixels according to dpi.
96 IPC_STRUCT_TRAITS_MEMBER(margin_top)
98 // The x-offset of the printable area, in pixels according to dpi.
99 IPC_STRUCT_TRAITS_MEMBER(margin_left)
101 // Specifies dots per inch.
102 IPC_STRUCT_TRAITS_MEMBER(dpi)
104 // Minimum shrink factor. See PrintSettings::min_shrink for more information.
105 IPC_STRUCT_TRAITS_MEMBER(min_shrink)
107 // Maximum shrink factor. See PrintSettings::max_shrink for more information.
108 IPC_STRUCT_TRAITS_MEMBER(max_shrink)
110 // Desired apparent dpi on paper.
111 IPC_STRUCT_TRAITS_MEMBER(desired_dpi)
113 // Cookie for the document to ensure correctness.
114 IPC_STRUCT_TRAITS_MEMBER(document_cookie)
116 // Should only print currently selected text.
117 IPC_STRUCT_TRAITS_MEMBER(selection_only)
119 // Does the printer support alpha blending?
120 IPC_STRUCT_TRAITS_MEMBER(supports_alpha_blend)
122 // *** Parameters below are used only for print preview. ***
124 // The print preview ui associated with this request.
125 IPC_STRUCT_TRAITS_MEMBER(preview_ui_id)
127 // The id of the preview request.
128 IPC_STRUCT_TRAITS_MEMBER(preview_request_id)
130 // True if this is the first preview request.
131 IPC_STRUCT_TRAITS_MEMBER(is_first_request)
133 // Specifies the page scaling option for preview printing.
134 IPC_STRUCT_TRAITS_MEMBER(print_scaling_option)
136 // True if print to pdf is requested.
137 IPC_STRUCT_TRAITS_MEMBER(print_to_pdf)
139 // Specifies if the header and footer should be rendered.
140 IPC_STRUCT_TRAITS_MEMBER(display_header_footer)
142 // Title string to be printed as header if requested by the user.
143 IPC_STRUCT_TRAITS_MEMBER(title)
145 // URL string to be printed as footer if requested by the user.
146 IPC_STRUCT_TRAITS_MEMBER(url)
148 // True if print backgrounds is requested by the user.
149 IPC_STRUCT_TRAITS_MEMBER(should_print_backgrounds)
150 IPC_STRUCT_TRAITS_END()
152 IPC_STRUCT_BEGIN(PrintMsg_PrintPage_Params)
153 // Parameters to render the page as a printed page. It must always be the same
154 // value for all the document.
155 IPC_STRUCT_MEMBER(PrintMsg_Print_Params, params)
157 // The page number is the indicator of the square that should be rendered
158 // according to the layout specified in PrintMsg_Print_Params.
159 IPC_STRUCT_MEMBER(int, page_number)
160 IPC_STRUCT_END()
162 IPC_STRUCT_TRAITS_BEGIN(PrintHostMsg_RequestPrintPreview_Params)
163 IPC_STRUCT_TRAITS_MEMBER(is_modifiable)
164 IPC_STRUCT_TRAITS_MEMBER(webnode_only)
165 IPC_STRUCT_TRAITS_MEMBER(has_selection)
166 IPC_STRUCT_TRAITS_MEMBER(selection_only)
167 IPC_STRUCT_TRAITS_END()
169 IPC_STRUCT_TRAITS_BEGIN(printing::PageSizeMargins)
170 IPC_STRUCT_TRAITS_MEMBER(content_width)
171 IPC_STRUCT_TRAITS_MEMBER(content_height)
172 IPC_STRUCT_TRAITS_MEMBER(margin_left)
173 IPC_STRUCT_TRAITS_MEMBER(margin_right)
174 IPC_STRUCT_TRAITS_MEMBER(margin_top)
175 IPC_STRUCT_TRAITS_MEMBER(margin_bottom)
176 IPC_STRUCT_TRAITS_END()
178 IPC_STRUCT_TRAITS_BEGIN(PrintMsg_PrintPages_Params)
179 // Parameters to render the page as a printed page. It must always be the same
180 // value for all the document.
181 IPC_STRUCT_TRAITS_MEMBER(params)
183 // If empty, this means a request to render all the printed pages.
184 IPC_STRUCT_TRAITS_MEMBER(pages)
185 IPC_STRUCT_TRAITS_END()
187 // Parameters to describe a rendered document.
188 IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewDocument_Params)
189 // True when we can reuse existing preview data. |metafile_data_handle| and
190 // |data_size| should not be used when this is true.
191 IPC_STRUCT_MEMBER(bool, reuse_existing_data)
193 // A shared memory handle to metafile data.
194 IPC_STRUCT_MEMBER(base::SharedMemoryHandle, metafile_data_handle)
196 // Size of metafile data.
197 IPC_STRUCT_MEMBER(uint32, data_size)
199 // Cookie for the document to ensure correctness.
200 IPC_STRUCT_MEMBER(int, document_cookie)
202 // Store the expected pages count.
203 IPC_STRUCT_MEMBER(int, expected_pages_count)
205 // Whether the preview can be modified.
206 IPC_STRUCT_MEMBER(bool, modifiable)
208 // The id of the preview request.
209 IPC_STRUCT_MEMBER(int, preview_request_id)
210 IPC_STRUCT_END()
212 // Parameters to describe a rendered preview page.
213 IPC_STRUCT_BEGIN(PrintHostMsg_DidPreviewPage_Params)
214 // A shared memory handle to metafile data for a draft document of the page.
215 IPC_STRUCT_MEMBER(base::SharedMemoryHandle, metafile_data_handle)
217 // Size of metafile data.
218 IPC_STRUCT_MEMBER(uint32, data_size)
220 // |page_number| is zero-based and can be |printing::INVALID_PAGE_INDEX| if it
221 // is just a check.
222 IPC_STRUCT_MEMBER(int, page_number)
224 // The id of the preview request.
225 IPC_STRUCT_MEMBER(int, preview_request_id)
226 IPC_STRUCT_END()
228 // Parameters sent along with the page count.
229 IPC_STRUCT_BEGIN(PrintHostMsg_DidGetPreviewPageCount_Params)
230 // Cookie for the document to ensure correctness.
231 IPC_STRUCT_MEMBER(int, document_cookie)
233 // Total page count.
234 IPC_STRUCT_MEMBER(int, page_count)
236 // Indicates whether the previewed document is modifiable.
237 IPC_STRUCT_MEMBER(bool, is_modifiable)
239 // The id of the preview request.
240 IPC_STRUCT_MEMBER(int, preview_request_id)
242 // Indicates whether the existing preview data needs to be cleared or not.
243 IPC_STRUCT_MEMBER(bool, clear_preview_data)
244 IPC_STRUCT_END()
246 // Parameters to describe a rendered page.
247 IPC_STRUCT_BEGIN(PrintHostMsg_DidPrintPage_Params)
248 // A shared memory handle to the EMF data. This data can be quite large so a
249 // memory map needs to be used.
250 IPC_STRUCT_MEMBER(base::SharedMemoryHandle, metafile_data_handle)
252 // Size of the metafile data.
253 IPC_STRUCT_MEMBER(uint32, data_size)
255 // Cookie for the document to ensure correctness.
256 IPC_STRUCT_MEMBER(int, document_cookie)
258 // Page number.
259 IPC_STRUCT_MEMBER(int, page_number)
261 // Shrink factor used to render this page.
262 IPC_STRUCT_MEMBER(double, actual_shrink)
264 // The size of the page the page author specified.
265 IPC_STRUCT_MEMBER(gfx::Size, page_size)
267 // The printable area the page author specified.
268 IPC_STRUCT_MEMBER(gfx::Rect, content_area)
269 IPC_STRUCT_END()
271 // Parameters for the IPC message ViewHostMsg_ScriptedPrint
272 IPC_STRUCT_BEGIN(PrintHostMsg_ScriptedPrint_Params)
273 IPC_STRUCT_MEMBER(int, cookie)
274 IPC_STRUCT_MEMBER(int, expected_pages_count)
275 IPC_STRUCT_MEMBER(bool, has_selection)
276 IPC_STRUCT_MEMBER(printing::MarginType, margin_type)
277 IPC_STRUCT_END()
280 // Messages sent from the browser to the renderer.
282 // Tells the render view to initiate print preview for the entire document.
283 IPC_MESSAGE_ROUTED1(PrintMsg_InitiatePrintPreview, bool /* selection_only */)
285 // Tells the render frame to initiate printing or print preview for a particular
286 // node, depending on which mode the render frame is in.
287 IPC_MESSAGE_ROUTED0(PrintMsg_PrintNodeUnderContextMenu)
289 // Tells the renderer to print the print preview tab's PDF plugin without
290 // showing the print dialog. (This is the final step in the print preview
291 // workflow.)
292 IPC_MESSAGE_ROUTED1(PrintMsg_PrintForPrintPreview,
293 base::DictionaryValue /* settings */)
295 // Tells the render view to switch the CSS to print media type, renders every
296 // requested pages and switch back the CSS to display media type.
297 IPC_MESSAGE_ROUTED0(PrintMsg_PrintPages)
299 // Tells the render view that printing is done so it can clean up.
300 IPC_MESSAGE_ROUTED1(PrintMsg_PrintingDone,
301 bool /* success */)
303 // Tells the render view whether scripted printing is blocked or not.
304 IPC_MESSAGE_ROUTED1(PrintMsg_SetScriptedPrintingBlocked,
305 bool /* blocked */)
307 // Tells the render view to switch the CSS to print media type, renders every
308 // requested pages for print preview using the given |settings|. This gets
309 // called multiple times as the user updates settings.
310 IPC_MESSAGE_ROUTED1(PrintMsg_PrintPreview,
311 base::DictionaryValue /* settings */)
313 // Like PrintMsg_PrintPages, but using the print preview document's frame/node.
314 IPC_MESSAGE_ROUTED0(PrintMsg_PrintForSystemDialog)
316 // Tells a renderer to stop blocking script initiated printing.
317 IPC_MESSAGE_ROUTED0(PrintMsg_ResetScriptedPrintCount)
319 // Messages sent from the renderer to the browser.
321 #if defined(OS_WIN)
322 // Duplicates a shared memory handle from the renderer to the browser. Then
323 // the renderer can flush the handle.
324 IPC_SYNC_MESSAGE_ROUTED1_1(PrintHostMsg_DuplicateSection,
325 base::SharedMemoryHandle /* renderer handle */,
326 base::SharedMemoryHandle /* browser handle */)
327 #endif
329 // Check if printing is enabled.
330 IPC_SYNC_MESSAGE_ROUTED0_1(PrintHostMsg_IsPrintingEnabled,
331 bool /* is_enabled */)
333 // Tells the browser that the renderer is done calculating the number of
334 // rendered pages according to the specified settings.
335 IPC_MESSAGE_ROUTED2(PrintHostMsg_DidGetPrintedPagesCount,
336 int /* rendered document cookie */,
337 int /* number of rendered pages */)
339 // Sends the document cookie of the current printer query to the browser.
340 IPC_MESSAGE_ROUTED1(PrintHostMsg_DidGetDocumentCookie,
341 int /* rendered document cookie */)
343 // Tells the browser that the print dialog has been shown.
344 IPC_MESSAGE_ROUTED0(PrintHostMsg_DidShowPrintDialog)
346 // Sends back to the browser the rendered "printed page" that was requested by
347 // a ViewMsg_PrintPage message or from scripted printing. The memory handle in
348 // this message is already valid in the browser process.
349 IPC_MESSAGE_ROUTED1(PrintHostMsg_DidPrintPage,
350 PrintHostMsg_DidPrintPage_Params /* page content */)
352 // The renderer wants to know the default print settings.
353 IPC_SYNC_MESSAGE_ROUTED0_1(PrintHostMsg_GetDefaultPrintSettings,
354 PrintMsg_Print_Params /* default_settings */)
356 // The renderer wants to update the current print settings with new
357 // |job_settings|.
358 IPC_SYNC_MESSAGE_ROUTED2_1(PrintHostMsg_UpdatePrintSettings,
359 int /* document_cookie */,
360 base::DictionaryValue /* job_settings */,
361 PrintMsg_PrintPages_Params /* current_settings */)
363 // It's the renderer that controls the printing process when it is generated
364 // by javascript. This step is about showing UI to the user to select the
365 // final print settings. The output parameter is the same as
366 // ViewMsg_PrintPages which is executed implicitly.
367 IPC_SYNC_MESSAGE_ROUTED1_1(PrintHostMsg_ScriptedPrint,
368 PrintHostMsg_ScriptedPrint_Params,
369 PrintMsg_PrintPages_Params
370 /* settings chosen by the user*/)
372 #if defined(OS_ANDROID)
373 // Asks the browser to create a temporary file for the renderer to fill
374 // in resulting NativeMetafile in printing.
375 IPC_SYNC_MESSAGE_ROUTED0_2(PrintHostMsg_AllocateTempFileForPrinting,
376 base::FileDescriptor /* temp file fd */,
377 int /* fd in browser*/)
378 IPC_MESSAGE_ROUTED1(PrintHostMsg_TempFileForPrintingWritten,
379 int /* fd in browser */)
380 #endif
381 // Asks the browser to do print preview.
382 IPC_MESSAGE_ROUTED1(PrintHostMsg_RequestPrintPreview,
383 PrintHostMsg_RequestPrintPreview_Params /* params */)
385 // Notify the browser the number of pages in the print preview document.
386 IPC_MESSAGE_ROUTED1(PrintHostMsg_DidGetPreviewPageCount,
387 PrintHostMsg_DidGetPreviewPageCount_Params /* params */)
389 // Notify the browser of the default page layout according to the currently
390 // selected printer and page size.
391 // |printable_area_in_points| Specifies the printable area in points.
392 // |has_custom_page_size_style| is true when the printing frame has a custom
393 // page size css otherwise false.
394 IPC_MESSAGE_ROUTED3(PrintHostMsg_DidGetDefaultPageLayout,
395 printing::PageSizeMargins /* page layout in points */,
396 gfx::Rect /* printable area in points */,
397 bool /* has custom page size style */)
399 // Notify the browser a print preview page has been rendered.
400 IPC_MESSAGE_ROUTED1(PrintHostMsg_DidPreviewPage,
401 PrintHostMsg_DidPreviewPage_Params /* params */)
403 // Asks the browser whether the print preview has been cancelled.
404 IPC_SYNC_MESSAGE_ROUTED2_1(PrintHostMsg_CheckForCancel,
405 int32 /* PrintPreviewUI ID */,
406 int /* request id */,
407 bool /* print preview cancelled */)
409 // Sends back to the browser the complete rendered document (non-draft mode,
410 // used for printing) that was requested by a PrintMsg_PrintPreview message.
411 // The memory handle in this message is already valid in the browser process.
412 IPC_MESSAGE_ROUTED1(PrintHostMsg_MetafileReadyForPrinting,
413 PrintHostMsg_DidPreviewDocument_Params /* params */)
415 // Tell the browser printing failed.
416 IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintingFailed,
417 int /* document cookie */)
419 // Tell the browser print preview failed.
420 IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintPreviewFailed,
421 int /* document cookie */)
423 // Tell the browser print preview was cancelled.
424 IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintPreviewCancelled,
425 int /* document cookie */)
427 // Tell the browser print preview found the selected printer has invalid
428 // settings (which typically caused by disconnected network printer or printer
429 // driver is bogus).
430 IPC_MESSAGE_ROUTED1(PrintHostMsg_PrintPreviewInvalidPrinterSettings,
431 int /* document cookie */)
433 // Run a nested message loop in the renderer until print preview for
434 // window.print() finishes.
435 IPC_SYNC_MESSAGE_ROUTED0_0(PrintHostMsg_SetupScriptedPrintPreview)
437 // Tell the browser to show the print preview, when the document is sufficiently
438 // loaded such that the renderer can determine whether it is modifiable or not.
439 IPC_MESSAGE_ROUTED1(PrintHostMsg_ShowScriptedPrintPreview,
440 bool /* is_modifiable */)
442 // Notify the browser that the PDF in the initiator renderer has disabled print
443 // scaling option.
444 IPC_MESSAGE_ROUTED0(PrintHostMsg_PrintPreviewScalingDisabled)