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

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

Issue 467343003: Defer request to print a PDF when the user initiates the entire frame and the PDF hasn't loaded. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
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..9e40a06db37474ef7017e85c5c8c0491b09cf807 100644
--- a/chrome/renderer/printing/print_web_view_helper.cc
+++ b/chrome/renderer/printing/print_web_view_helper.cc
@@ -791,7 +791,8 @@ PrintWebViewHelper::PrintWebViewHelper(content::RenderView* render_view)
print_node_in_progress_(false),
is_loading_(false),
is_scripted_preview_delayed_(false),
- weak_ptr_factory_(this) {
+ weak_ptr_factory_(this),
+ on_stop_loading_type_(PRINT_PREVIEW_SCRIPTED) {
}
PrintWebViewHelper::~PrintWebViewHelper() {}
@@ -820,7 +821,18 @@ void PrintWebViewHelper::DidStartLoading() {
void PrintWebViewHelper::DidStopLoading() {
is_loading_ = false;
- ShowScriptedPrintPreview();
+
+ // |on_stop_loading_type_| should be reset to the default value
+ // PRINT_PREVIEW_SCRIPTED after is its equal to
+ // PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME because the race condition has
+ // been handled.
+ if (on_stop_loading_type_ == PRINT_PREVIEW_SCRIPTED) {
+ ShowScriptedPrintPreview();
+ } else if (on_stop_loading_type_ ==
+ PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME) {
+ RequestPrintPreview(on_stop_loading_type_);
+ on_stop_loading_type_ = PRINT_PREVIEW_SCRIPTED;
+ }
}
// Prints |frame| which called window.print().
@@ -1725,6 +1737,14 @@ void PrintWebViewHelper::RequestPrintPreview(PrintPreviewRequestType type) {
return;
}
case PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME: {
ivandavid 2014/08/13 20:58:55 This is the only case where we should handle the r
Vitaly Buka (NO REVIEWS) 2014/08/13 23:39:45 No, it is not. Try to 1. open huge pdf (for exam
ivandavid 2014/08/14 03:38:13 Done.
ivandavid 2014/08/14 03:38:13 Oh OK. I figured why the PRINT_PREVIEW_USER_INITIA
+ // Handles case where this function has been called, but DidStopLoading()
+ // hasn't been called yet. RequestPrintPreview() will be called again, at
+ // the end of DidStopLoading() with the same value for |type|.
+ if (is_loading_ && GetPlugin(print_preview_context_.source_frame())) {
+ on_stop_loading_type_ = PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME;
+ return;
+ }
+
break;
}
case PRINT_PREVIEW_USER_INITIATED_SELECTION: {

Powered by Google App Engine
This is Rietveld 408576698