| 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..5e1328f2ab0bb6fc846b9c6fc9333530c264119b 100644
|
| --- a/chrome/renderer/printing/print_web_view_helper.cc
|
| +++ b/chrome/renderer/printing/print_web_view_helper.cc
|
| @@ -820,7 +820,10 @@ void PrintWebViewHelper::DidStartLoading() {
|
|
|
| void PrintWebViewHelper::DidStopLoading() {
|
| is_loading_ = false;
|
| - ShowScriptedPrintPreview();
|
| + if (!on_stop_loading_closure_.is_null()) {
|
| + on_stop_loading_closure_.Run();
|
| + on_stop_loading_closure_.Reset();
|
| + }
|
| }
|
|
|
| // Prints |frame| which called window.print().
|
| @@ -1711,6 +1714,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,14 +1731,34 @@ 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: {
|
| DCHECK(has_selection);
|
| + DCHECK(!GetPlugin(print_preview_context_.source_frame()));
|
| params.selection_only = has_selection;
|
| break;
|
| }
|
| case PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE: {
|
| + 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;
|
| }
|
|
|