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 777eb69fa183c52236578b34969c60e803511b5e..3a094ab0b6e79745dbb936afa31e32af48355fd0 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(); |
+ else |
+ NOTREACHED(); |
Vitaly Buka (NO REVIEWS)
2014/08/06 08:53:57
NOTREACHED is incorrect here. DidStopLoading is go
ivandavid
2014/08/06 19:00:17
Done.
|
} |
// Prints |frame| which called window.print(). |
@@ -1699,6 +1702,10 @@ void PrintWebViewHelper::RequestPrintPreview(PrintPreviewRequestType type) { |
PrintHostMsg_RequestPrintPreview_Params params; |
params.is_modifiable = is_modifiable; |
params.has_selection = has_selection; |
+ on_stop_loading_closure_ = |
Vitaly Buka (NO REVIEWS)
2014/08/06 08:53:57
this piece should be on line 1718
ivandavid
2014/08/06 19:00:17
Ok. I put it after the comment.
ivandavid
2014/08/06 19:00:17
Done.
|
+ base::Bind(&PrintWebViewHelper::ShowScriptedPrintPreview, |
+ base::Unretained(this)); |
+ |
switch (type) { |
case PRINT_PREVIEW_SCRIPTED: { |
// Shows scripted print preview in two stages. |
@@ -1725,6 +1732,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())) { |
Vitaly Buka (NO REVIEWS)
2014/08/06 08:53:57
Same is needed for PRINT_PREVIEW_USER_INITIATED_CO
ivandavid
2014/08/06 19:00:16
Done.
ivandavid
2014/08/06 19:00:16
Is it supposed to bind RequestPrintPreview() or Sh
Vitaly Buka (NO REVIEWS)
2014/08/06 21:00:36
Yes, it should be RequestPrintPreview. Bind of Req
|
+ on_stop_loading_closure_ = |
+ base::Bind(&PrintWebViewHelper::RequestPrintPreview, |
+ base::Unretained(this), |
+ type); |
+ return; |
+ } |
+ |
break; |
} |
case PRINT_PREVIEW_USER_INITIATED_SELECTION: { |