OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 COMPONENTS_PRINTING_RENDERER_PRINT_RENDER_FRAME_HELPER_H_ | 5 #ifndef COMPONENTS_PRINTING_RENDERER_PRINT_RENDER_FRAME_HELPER_H_ |
6 #define COMPONENTS_PRINTING_RENDERER_PRINT_RENDER_FRAME_HELPER_H_ | 6 #define COMPONENTS_PRINTING_RENDERER_PRINT_RENDER_FRAME_HELPER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 bool ignore_css_margins, | 346 bool ignore_css_margins, |
347 double* scale_factor, | 347 double* scale_factor, |
348 PageSizeMargins* page_layout_in_points); | 348 PageSizeMargins* page_layout_in_points); |
349 | 349 |
350 // Return an array of pages to print given the print |params| and an expected | 350 // Return an array of pages to print given the print |params| and an expected |
351 // |page_count|. Page numbers are zero-based. | 351 // |page_count|. Page numbers are zero-based. |
352 static std::vector<int> GetPrintedPages( | 352 static std::vector<int> GetPrintedPages( |
353 const PrintMsg_PrintPages_Params& params, | 353 const PrintMsg_PrintPages_Params& params, |
354 int page_count); | 354 int page_count); |
355 | 355 |
356 // Given the |canvas| to draw on, prints the appropriate headers and footers | 356 // Helper function to find document type. |
357 // to |canvas| using information from the remaining parameters. | 357 static SkiaDocumentType GetDocType(const PrintMsg_Print_Params& params); |
| 358 |
| 359 // Given the |device| and |canvas| to draw on, prints the appropriate headers |
| 360 // and footers using strings from |header_footer_info| on to the canvas. |
358 static void PrintHeaderAndFooter(blink::WebCanvas* canvas, | 361 static void PrintHeaderAndFooter(blink::WebCanvas* canvas, |
359 int page_number, | 362 int page_number, |
360 int total_pages, | 363 int total_pages, |
361 const blink::WebLocalFrame& source_frame, | 364 const blink::WebLocalFrame& source_frame, |
362 float webkit_scale_factor, | 365 float webkit_scale_factor, |
363 const PageSizeMargins& page_layout_in_points, | 366 const PageSizeMargins& page_layout_in_points, |
364 const PrintMsg_Print_Params& params); | 367 const PrintMsg_Print_Params& params); |
365 | 368 |
366 // Script Initiated Printing ------------------------------------------------ | 369 // Script Initiated Printing ------------------------------------------------ |
367 | 370 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
426 // the |web_frame| / |web_node| to generate the print preview for. | 429 // the |web_frame| / |web_node| to generate the print preview for. |
427 void InitWithFrame(blink::WebLocalFrame* web_frame); | 430 void InitWithFrame(blink::WebLocalFrame* web_frame); |
428 void InitWithNode(const blink::WebNode& web_node); | 431 void InitWithNode(const blink::WebNode& web_node); |
429 | 432 |
430 // Does bookkeeping at the beginning of print preview. | 433 // Does bookkeeping at the beginning of print preview. |
431 void OnPrintPreview(); | 434 void OnPrintPreview(); |
432 | 435 |
433 // Create the print preview document. |pages| is empty to print all pages. | 436 // Create the print preview document. |pages| is empty to print all pages. |
434 // Takes ownership of |prepared_frame|. | 437 // Takes ownership of |prepared_frame|. |
435 bool CreatePreviewDocument(PrepareFrameAndViewForPrint* prepared_frame, | 438 bool CreatePreviewDocument(PrepareFrameAndViewForPrint* prepared_frame, |
436 const std::vector<int>& pages); | 439 const std::vector<int>& pages, |
| 440 SkiaDocumentType doc_type); |
437 | 441 |
438 // Called after a page gets rendered. |page_time| is how long the | 442 // Called after a page gets rendered. |page_time| is how long the |
439 // rendering took. | 443 // rendering took. |
440 void RenderedPreviewPage(const base::TimeDelta& page_time); | 444 void RenderedPreviewPage(const base::TimeDelta& page_time); |
441 | 445 |
442 // Updates the print preview context when the required pages are rendered. | 446 // Updates the print preview context when the required pages are rendered. |
443 void AllPagesRendered(); | 447 void AllPagesRendered(); |
444 | 448 |
445 // Finalizes the print ready preview document. | 449 // Finalizes the print ready preview document. |
446 void FinalizePrintReadyDocument(); | 450 void FinalizePrintReadyDocument(); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 base::Closure on_stop_loading_closure_; | 566 base::Closure on_stop_loading_closure_; |
563 | 567 |
564 base::WeakPtrFactory<PrintRenderFrameHelper> weak_ptr_factory_; | 568 base::WeakPtrFactory<PrintRenderFrameHelper> weak_ptr_factory_; |
565 | 569 |
566 DISALLOW_COPY_AND_ASSIGN(PrintRenderFrameHelper); | 570 DISALLOW_COPY_AND_ASSIGN(PrintRenderFrameHelper); |
567 }; | 571 }; |
568 | 572 |
569 } // namespace printing | 573 } // namespace printing |
570 | 574 |
571 #endif // COMPONENTS_PRINTING_RENDERER_PRINT_RENDER_FRAME_HELPER_H_ | 575 #endif // COMPONENTS_PRINTING_RENDERER_PRINT_RENDER_FRAME_HELPER_H_ |
OLD | NEW |