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

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: Fixed nits 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
« no previous file with comments | « chrome/renderer/mock_printer.cc ('k') | chrome/renderer/print_web_view_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 86dc95d5130abf28c32c8d1d05264d4acdd72796..b83bf2e47002a9d334dd837a79d9a6a7a344552b 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"
@@ -55,22 +56,22 @@ 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::WebPrintParams& webkit_print_params);
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,16 +161,24 @@ class PrintWebViewHelper
// Returns true if the current destination printer is PRINT_TO_PDF.
bool IsPrintToPdfRequested(const base::DictionaryValue& settings);
- // Returns false if
- // (1) The current destination printer is SAVE_AS_PDF or
+ // 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.
- // (3) Source is PDF and the user has requested not to fit to printable area
- // via |job_settings|.
- // In all other cases returns true to fit the print contents in paper size.
- bool IsFitToPaperSizeRequested(bool source_is_html,
- const base::DictionaryValue& job_settings,
- const PrintMsg_Print_Params& params);
+ //
+ // In all other cases, we scale the source page to fit the printable area.
+ WebKit::WebPrintScalingOption GetPrintScalingOption(
+ bool source_is_html,
+ const base::DictionaryValue& job_settings,
+ const PrintMsg_Print_Params& params);
// Initiate print preview.
void OnInitiatePrintPreview();
@@ -211,7 +220,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
@@ -435,7 +444,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:
« no previous file with comments | « chrome/renderer/mock_printer.cc ('k') | chrome/renderer/print_web_view_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698