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_WEB_VIEW_HELPER_H_ | 5 #ifndef COMPONENTS_PRINTING_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
6 #define COMPONENTS_PRINTING_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 6 #define COMPONENTS_PRINTING_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 void FinishFramePrinting(); | 286 void FinishFramePrinting(); |
287 // Render the frame for printing. | 287 // Render the frame for printing. |
288 bool RenderPagesForPrint(blink::WebLocalFrame* frame, | 288 bool RenderPagesForPrint(blink::WebLocalFrame* frame, |
289 const blink::WebNode& node); | 289 const blink::WebNode& node); |
290 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) | 290 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) |
291 | 291 |
292 // Prints the page listed in |params|. | 292 // Prints the page listed in |params|. |
293 #if defined(OS_MACOSX) | 293 #if defined(OS_MACOSX) |
294 void PrintPagesInternal(const PrintMsg_Print_Params& params, | 294 void PrintPagesInternal(const PrintMsg_Print_Params& params, |
295 const std::vector<int>& printed_pages, | 295 const std::vector<int>& printed_pages, |
| 296 int page_count, |
296 blink::WebLocalFrame* frame); | 297 blink::WebLocalFrame* frame); |
297 #else | 298 #else |
298 void PrintPageInternal(const PrintMsg_Print_Params& params, | 299 void PrintPageInternal(const PrintMsg_Print_Params& params, |
299 int page_number, | 300 int page_number, |
| 301 int page_count, |
300 blink::WebLocalFrame* frame, | 302 blink::WebLocalFrame* frame, |
301 PdfMetafileSkia* metafile, | 303 PdfMetafileSkia* metafile, |
302 gfx::Size* page_size_in_dpi, | 304 gfx::Size* page_size_in_dpi, |
303 gfx::Rect* content_area_in_dpi, | 305 gfx::Rect* content_area_in_dpi, |
304 gfx::Rect* printable_area_in_dpi); | 306 gfx::Rect* printable_area_in_dpi); |
305 #endif // defined(OS_MACOSX) | 307 #endif // defined(OS_MACOSX) |
306 | 308 |
307 // Platform specific helper function for rendering page(s) to |metafile|. | 309 // Platform specific helper function for rendering page(s) to |metafile|. |
308 #if defined(OS_MACOSX) | 310 #if defined(OS_MACOSX) |
309 void RenderPage(const PrintMsg_Print_Params& params, | 311 void RenderPage(const PrintMsg_Print_Params& params, |
310 int page_number, | 312 int page_number, |
| 313 int page_count, |
311 blink::WebLocalFrame* frame, | 314 blink::WebLocalFrame* frame, |
312 bool is_preview, | 315 bool is_preview, |
313 PdfMetafileSkia* metafile, | 316 PdfMetafileSkia* metafile, |
314 gfx::Size* page_size, | 317 gfx::Size* page_size, |
315 gfx::Rect* content_rect); | 318 gfx::Rect* content_rect); |
316 #endif // defined(OS_MACOSX) | 319 #endif // defined(OS_MACOSX) |
317 | 320 |
318 // Renders page contents from |frame| to |content_area| of |canvas|. | 321 // Renders page contents from |frame| to |content_area| of |canvas|. |
319 // |page_number| is zero-based. | 322 // |page_number| is zero-based. |
320 // When method is called, canvas should be setup to draw to |canvas_area| | 323 // When method is called, canvas should be setup to draw to |canvas_area| |
(...skipping 18 matching lines...) Expand all Loading... |
339 bool ignore_css_margins, | 342 bool ignore_css_margins, |
340 double* scale_factor, | 343 double* scale_factor, |
341 PageSizeMargins* page_layout_in_points); | 344 PageSizeMargins* page_layout_in_points); |
342 | 345 |
343 // Return an array of pages to print given the print |params| and an expected | 346 // Return an array of pages to print given the print |params| and an expected |
344 // |page_count|. Page numbers are zero-based. | 347 // |page_count|. Page numbers are zero-based. |
345 static std::vector<int> GetPrintedPages( | 348 static std::vector<int> GetPrintedPages( |
346 const PrintMsg_PrintPages_Params& params, | 349 const PrintMsg_PrintPages_Params& params, |
347 int page_count); | 350 int page_count); |
348 | 351 |
349 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) | 352 // Given the |canvas| to draw on, prints the appropriate headers and footers |
350 // Given the |device| and |canvas| to draw on, prints the appropriate headers | 353 // to |canvas| using information from the remaining parameters. |
351 // and footers using strings from |header_footer_info| on to the canvas. | |
352 static void PrintHeaderAndFooter(blink::WebCanvas* canvas, | 354 static void PrintHeaderAndFooter(blink::WebCanvas* canvas, |
353 int page_number, | 355 int page_number, |
354 int total_pages, | 356 int total_pages, |
355 const blink::WebFrame& source_frame, | 357 const blink::WebFrame& source_frame, |
356 float webkit_scale_factor, | 358 float webkit_scale_factor, |
357 const PageSizeMargins& page_layout_in_points, | 359 const PageSizeMargins& page_layout_in_points, |
358 const PrintMsg_Print_Params& params); | 360 const PrintMsg_Print_Params& params); |
359 #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) | |
360 | 361 |
361 // Script Initiated Printing ------------------------------------------------ | 362 // Script Initiated Printing ------------------------------------------------ |
362 | 363 |
363 // Return true if script initiated printing is currently | 364 // Return true if script initiated printing is currently |
364 // allowed. |user_initiated| should be true when a user event triggered the | 365 // allowed. |user_initiated| should be true when a user event triggered the |
365 // script, most likely by pressing a print button on the page. | 366 // script, most likely by pressing a print button on the page. |
366 bool IsScriptInitiatedPrintAllowed(blink::WebLocalFrame* frame, | 367 bool IsScriptInitiatedPrintAllowed(blink::WebLocalFrame* frame, |
367 bool user_initiated); | 368 bool user_initiated); |
368 | 369 |
369 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) | 370 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 base::Closure on_stop_loading_closure_; | 558 base::Closure on_stop_loading_closure_; |
558 | 559 |
559 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; | 560 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; |
560 | 561 |
561 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 562 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
562 }; | 563 }; |
563 | 564 |
564 } // namespace printing | 565 } // namespace printing |
565 | 566 |
566 #endif // COMPONENTS_PRINTING_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 567 #endif // COMPONENTS_PRINTING_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
OLD | NEW |