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

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: Removed NOTREACHED() in DidStopLoading(), moved the first bind statement and added another. 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..420af085b49e22e4ce52dba80ff340694989117b 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())
+ on_stop_loading_closure_.Run();
}
// Prints |frame| which called window.print().
@@ -1711,6 +1712,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 +1729,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 +1748,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;
}
« 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