Index: chrome/renderer/print_web_view_helper.cc |
diff --git a/chrome/renderer/print_web_view_helper.cc b/chrome/renderer/print_web_view_helper.cc |
index 784fc1042bc478e36746cb5ea3cff2c192878de8..bf696b025e3f4ed73be680d68acdab9c2fb5ec51 100644 |
--- a/chrome/renderer/print_web_view_helper.cc |
+++ b/chrome/renderer/print_web_view_helper.cc |
@@ -428,9 +428,7 @@ PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint( |
WebNode* node) |
: frame_(frame), |
web_view_(frame->view()), |
- dpi_(static_cast<int>(print_params.dpi)), |
expected_pages_count_(0), |
- use_browser_overlays_(true), |
finished_(false) { |
gfx::Size canvas_size; |
CalculatePrintCanvasSize(print_params, &canvas_size); |
@@ -439,10 +437,12 @@ PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint( |
prev_scroll_offset_ = web_frame->scrollOffset(); |
prev_view_size_ = web_view_->size(); |
+ WebKit::WebNode node_to_print; |
if (node) |
- node_to_print_ = *node; |
+ node_to_print = *node; |
- StartPrinting(canvas_size); |
+ frame_->printBegin(node_to_print); |
+ StartPrinting(canvas_size, static_cast<int>(print_params.dpi)); |
} |
PrepareFrameAndViewForPrint::~PrepareFrameAndViewForPrint() { |
@@ -457,13 +457,17 @@ void PrepareFrameAndViewForPrint::UpdatePrintParams( |
if (canvas_size == print_canvas_size_) |
return; |
- frame_->printEnd(); |
- dpi_ = static_cast<int>(print_params.dpi); |
- StartPrinting(canvas_size); |
+ StartPrinting(canvas_size, static_cast<int>(print_params.dpi)); |
+} |
+ |
+bool PrepareFrameAndViewForPrint::ShouldUseBrowserOverlays() const |
+{ |
+ return frame_->shouldUseBrowserOverlays(); |
} |
void PrepareFrameAndViewForPrint::StartPrinting( |
- const gfx::Size& print_canvas_size) { |
+ const gfx::Size& print_canvas_size, |
+ int dpi) { |
print_canvas_size_ = print_canvas_size; |
// Layout page according to printer page size. Since WebKit shrinks the |
@@ -477,8 +481,8 @@ void PrepareFrameAndViewForPrint::StartPrinting( |
web_view_->resize(print_layout_size); |
- expected_pages_count_ = frame_->printBegin(print_canvas_size_, node_to_print_, |
- dpi_, &use_browser_overlays_); |
+ expected_pages_count_ = |
+ frame_->setPageSizeResolution(print_canvas_size_, dpi); |
} |
void PrepareFrameAndViewForPrint::FinishPrinting() { |
@@ -814,10 +818,6 @@ void PrintWebViewHelper::Print(WebKit::WebFrame* frame, WebKit::WebNode* node) { |
if (expected_page_count) |
use_browser_overlays = prepare->ShouldUseBrowserOverlays(); |
- // Release the prepare before going any further, since we are going to |
- // show UI and wait for the user. |
- prepare.reset(); |
vandebo (ex-Chrome)
2011/10/24 20:53:47
I think the reason this is done is not to make sur
dominicc (has gone to gerrit)
2011/10/25 04:44:39
Is that platform-specific, or specific to the new
Lei Zhang
2011/10/25 06:40:22
Unless you changed things in about:flags, in M15+
vandebo (ex-Chrome)
2011/10/25 17:03:11
As Lei noted, this code path is only used for the
|
- |
// Some full screen plugins can say they don't want to print. |
if (!expected_page_count) { |
DidFinishPrinting(OK); // Release resources and fail silently. |
@@ -832,7 +832,7 @@ void PrintWebViewHelper::Print(WebKit::WebFrame* frame, WebKit::WebNode* node) { |
} |
// Render Pages for printing. |
- if (!RenderPagesForPrint(frame, node, NULL)) { |
+ if (!RenderPagesForPrint(frame, node, prepare.get())) { |
Lei Zhang
2011/09/22 21:48:30
Not sure if this is right. If you use the |prepare
dominicc (has gone to gerrit)
2011/10/24 08:45:13
This code is quite twisty, but don’t the settings
|
LOG(ERROR) << "RenderPagesForPrint failed"; |
DidFinishPrinting(FAIL_PRINT); |
} |