| 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 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 | 193 |
| 194 void Print(WebKit::WebFrame* frame, const WebKit::WebNode& node); | 194 void Print(WebKit::WebFrame* frame, const WebKit::WebNode& node); |
| 195 | 195 |
| 196 // Notification when printing is done - signal tear-down/free resources. | 196 // Notification when printing is done - signal tear-down/free resources. |
| 197 void DidFinishPrinting(PrintingResult result); | 197 void DidFinishPrinting(PrintingResult result); |
| 198 | 198 |
| 199 // Print Settings ----------------------------------------------------------- | 199 // Print Settings ----------------------------------------------------------- |
| 200 | 200 |
| 201 // Initialize print page settings with default settings. | 201 // Initialize print page settings with default settings. |
| 202 // Used only for native printing workflow. | 202 // Used only for native printing workflow. |
| 203 bool InitPrintSettings(); | 203 bool InitPrintSettings(WebKit::WebFrame* frame, const WebKit::WebNode& node); |
| 204 | 204 |
| 205 // Initialize print page settings with default settings and prepare the frame | 205 // Initialize print page settings with default settings and prepare the frame |
| 206 // for print. A new PrepareFrameAndViewForPrint is created to fulfill the | 206 // for print. A new PrepareFrameAndViewForPrint is created to fulfill the |
| 207 // request and is filled into the |prepare| argument. | 207 // request and is filled into the |prepare| argument. |
| 208 // Used only for native printing workflow. | 208 // Used only for native printing workflow. |
| 209 bool InitPrintSettingsAndPrepareFrame( | 209 bool InitPrintSettingsAndPrepareFrame( |
| 210 WebKit::WebFrame* frame, | 210 WebKit::WebFrame* frame, |
| 211 const WebKit::WebNode& node, | 211 const WebKit::WebNode& node, |
| 212 scoped_ptr<PrepareFrameAndViewForPrint>* prepare); | 212 scoped_ptr<PrepareFrameAndViewForPrint>* prepare); |
| 213 | 213 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 279 |
| 280 bool CopyMetafileDataToSharedMem(printing::Metafile* metafile, | 280 bool CopyMetafileDataToSharedMem(printing::Metafile* metafile, |
| 281 base::SharedMemoryHandle* shared_mem_handle); | 281 base::SharedMemoryHandle* shared_mem_handle); |
| 282 | 282 |
| 283 // Helper method to get page layout in points and fit to page if needed. | 283 // Helper method to get page layout in points and fit to page if needed. |
| 284 static void ComputePageLayoutInPointsForCss( | 284 static void ComputePageLayoutInPointsForCss( |
| 285 WebKit::WebFrame* frame, | 285 WebKit::WebFrame* frame, |
| 286 int page_index, | 286 int page_index, |
| 287 const PrintMsg_Print_Params& default_params, | 287 const PrintMsg_Print_Params& default_params, |
| 288 bool ignore_css_margins, | 288 bool ignore_css_margins, |
| 289 bool fit_to_page, | |
| 290 double* scale_factor, | 289 double* scale_factor, |
| 291 printing::PageSizeMargins* page_layout_in_points); | 290 printing::PageSizeMargins* page_layout_in_points); |
| 292 | 291 |
| 293 // Prepare the frame and view for print and then call this function to honor | 292 // Prepare the frame and view for print and then call this function to honor |
| 294 // the CSS page layout information. | 293 // the CSS page layout information. |
| 295 static void UpdateFrameAndViewFromCssPageLayout( | 294 static void UpdateFrameAndViewFromCssPageLayout( |
| 296 WebKit::WebFrame* frame, | 295 WebKit::WebFrame* frame, |
| 297 const WebKit::WebNode& node, | 296 const WebKit::WebNode& node, |
| 298 PrepareFrameAndViewForPrint* prepare, | 297 PrepareFrameAndViewForPrint* prepare, |
| 299 const PrintMsg_Print_Params& params, | 298 const PrintMsg_Print_Params& params, |
| 300 bool ignore_css_margins, | 299 bool ignore_css_margins); |
| 301 bool fit_to_page); | |
| 302 | 300 |
| 303 // Given the |device| and |canvas| to draw on, prints the appropriate headers | 301 // Given the |device| and |canvas| to draw on, prints the appropriate headers |
| 304 // and footers using strings from |header_footer_info| on to the canvas. | 302 // and footers using strings from |header_footer_info| on to the canvas. |
| 305 static void PrintHeaderAndFooter( | 303 static void PrintHeaderAndFooter( |
| 306 WebKit::WebCanvas* canvas, | 304 WebKit::WebCanvas* canvas, |
| 307 int page_number, | 305 int page_number, |
| 308 int total_pages, | 306 int total_pages, |
| 309 float webkit_scale_factor, | 307 float webkit_scale_factor, |
| 310 const printing::PageSizeMargins& page_layout_in_points, | 308 const printing::PageSizeMargins& page_layout_in_points, |
| 311 const base::DictionaryValue& header_footer_info); | 309 const base::DictionaryValue& header_footer_info); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 bool PreviewPageRendered(int page_number, printing::Metafile* metafile); | 346 bool PreviewPageRendered(int page_number, printing::Metafile* metafile); |
| 349 | 347 |
| 350 // WebView used only to print the selection. | 348 // WebView used only to print the selection. |
| 351 WebKit::WebView* print_web_view_; | 349 WebKit::WebView* print_web_view_; |
| 352 | 350 |
| 353 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_; | 351 scoped_ptr<PrintMsg_PrintPages_Params> print_pages_params_; |
| 354 bool is_preview_enabled_; | 352 bool is_preview_enabled_; |
| 355 bool is_print_ready_metafile_sent_; | 353 bool is_print_ready_metafile_sent_; |
| 356 bool ignore_css_margins_; | 354 bool ignore_css_margins_; |
| 357 | 355 |
| 358 // True if we need to auto fit to page else false. | |
| 359 // NOTE: When we print to pdf, we don't fit to page. | |
| 360 bool fit_to_page_; | |
| 361 | |
| 362 // Used for scripted initiated printing blocking. | 356 // Used for scripted initiated printing blocking. |
| 363 base::Time last_cancelled_script_print_; | 357 base::Time last_cancelled_script_print_; |
| 364 int user_cancelled_scripted_print_count_; | 358 int user_cancelled_scripted_print_count_; |
| 365 bool is_scripted_printing_blocked_; | 359 bool is_scripted_printing_blocked_; |
| 366 | 360 |
| 367 // Let the browser process know of a printing failure. Only set to false when | 361 // Let the browser process know of a printing failure. Only set to false when |
| 368 // the failure came from the browser in the first place. | 362 // the failure came from the browser in the first place. |
| 369 bool notify_browser_of_print_failure_; | 363 bool notify_browser_of_print_failure_; |
| 370 | 364 |
| 371 // True, when printing from print preview. | 365 // True, when printing from print preview. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 387 // the |web_frame| / |web_node| to generate the print preview for. | 381 // the |web_frame| / |web_node| to generate the print preview for. |
| 388 void InitWithFrame(WebKit::WebFrame* web_frame); | 382 void InitWithFrame(WebKit::WebFrame* web_frame); |
| 389 void InitWithNode(const WebKit::WebNode& web_node); | 383 void InitWithNode(const WebKit::WebNode& web_node); |
| 390 | 384 |
| 391 // Does bookkeeping at the beginning of print preview. | 385 // Does bookkeeping at the beginning of print preview. |
| 392 void OnPrintPreview(); | 386 void OnPrintPreview(); |
| 393 | 387 |
| 394 // Create the print preview document. |pages| is empty to print all pages. | 388 // Create the print preview document. |pages| is empty to print all pages. |
| 395 bool CreatePreviewDocument(PrintMsg_Print_Params* params, | 389 bool CreatePreviewDocument(PrintMsg_Print_Params* params, |
| 396 const std::vector<int>& pages, | 390 const std::vector<int>& pages, |
| 397 bool ignore_css_margins, | 391 bool ignore_css_margins); |
| 398 bool fit_to_page); | |
| 399 | 392 |
| 400 // Called after a page gets rendered. |page_time| is how long the | 393 // Called after a page gets rendered. |page_time| is how long the |
| 401 // rendering took. | 394 // rendering took. |
| 402 void RenderedPreviewPage(const base::TimeDelta& page_time); | 395 void RenderedPreviewPage(const base::TimeDelta& page_time); |
| 403 | 396 |
| 404 // Updates the print preview context when the required pages are rendered. | 397 // Updates the print preview context when the required pages are rendered. |
| 405 void AllPagesRendered(); | 398 void AllPagesRendered(); |
| 406 | 399 |
| 407 // Finalizes the print ready preview document. | 400 // Finalizes the print ready preview document. |
| 408 void FinalizePrintReadyDocument(); | 401 void FinalizePrintReadyDocument(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 enum PrintPreviewErrorBuckets error_; | 467 enum PrintPreviewErrorBuckets error_; |
| 475 | 468 |
| 476 State state_; | 469 State state_; |
| 477 }; | 470 }; |
| 478 | 471 |
| 479 PrintPreviewContext print_preview_context_; | 472 PrintPreviewContext print_preview_context_; |
| 480 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 473 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
| 481 }; | 474 }; |
| 482 | 475 |
| 483 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 476 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
| OLD | NEW |