Chromium Code Reviews| Index: chrome/renderer/printing/print_web_view_helper.cc |
| diff --git a/chrome/renderer/printing/print_web_view_helper.cc b/chrome/renderer/printing/print_web_view_helper.cc |
| index e4129eef490197b6e61ea78d3e06f191c558d3cd..f5c34c58844ac8d2def63a721f68a32b1e6e62e9 100644 |
| --- a/chrome/renderer/printing/print_web_view_helper.cc |
| +++ b/chrome/renderer/printing/print_web_view_helper.cc |
| @@ -820,7 +820,8 @@ void PrintWebViewHelper::DidStartLoading() { |
| void PrintWebViewHelper::DidStopLoading() { |
| is_loading_ = false; |
| - ShowScriptedPrintPreview(); |
| + if (!on_stop_loading_closure_.is_null()) |
|
Vitaly Buka (NO REVIEWS)
2014/08/14 05:19:43
on_stop_loading_closure_.reset() after run
ivandavid
2014/08/15 00:35:23
Done.
|
| + on_stop_loading_closure_.Run(); |
| } |
| // Prints |frame| which called window.print(). |
| @@ -1699,6 +1700,7 @@ void PrintWebViewHelper::RequestPrintPreview(PrintPreviewRequestType type) { |
| PrintHostMsg_RequestPrintPreview_Params params; |
| params.is_modifiable = is_modifiable; |
| params.has_selection = has_selection; |
| + DCHECK(!GetPlugin(print_preview_context_.source_frame())); |
|
Vitaly Buka (NO REVIEWS)
2014/08/14 05:19:43
this DCHECK makes no sense
if it was correct, all
ivandavid
2014/08/15 00:35:23
Done.
|
| switch (type) { |
| case PRINT_PREVIEW_SCRIPTED: { |
| // Shows scripted print preview in two stages. |
| @@ -1711,6 +1713,9 @@ void PrintWebViewHelper::RequestPrintPreview(PrintPreviewRequestType type) { |
| // Wait for DidStopLoading. Plugins may not know the correct |
| // |is_modifiable| value until they are fully loaded, which occurs when |
| // DidStopLoading() is called. Defer showing the preview until then. |
| + on_stop_loading_closure_ = |
| + base::Bind(&PrintWebViewHelper::ShowScriptedPrintPreview, |
| + base::Unretained(this)); |
| } else { |
| base::MessageLoop::current()->PostTask( |
| FROM_HERE, |
| @@ -1725,6 +1730,17 @@ void PrintWebViewHelper::RequestPrintPreview(PrintPreviewRequestType type) { |
| return; |
| } |
| case PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME: { |
| + // Wait for DidStopLoading. Continuing with this function while |
| + // |is_loading_| is true will cause print preview to hang when try to |
| + // print a PDF document. |
| + if (is_loading_ && GetPlugin(print_preview_context_.source_frame())) { |
| + on_stop_loading_closure_ = |
| + base::Bind(&PrintWebViewHelper::RequestPrintPreview, |
| + base::Unretained(this), |
| + type); |
| + return; |
| + } |
| + |
| break; |
| } |
| case PRINT_PREVIEW_USER_INITIATED_SELECTION: { |
| @@ -1733,6 +1749,15 @@ void PrintWebViewHelper::RequestPrintPreview(PrintPreviewRequestType type) { |
| break; |
| } |
| case PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE: { |
| + // Same situation as in PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME. |
| + if (is_loading_ && GetPlugin(print_preview_context_.source_frame())) { |
| + on_stop_loading_closure_ = |
| + base::Bind(&PrintWebViewHelper::RequestPrintPreview, |
| + base::Unretained(this), |
| + type); |
| + return; |
| + } |
| + |
| params.webnode_only = true; |
| break; |
| } |