OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 5 #ifndef CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
6 #define CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 6 #define CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 virtual void PrintPage(WebKit::WebFrame* frame) OVERRIDE; | 110 virtual void PrintPage(WebKit::WebFrame* frame) OVERRIDE; |
111 | 111 |
112 // Message handlers --------------------------------------------------------- | 112 // Message handlers --------------------------------------------------------- |
113 | 113 |
114 // Print the document. | 114 // Print the document. |
115 void OnPrintPages(); | 115 void OnPrintPages(); |
116 | 116 |
117 // Print the document with the print preview frame/node. | 117 // Print the document with the print preview frame/node. |
118 void OnPrintForSystemDialog(); | 118 void OnPrintForSystemDialog(); |
119 | 119 |
120 // Update |ignore_frame_margins_css_| based on settings. | |
121 void UpdateFrameMarginsCssInfo(const base::DictionaryValue& settings); | |
122 | |
123 // Returns true if the current destination printer is PRINT_TO_PDF. | |
124 bool IsPrintToPdfRequested(const base::DictionaryValue& settings); | |
125 | |
120 // Initiate print preview. | 126 // Initiate print preview. |
121 void OnInitiatePrintPreview(); | 127 void OnInitiatePrintPreview(); |
122 | 128 |
123 // Start the process of generating a print preview using |settings|. | 129 // Start the process of generating a print preview using |settings|. |
124 void OnPrintPreview(const base::DictionaryValue& settings); | 130 void OnPrintPreview(const base::DictionaryValue& settings); |
125 | 131 |
126 // Initialize the print preview document. | 132 // Initialize the print preview document. |
127 bool CreatePreviewDocument(); | 133 bool CreatePreviewDocument(); |
128 | 134 |
129 // Renders a print preview page. |page_number| is 0-based. | 135 // Renders a print preview page. |page_number| is 0-based. |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 | 241 |
236 bool CopyAndPrint(WebKit::WebFrame* web_frame); | 242 bool CopyAndPrint(WebKit::WebFrame* web_frame); |
237 | 243 |
238 bool CopyMetafileDataToSharedMem(printing::Metafile* metafile, | 244 bool CopyMetafileDataToSharedMem(printing::Metafile* metafile, |
239 base::SharedMemoryHandle* shared_mem_handle); | 245 base::SharedMemoryHandle* shared_mem_handle); |
240 | 246 |
241 static void GetPageSizeAndMarginsInPoints( | 247 static void GetPageSizeAndMarginsInPoints( |
242 WebKit::WebFrame* frame, | 248 WebKit::WebFrame* frame, |
243 int page_index, | 249 int page_index, |
244 const PrintMsg_Print_Params& default_params, | 250 const PrintMsg_Print_Params& default_params, |
251 bool ignore_frame_margins_css, | |
252 bool fit_to_page, | |
253 double* scale_factor, | |
245 printing::PageSizeMargins* page_layout_in_points); | 254 printing::PageSizeMargins* page_layout_in_points); |
246 | 255 |
247 static void UpdatePrintableSizeInPrintParameters( | 256 static void UpdatePrintableSizeInPrintParameters( |
248 WebKit::WebFrame* frame, | 257 WebKit::WebFrame* frame, |
249 const WebKit::WebNode& node, | 258 const WebKit::WebNode& node, |
250 PrepareFrameAndViewForPrint* prepare, | 259 PrepareFrameAndViewForPrint* prepare, |
251 PrintMsg_Print_Params* params); | 260 PrintMsg_Print_Params* params, |
261 bool ignore_frame_margins_css, | |
262 bool fit_to_page); | |
252 | 263 |
253 // Given the |device| and |canvas| to draw on, prints the appropriate headers | 264 // Given the |device| and |canvas| to draw on, prints the appropriate headers |
254 // and footers using strings from |header_footer_info| on to the canvas. | 265 // and footers using strings from |header_footer_info| on to the canvas. |
255 static void PrintHeaderAndFooter( | 266 static void PrintHeaderAndFooter( |
256 WebKit::WebCanvas* canvas, | 267 WebKit::WebCanvas* canvas, |
257 int page_number, | 268 int page_number, |
258 int total_pages, | 269 int total_pages, |
259 float webkit_scale_factor, | 270 float webkit_scale_factor, |
260 const printing::PageSizeMargins& page_layout_in_points, | 271 const printing::PageSizeMargins& page_layout_in_points, |
261 const base::DictionaryValue& header_footer_info); | 272 const base::DictionaryValue& header_footer_info); |
(...skipping 30 matching lines...) Expand all Loading... | |
292 // For a valid |page_number| with modifiable content, | 303 // For a valid |page_number| with modifiable content, |
293 // |metafile| is the rendered page. Otherwise |metafile| is NULL. | 304 // |metafile| is the rendered page. Otherwise |metafile| is NULL. |
294 // Returns true if print preview should continue, false on failure. | 305 // Returns true if print preview should continue, false on failure. |
295 bool PreviewPageRendered(int page_number, printing::Metafile* metafile); | 306 bool PreviewPageRendered(int page_number, printing::Metafile* metafile); |
296 | 307 |
297 WebKit::WebView* print_web_view_; | 308 WebKit::WebView* print_web_view_; |
298 | 309 |
299 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_; | 310 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_; |
300 bool is_preview_enabled_; | 311 bool is_preview_enabled_; |
301 bool is_print_ready_metafile_sent_; | 312 bool is_print_ready_metafile_sent_; |
313 bool ignore_frame_margins_css_; | |
314 | |
315 // True if the previewing/printing source is html. | |
vandebo (ex-Chrome)
2011/12/02 01:28:19
Don't we already have ways to figure that out here
kmadhusu
2011/12/02 23:33:19
whoops.. I meant to write "True if we need to auto
| |
316 // False if the source is pdf. | |
317 bool fit_to_page_; | |
302 | 318 |
303 // Used for scripted initiated printing blocking. | 319 // Used for scripted initiated printing blocking. |
304 base::Time last_cancelled_script_print_; | 320 base::Time last_cancelled_script_print_; |
305 int user_cancelled_scripted_print_count_; | 321 int user_cancelled_scripted_print_count_; |
306 | 322 |
307 // Let the browser process know of a printing failure. Only set to false when | 323 // Let the browser process know of a printing failure. Only set to false when |
308 // the failure came from the browser in the first place. | 324 // the failure came from the browser in the first place. |
309 bool notify_browser_of_print_failure_; | 325 bool notify_browser_of_print_failure_; |
310 | 326 |
311 scoped_ptr<PrintMsg_PrintPages_Params> old_print_pages_params_; | 327 scoped_ptr<PrintMsg_PrintPages_Params> old_print_pages_params_; |
(...skipping 24 matching lines...) Expand all Loading... | |
336 // Initializes the print preview context. Need to be called to set | 352 // Initializes the print preview context. Need to be called to set |
337 // the |web_frame| / |web_node| to generate the print preview for. | 353 // the |web_frame| / |web_node| to generate the print preview for. |
338 void InitWithFrame(WebKit::WebFrame* web_frame); | 354 void InitWithFrame(WebKit::WebFrame* web_frame); |
339 void InitWithNode(const WebKit::WebNode& web_node); | 355 void InitWithNode(const WebKit::WebNode& web_node); |
340 | 356 |
341 // Does bookkeeping at the beginning of print preview. | 357 // Does bookkeeping at the beginning of print preview. |
342 void OnPrintPreview(); | 358 void OnPrintPreview(); |
343 | 359 |
344 // Create the print preview document. |pages| is empty to print all pages. | 360 // Create the print preview document. |pages| is empty to print all pages. |
345 bool CreatePreviewDocument(PrintMsg_Print_Params* params, | 361 bool CreatePreviewDocument(PrintMsg_Print_Params* params, |
346 const std::vector<int>& pages); | 362 const std::vector<int>& pages, |
363 bool ignore_frame_margins_css, | |
364 bool fit_to_page); | |
347 | 365 |
348 // Called after a page gets rendered. |page_time| is how long the | 366 // Called after a page gets rendered. |page_time| is how long the |
349 // rendering took. | 367 // rendering took. |
350 void RenderedPreviewPage(const base::TimeDelta& page_time); | 368 void RenderedPreviewPage(const base::TimeDelta& page_time); |
351 | 369 |
352 // Updates the print preview context when the required pages are rendered. | 370 // Updates the print preview context when the required pages are rendered. |
353 void AllPagesRendered(); | 371 void AllPagesRendered(); |
354 | 372 |
355 // Finalizes the print ready preview document. | 373 // Finalizes the print ready preview document. |
356 void FinalizePrintReadyDocument(); | 374 void FinalizePrintReadyDocument(); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
423 | 441 |
424 State state_; | 442 State state_; |
425 }; | 443 }; |
426 | 444 |
427 PrintPreviewContext print_preview_context_; | 445 PrintPreviewContext print_preview_context_; |
428 | 446 |
429 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 447 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
430 }; | 448 }; |
431 | 449 |
432 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 450 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
OLD | NEW |