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

Side by Side Diff: chrome/renderer/print_web_view_helper.cc

Issue 6142013: Allow printing/saving a plugin through right click menu, even if it's in a fr... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/print_web_view_helper.h ('k') | chrome/renderer/print_web_view_helper_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #include "chrome/renderer/print_web_view_helper.h" 5 #include "chrome/renderer/print_web_view_helper.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/process_util.h" 9 #include "base/process_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/common/render_messages.h" 11 #include "chrome/common/render_messages.h"
12 #include "chrome/common/render_messages_params.h" 12 #include "chrome/common/render_messages_params.h"
13 #include "chrome/renderer/render_view.h" 13 #include "chrome/renderer/render_view.h"
14 #include "grit/generated_resources.h" 14 #include "grit/generated_resources.h"
15 #include "printing/units.h" 15 #include "printing/units.h"
16 #include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h" 16 #include "third_party/WebKit/WebKit/chromium/public/WebConsoleMessage.h"
17 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h"
18 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h"
17 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" 19 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
20 #include "third_party/WebKit/WebKit/chromium/public/WebNode.h"
18 #include "third_party/WebKit/WebKit/chromium/public/WebRect.h" 21 #include "third_party/WebKit/WebKit/chromium/public/WebRect.h"
19 #include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h" 22 #include "third_party/WebKit/WebKit/chromium/public/WebScreenInfo.h"
20 #include "third_party/WebKit/WebKit/chromium/public/WebSize.h" 23 #include "third_party/WebKit/WebKit/chromium/public/WebSize.h"
21 #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" 24 #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h"
22 #include "third_party/WebKit/WebKit/chromium/public/WebView.h" 25 #include "third_party/WebKit/WebKit/chromium/public/WebView.h"
23 #include "webkit/glue/webkit_glue.h" 26 #include "webkit/glue/webkit_glue.h"
24 27
25 using printing::ConvertPixelsToPoint; 28 using printing::ConvertPixelsToPoint;
26 using printing::ConvertPixelsToPointDouble; 29 using printing::ConvertPixelsToPointDouble;
27 using printing::ConvertUnit; 30 using printing::ConvertUnit;
28 using printing::ConvertUnitDouble; 31 using printing::ConvertUnitDouble;
29 using WebKit::WebConsoleMessage; 32 using WebKit::WebConsoleMessage;
30 using WebKit::WebFrame; 33 using WebKit::WebFrame;
31 using WebKit::WebNode; 34 using WebKit::WebNode;
32 using WebKit::WebRect; 35 using WebKit::WebRect;
33 using WebKit::WebSize; 36 using WebKit::WebSize;
34 using WebKit::WebScreenInfo; 37 using WebKit::WebScreenInfo;
35 using WebKit::WebString; 38 using WebKit::WebString;
36 using WebKit::WebURLRequest; 39 using WebKit::WebURLRequest;
37 using WebKit::WebView; 40 using WebKit::WebView;
38 41
39 PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint( 42 PrepareFrameAndViewForPrint::PrepareFrameAndViewForPrint(
40 const ViewMsg_Print_Params& print_params, 43 const ViewMsg_Print_Params& print_params,
41 WebFrame* frame, 44 WebFrame* frame,
45 WebNode* node,
42 WebView* web_view) 46 WebView* web_view)
43 : frame_(frame), web_view_(web_view), expected_pages_count_(0), 47 : frame_(frame), web_view_(web_view), expected_pages_count_(0),
44 use_browser_overlays_(true) { 48 use_browser_overlays_(true) {
45 int dpi = static_cast<int>(print_params.dpi); 49 int dpi = static_cast<int>(print_params.dpi);
46 #if defined(OS_MACOSX) 50 #if defined(OS_MACOSX)
47 // On the Mac, the printable area is in points, don't do any scaling based 51 // On the Mac, the printable area is in points, don't do any scaling based
48 // on dpi. 52 // on dpi.
49 dpi = printing::kPointsPerInch; 53 dpi = printing::kPointsPerInch;
50 #endif // defined(OS_MACOSX) 54 #endif // defined(OS_MACOSX)
51 print_canvas_size_.set_width( 55 print_canvas_size_.set_width(
(...skipping 10 matching lines...) Expand all
62 // minimum (default) scaling. 66 // minimum (default) scaling.
63 // This is important for sites that try to fill the page. 67 // This is important for sites that try to fill the page.
64 gfx::Size print_layout_size(print_canvas_size_); 68 gfx::Size print_layout_size(print_canvas_size_);
65 print_layout_size.set_height(static_cast<int>( 69 print_layout_size.set_height(static_cast<int>(
66 static_cast<double>(print_layout_size.height()) * 1.25)); 70 static_cast<double>(print_layout_size.height()) * 1.25));
67 71
68 prev_view_size_ = web_view->size(); 72 prev_view_size_ = web_view->size();
69 73
70 web_view->resize(print_layout_size); 74 web_view->resize(print_layout_size);
71 75
72 #if defined(WEBFRAME_PRINTBEGIN_TAKES_NODE) 76 WebNode node_to_print;
77 if (node)
78 node_to_print = *node;
73 expected_pages_count_ = frame->printBegin( 79 expected_pages_count_ = frame->printBegin(
74 print_canvas_size_, WebNode(), static_cast<int>(print_params.dpi), 80 print_canvas_size_, node_to_print, static_cast<int>(print_params.dpi),
75 &use_browser_overlays_); 81 &use_browser_overlays_);
76 #else
77 expected_pages_count_ = frame->printBegin(
78 print_canvas_size_, static_cast<int>(print_params.dpi),
79 &use_browser_overlays_);
80 #endif
81 } 82 }
82 83
83 PrepareFrameAndViewForPrint::~PrepareFrameAndViewForPrint() { 84 PrepareFrameAndViewForPrint::~PrepareFrameAndViewForPrint() {
84 frame_->printEnd(); 85 frame_->printEnd();
85 web_view_->resize(prev_view_size_); 86 web_view_->resize(prev_view_size_);
86 } 87 }
87 88
88 89
89 PrintWebViewHelper::PrintWebViewHelper(RenderView* render_view) 90 PrintWebViewHelper::PrintWebViewHelper(RenderView* render_view)
90 : render_view_(render_view), 91 : render_view_(render_view),
91 print_web_view_(NULL), 92 print_web_view_(NULL),
92 user_cancelled_scripted_print_count_(0), 93 user_cancelled_scripted_print_count_(0),
93 is_preview_(false) {} 94 is_preview_(false) {}
94 95
95 PrintWebViewHelper::~PrintWebViewHelper() {} 96 PrintWebViewHelper::~PrintWebViewHelper() {}
96 97
97 void PrintWebViewHelper::Print(WebFrame* frame, 98 void PrintWebViewHelper::PrintFrame(WebFrame* frame,
99 bool script_initiated,
100 bool is_preview) {
101 Print(frame, NULL, script_initiated, is_preview);
102 }
103
104 void PrintWebViewHelper::PrintNode(WebNode* node,
105 bool script_initiated,
106 bool is_preview) {
107 Print(node->document().frame(), node, script_initiated, is_preview);
108 }
109
110 void PrintWebViewHelper::Print(WebKit::WebFrame* frame,
111 WebNode* node,
98 bool script_initiated, 112 bool script_initiated,
99 bool is_preview) { 113 bool is_preview) {
100 const int kMinSecondsToIgnoreJavascriptInitiatedPrint = 2; 114 const int kMinSecondsToIgnoreJavascriptInitiatedPrint = 2;
101 const int kMaxSecondsToIgnoreJavascriptInitiatedPrint = 2 * 60; // 2 Minutes. 115 const int kMaxSecondsToIgnoreJavascriptInitiatedPrint = 2 * 60; // 2 Minutes.
102 116
103 // If still not finished with earlier print request simply ignore. 117 // If still not finished with earlier print request simply ignore.
104 if (IsPrinting()) 118 if (IsPrinting())
105 return; 119 return;
106 120
107 // Check if there is script repeatedly trying to print and ignore it if too 121 // Check if there is script repeatedly trying to print and ignore it if too
(...skipping 14 matching lines...) Expand all
122 WebConsoleMessage::LevelWarning, 136 WebConsoleMessage::LevelWarning,
123 message)); 137 message));
124 return; 138 return;
125 } 139 }
126 } 140 }
127 141
128 bool print_cancelled = false; 142 bool print_cancelled = false;
129 is_preview_ = is_preview; 143 is_preview_ = is_preview;
130 144
131 // Initialize print settings. 145 // Initialize print settings.
132 if (!InitPrintSettings(frame)) 146 if (!InitPrintSettings(frame, node))
133 return; // Failed to init print page settings. 147 return; // Failed to init print page settings.
134 148
135 int expected_pages_count = 0; 149 int expected_pages_count = 0;
136 bool use_browser_overlays = true; 150 bool use_browser_overlays = true;
137 151
138 // Prepare once to calculate the estimated page count. This must be in 152 // Prepare once to calculate the estimated page count. This must be in
139 // a scope for itself (see comments on PrepareFrameAndViewForPrint). 153 // a scope for itself (see comments on PrepareFrameAndViewForPrint).
140 { 154 {
141 PrepareFrameAndViewForPrint prep_frame_view( 155 PrepareFrameAndViewForPrint prep_frame_view(
142 (*print_pages_params_).params, frame, frame->view()); 156 (*print_pages_params_).params, frame, node, frame->view());
143 expected_pages_count = prep_frame_view.GetExpectedPageCount(); 157 expected_pages_count = prep_frame_view.GetExpectedPageCount();
144 if (expected_pages_count) 158 if (expected_pages_count)
145 use_browser_overlays = prep_frame_view.ShouldUseBrowserOverlays(); 159 use_browser_overlays = prep_frame_view.ShouldUseBrowserOverlays();
146 } 160 }
147 161
148 // Some full screen plugins can say they don't want to print. 162 // Some full screen plugins can say they don't want to print.
149 if (expected_pages_count) { 163 if (expected_pages_count) {
150 if (!is_preview_) { 164 if (!is_preview_) {
151 // Ask the browser to show UI to retrieve the final print settings. 165 // Ask the browser to show UI to retrieve the final print settings.
152 if (!GetPrintSettingsFromUser(frame, expected_pages_count, 166 if (!GetPrintSettingsFromUser(frame, expected_pages_count,
153 use_browser_overlays)) { 167 use_browser_overlays)) {
154 print_cancelled = true; 168 print_cancelled = true;
155 } 169 }
156 } 170 }
157 171
158 // Render Pages for printing. 172 // Render Pages for printing.
159 if (!print_cancelled) { 173 if (!print_cancelled) {
160 if (is_preview_) 174 if (is_preview_)
161 RenderPagesForPreview(frame); 175 RenderPagesForPreview(frame);
162 else 176 else
163 RenderPagesForPrint(frame); 177 RenderPagesForPrint(frame, node);
164 178
165 // Reset cancel counter on first successful print. 179 // Reset cancel counter on first successful print.
166 user_cancelled_scripted_print_count_ = 0; 180 user_cancelled_scripted_print_count_ = 0;
167 return; // All went well. 181 return; // All went well.
168 } else { 182 } else {
169 if (script_initiated) { 183 if (script_initiated) {
170 ++user_cancelled_scripted_print_count_; 184 ++user_cancelled_scripted_print_count_;
171 last_cancelled_script_print_ = base::Time::Now(); 185 last_cancelled_script_print_ = base::Time::Now();
172 } 186 }
173 } 187 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 236
223 // When loading is done this will call DidStopLoading that will do the 237 // When loading is done this will call DidStopLoading that will do the
224 // actual printing. 238 // actual printing.
225 print_web_view_->mainFrame()->loadRequest(WebURLRequest(url)); 239 print_web_view_->mainFrame()->loadRequest(WebURLRequest(url));
226 240
227 return true; 241 return true;
228 } 242 }
229 243
230 #if defined(OS_MACOSX) || defined(OS_WIN) 244 #if defined(OS_MACOSX) || defined(OS_WIN)
231 void PrintWebViewHelper::PrintPages(const ViewMsg_PrintPages_Params& params, 245 void PrintWebViewHelper::PrintPages(const ViewMsg_PrintPages_Params& params,
232 WebFrame* frame) { 246 WebFrame* frame,
247 WebNode* node) {
233 ViewMsg_Print_Params printParams = params.params; 248 ViewMsg_Print_Params printParams = params.params;
234 UpdatePrintableSizeInPrintParameters(frame, &printParams); 249 UpdatePrintableSizeInPrintParameters(frame, node, &printParams);
235 250
236 PrepareFrameAndViewForPrint prep_frame_view(printParams, 251 PrepareFrameAndViewForPrint prep_frame_view(printParams,
237 frame, 252 frame,
253 node,
238 frame->view()); 254 frame->view());
239 int page_count = prep_frame_view.GetExpectedPageCount(); 255 int page_count = prep_frame_view.GetExpectedPageCount();
240 256
241 Send(new ViewHostMsg_DidGetPrintedPagesCount(routing_id(), 257 Send(new ViewHostMsg_DidGetPrintedPagesCount(routing_id(),
242 printParams.document_cookie, 258 printParams.document_cookie,
243 page_count)); 259 page_count));
244 if (!page_count) 260 if (!page_count)
245 return; 261 return;
246 262
247 const gfx::Size& canvas_size = prep_frame_view.GetPrintCanvasSize(); 263 const gfx::Size& canvas_size = prep_frame_view.GetPrintCanvasSize();
(...skipping 18 matching lines...) Expand all
266 bool PrintWebViewHelper::Send(IPC::Message* msg) { 282 bool PrintWebViewHelper::Send(IPC::Message* msg) {
267 return render_view_->Send(msg); 283 return render_view_->Send(msg);
268 } 284 }
269 285
270 int32 PrintWebViewHelper::routing_id() { 286 int32 PrintWebViewHelper::routing_id() {
271 return render_view_->routing_id(); 287 return render_view_->routing_id();
272 } 288 }
273 289
274 void PrintWebViewHelper::didStopLoading() { 290 void PrintWebViewHelper::didStopLoading() {
275 DCHECK(print_pages_params_.get() != NULL); 291 DCHECK(print_pages_params_.get() != NULL);
276 PrintPages(*print_pages_params_.get(), print_web_view_->mainFrame()); 292 PrintPages(*print_pages_params_.get(), print_web_view_->mainFrame(), NULL);
277 } 293 }
278 294
279 void PrintWebViewHelper::GetPageSizeAndMarginsInPoints( 295 void PrintWebViewHelper::GetPageSizeAndMarginsInPoints(
280 WebFrame* frame, 296 WebFrame* frame,
281 int page_index, 297 int page_index,
282 const ViewMsg_Print_Params& default_params, 298 const ViewMsg_Print_Params& default_params,
283 double* content_width_in_points, 299 double* content_width_in_points,
284 double* content_height_in_points, 300 double* content_height_in_points,
285 double* margin_top_in_points, 301 double* margin_top_in_points,
286 double* margin_right_in_points, 302 double* margin_right_in_points,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 ConvertPixelsToPointDouble(margin_right_in_pixels); 367 ConvertPixelsToPointDouble(margin_right_in_pixels);
352 if (margin_bottom_in_points) 368 if (margin_bottom_in_points)
353 *margin_bottom_in_points = 369 *margin_bottom_in_points =
354 ConvertPixelsToPointDouble(margin_bottom_in_pixels); 370 ConvertPixelsToPointDouble(margin_bottom_in_pixels);
355 if (margin_left_in_points) 371 if (margin_left_in_points)
356 *margin_left_in_points = 372 *margin_left_in_points =
357 ConvertPixelsToPointDouble(margin_left_in_pixels); 373 ConvertPixelsToPointDouble(margin_left_in_pixels);
358 } 374 }
359 375
360 void PrintWebViewHelper::UpdatePrintableSizeInPrintParameters( 376 void PrintWebViewHelper::UpdatePrintableSizeInPrintParameters(
361 WebFrame* frame, ViewMsg_Print_Params* params) { 377 WebFrame* frame,
378 WebNode* node,
379 ViewMsg_Print_Params* params) {
362 double content_width_in_points; 380 double content_width_in_points;
363 double content_height_in_points; 381 double content_height_in_points;
364 double margin_top_in_points; 382 double margin_top_in_points;
365 double margin_right_in_points; 383 double margin_right_in_points;
366 double margin_bottom_in_points; 384 double margin_bottom_in_points;
367 double margin_left_in_points; 385 double margin_left_in_points;
368 PrepareFrameAndViewForPrint prepare(*params, frame, frame->view()); 386 PrepareFrameAndViewForPrint prepare(*params, frame, node, frame->view());
369 PrintWebViewHelper::GetPageSizeAndMarginsInPoints(frame, 0, *params, 387 PrintWebViewHelper::GetPageSizeAndMarginsInPoints(frame, 0, *params,
370 &content_width_in_points, &content_height_in_points, 388 &content_width_in_points, &content_height_in_points,
371 &margin_top_in_points, &margin_right_in_points, 389 &margin_top_in_points, &margin_right_in_points,
372 &margin_bottom_in_points, &margin_left_in_points); 390 &margin_bottom_in_points, &margin_left_in_points);
373 #if defined(OS_MACOSX) 391 #if defined(OS_MACOSX)
374 // On the Mac, the printable area is in points, don't do any scaling based 392 // On the Mac, the printable area is in points, don't do any scaling based
375 // on dpi. 393 // on dpi.
376 int dpi = printing::kPointsPerInch; 394 int dpi = printing::kPointsPerInch;
377 #else 395 #else
378 int dpi = static_cast<int>(params->dpi); 396 int dpi = static_cast<int>(params->dpi);
(...skipping 11 matching lines...) Expand all
390 static_cast<int>(ConvertUnitDouble(content_height_in_points + 408 static_cast<int>(ConvertUnitDouble(content_height_in_points +
391 margin_top_in_points + margin_bottom_in_points, 409 margin_top_in_points + margin_bottom_in_points,
392 printing::kPointsPerInch, dpi))); 410 printing::kPointsPerInch, dpi)));
393 411
394 params->margin_top = static_cast<int>(ConvertUnitDouble( 412 params->margin_top = static_cast<int>(ConvertUnitDouble(
395 margin_top_in_points, printing::kPointsPerInch, dpi)); 413 margin_top_in_points, printing::kPointsPerInch, dpi));
396 params->margin_left = static_cast<int>(ConvertUnitDouble( 414 params->margin_left = static_cast<int>(ConvertUnitDouble(
397 margin_left_in_points, printing::kPointsPerInch, dpi)); 415 margin_left_in_points, printing::kPointsPerInch, dpi));
398 } 416 }
399 417
400 bool PrintWebViewHelper::InitPrintSettings(WebFrame* frame) { 418 bool PrintWebViewHelper::InitPrintSettings(WebFrame* frame,
419 WebNode* node) {
401 ViewMsg_PrintPages_Params settings; 420 ViewMsg_PrintPages_Params settings;
402 if (GetDefaultPrintSettings(frame, &settings.params)) { 421 if (GetDefaultPrintSettings(frame, node, &settings.params)) {
403 print_pages_params_.reset(new ViewMsg_PrintPages_Params(settings)); 422 print_pages_params_.reset(new ViewMsg_PrintPages_Params(settings));
404 print_pages_params_->pages.clear(); 423 print_pages_params_->pages.clear();
405 return true; 424 return true;
406 } 425 }
407 return false; 426 return false;
408 } 427 }
409 428
410 bool PrintWebViewHelper::GetDefaultPrintSettings( 429 bool PrintWebViewHelper::GetDefaultPrintSettings(
411 WebFrame* frame, ViewMsg_Print_Params* params) { 430 WebFrame* frame,
431 WebNode* node,
432 ViewMsg_Print_Params* params) {
412 IPC::SyncMessage* msg = 433 IPC::SyncMessage* msg =
413 new ViewHostMsg_GetDefaultPrintSettings(routing_id(), params); 434 new ViewHostMsg_GetDefaultPrintSettings(routing_id(), params);
414 if (!Send(msg)) { 435 if (!Send(msg)) {
415 NOTREACHED(); 436 NOTREACHED();
416 return false; 437 return false;
417 } 438 }
418 // Check if the printer returned any settings, if the settings is empty, we 439 // Check if the printer returned any settings, if the settings is empty, we
419 // can safely assume there are no printer drivers configured. So we safely 440 // can safely assume there are no printer drivers configured. So we safely
420 // terminate. 441 // terminate.
421 if (params->IsEmpty()) { 442 if (params->IsEmpty()) {
422 render_view_->runModalAlertDialog( 443 render_view_->runModalAlertDialog(
423 frame, 444 frame,
424 l10n_util::GetStringUTF16(IDS_DEFAULT_PRINTER_NOT_FOUND_WARNING)); 445 l10n_util::GetStringUTF16(IDS_DEFAULT_PRINTER_NOT_FOUND_WARNING));
425 return false; 446 return false;
426 } 447 }
427 if (!(params->dpi && params->document_cookie)) { 448 if (!(params->dpi && params->document_cookie)) {
428 // Invalid print page settings. 449 // Invalid print page settings.
429 NOTREACHED(); 450 NOTREACHED();
430 return false; 451 return false;
431 } 452 }
432 UpdatePrintableSizeInPrintParameters(frame, params); 453 UpdatePrintableSizeInPrintParameters(frame, node, params);
433 return true; 454 return true;
434 } 455 }
435 456
436 bool PrintWebViewHelper::GetPrintSettingsFromUser(WebFrame* frame, 457 bool PrintWebViewHelper::GetPrintSettingsFromUser(WebFrame* frame,
437 int expected_pages_count, 458 int expected_pages_count,
438 bool use_browser_overlays) { 459 bool use_browser_overlays) {
439 ViewHostMsg_ScriptedPrint_Params params; 460 ViewHostMsg_ScriptedPrint_Params params;
440 ViewMsg_PrintPages_Params print_settings; 461 ViewMsg_PrintPages_Params print_settings;
441 462
442 // The routing id is sent across as it is needed to look up the 463 // The routing id is sent across as it is needed to look up the
(...skipping 16 matching lines...) Expand all
459 if (Send(msg)) { 480 if (Send(msg)) {
460 print_pages_params_.reset(new ViewMsg_PrintPages_Params(print_settings)); 481 print_pages_params_.reset(new ViewMsg_PrintPages_Params(print_settings));
461 } else { 482 } else {
462 // Send() failed. 483 // Send() failed.
463 NOTREACHED(); 484 NOTREACHED();
464 return false; 485 return false;
465 } 486 }
466 return (print_settings.params.dpi && print_settings.params.document_cookie); 487 return (print_settings.params.dpi && print_settings.params.document_cookie);
467 } 488 }
468 489
469 void PrintWebViewHelper::RenderPagesForPrint(WebFrame *frame) { 490 void PrintWebViewHelper::RenderPagesForPrint(WebFrame* frame,
491 WebNode* node) {
470 ViewMsg_PrintPages_Params print_settings = *print_pages_params_; 492 ViewMsg_PrintPages_Params print_settings = *print_pages_params_;
471 if (print_settings.params.selection_only) { 493 if (print_settings.params.selection_only) {
472 CopyAndPrint(frame); 494 CopyAndPrint(frame);
473 } else { 495 } else {
474 // TODO: Always copy before printing. 496 // TODO: Always copy before printing.
475 PrintPages(print_settings, frame); 497 PrintPages(print_settings, frame, node);
476 } 498 }
477 } 499 }
478 500
479 void PrintWebViewHelper::RenderPagesForPreview(WebFrame *frame) { 501 void PrintWebViewHelper::RenderPagesForPreview(WebFrame *frame) {
480 ViewMsg_PrintPages_Params print_settings = *print_pages_params_; 502 ViewMsg_PrintPages_Params print_settings = *print_pages_params_;
481 ViewHostMsg_DidPreviewDocument_Params print_params; 503 ViewHostMsg_DidPreviewDocument_Params print_params;
482 CreatePreviewDocument(print_settings, frame, &print_params); 504 CreatePreviewDocument(print_settings, frame, &print_params);
483 Send(new ViewHostMsg_PagesReadyForPreview(routing_id(), print_params)); 505 Send(new ViewHostMsg_PagesReadyForPreview(routing_id(), print_params));
484 } 506 }
485 507
(...skipping 21 matching lines...) Expand all
507 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(), 529 shared_buf.GiveToProcess(base::GetCurrentProcessHandle(),
508 shared_mem_handle); 530 shared_mem_handle);
509 return true; 531 return true;
510 } 532 }
511 } 533 }
512 } 534 }
513 NOTREACHED(); 535 NOTREACHED();
514 return false; 536 return false;
515 } 537 }
516 #endif 538 #endif
OLDNEW
« no previous file with comments | « chrome/renderer/print_web_view_helper.h ('k') | chrome/renderer/print_web_view_helper_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698