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

Unified Diff: chrome/renderer/printing/print_web_view_helper.cc

Issue 427723004: Fix for race condition where print preview hangs when attempting to print a PDF that hasn't loaded. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renamed closure. |on_stop_loading_closure_| now also calls ShowScriptedPrintPreview. Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/printing/print_web_view_helper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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: {
« no previous file with comments | « chrome/renderer/printing/print_web_view_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698