Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4696)

Unified Diff: chrome/renderer/print_web_view_helper.h

Issue 10168013: [Print Preview] Modified PrepareFrameAndViewPrint class to call the new printBegin function to supp… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..690c1926beff48c4bbbcc6d5a5248979767973b4 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/WebPrintParams.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebViewClient.h"
#include "ui/gfx/size.h"
@@ -28,10 +29,16 @@ struct PrintMsg_PrintPages_Params;
namespace base {
class DictionaryValue;
}
+
namespace printing {
struct PageSizeMargins;
}
+namespace webkit {
+struct WebPrintScalingOption;
+struct WebRect;
+struct WebSize;
+}
// Class that calls the Begin and End print functions on the frame and changes
// the size of the view temporarily to support full page printing..
// Do not serve any events in the time between construction and destruction of
@@ -55,22 +62,26 @@ class PrepareFrameAndViewForPrint {
return use_browser_overlays_;
}
- const gfx::Size& GetPrintCanvasSize() const {
- return print_canvas_size_;
+ gfx::Size GetPrintCanvasSize() const {
+ return gfx::Size(web_print_params_.printContentArea.width,
+ web_print_params_.printContentArea.height);
}
void FinishPrinting();
private:
- void StartPrinting(const gfx::Size& print_params);
+ void StartPrinting(const WebKit::WebRect& canvas_area,
+ const WebKit::WebRect& printable_area,
+ const WebKit::WebSize& paper_size,
+ int dpi,
+ const WebKit::WebPrintScalingOption& print_scaling_option);
WebKit::WebFrame* frame_;
WebKit::WebNode node_to_print_;
WebKit::WebView* web_view_;
- gfx::Size print_canvas_size_;
+ WebKit::WebPrintParams web_print_params_;
gfx::Size prev_view_size_;
gfx::Size prev_scroll_offset_;
- int dpi_;
int expected_pages_count_;
bool use_browser_overlays_;
bool finished_;
@@ -160,6 +171,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 +230,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
@@ -424,7 +454,7 @@ class PrintWebViewHelper
bool generate_draft_pages() const;
printing::PreviewMetafile* metafile();
const PrintMsg_Print_Params& print_params() const;
- const gfx::Size& GetPrintCanvasSize() const;
+ gfx::Size GetPrintCanvasSize() const;
int last_error() const;
private:

Powered by Google App Engine
This is Rietveld 408576698