Index: chrome/renderer/print_web_view_helper.h |
diff --git a/chrome/renderer/print_web_view_helper.h b/chrome/renderer/print_web_view_helper.h |
index 55a2e6be638d188e5fc8b1415c7fc76f5332be3a..2e489804ea08d1873b98e10aa0130edaa812ac51 100644 |
--- a/chrome/renderer/print_web_view_helper.h |
+++ b/chrome/renderer/print_web_view_helper.h |
@@ -18,6 +18,7 @@ |
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCanvas.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrameClient.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebPrintScalingOption.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h" |
#include "ui/gfx/size.h" |
@@ -62,17 +63,22 @@ class PrepareFrameAndViewForPrint { |
void FinishPrinting(); |
private: |
- void StartPrinting(const gfx::Size& print_params); |
+ void StartPrinting(const gfx::Size& canvas_size, |
+ const gfx::Rect& printable_area, |
+ const gfx::Size& paper_size); |
WebKit::WebFrame* frame_; |
WebKit::WebNode node_to_print_; |
WebKit::WebView* web_view_; |
gfx::Size print_canvas_size_; |
+ gfx::Rect printable_area_; |
+ gfx::Size paper_size_; |
gfx::Size prev_view_size_; |
gfx::Size prev_scroll_offset_; |
int dpi_; |
int expected_pages_count_; |
bool use_browser_overlays_; |
+ WebKit::WebPrintScalingOption print_scaling_option_; |
bool finished_; |
DISALLOW_COPY_AND_ASSIGN(PrepareFrameAndViewForPrint); |
@@ -160,6 +166,25 @@ class PrintWebViewHelper |
// Returns true if the current destination printer is PRINT_TO_PDF. |
bool IsPrintToPdfRequested(const base::DictionaryValue& settings); |
+ // Returns the print scaling option to retain/scale/crop the source page size |
+ // to fit the printable area of the paper. |
+ // |
+ // We retain the source page size when the current destination printer is |
+ // SAVE_AS_PDF. |
+ // |
+ // We crop the source page size to fit the printable area or we print only the |
+ // left top page contents when |
+ // (1) Source is PDF and the user has requested not to fit to printable area |
+ // via |job_settings|. |
+ // (2) Source is PDF. This is the first preview request and print scaling |
+ // option is disabled for initiator renderer plugin. |
+ // |
+ // In all other cases, we scale the source page to fit the printable area. |
+ WebKit::WebPrintScalingOption GetPrintScalingOption( |
+ bool source_is_html, |
+ const base::DictionaryValue& settings, |
+ const PrintMsg_Print_Params& params); |
+ |
// Initiate print preview. |
void OnInitiatePrintPreview(); |
@@ -200,7 +225,7 @@ class PrintWebViewHelper |
// Initialize print page settings with default settings. |
// Used only for native printing workflow. |
- bool InitPrintSettings(); |
+ bool InitPrintSettings(bool fit_to_paper_size); |
// Initialize print page settings with default settings and prepare the frame |
// for print. A new PrepareFrameAndViewForPrint is created to fulfill the |