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

Side by Side 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: Moved |request_print_preview_closure_| into the switch statement. 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 unified diff | Download patch
« no previous file with comments | « chrome/renderer/printing/print_web_view_helper.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/printing/print_web_view_helper.h" 5 #include "chrome/renderer/printing/print_web_view_helper.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after
813 return !IsScriptInitiatedPrintTooFrequent(frame); 813 return !IsScriptInitiatedPrintTooFrequent(frame);
814 return true; 814 return true;
815 } 815 }
816 816
817 void PrintWebViewHelper::DidStartLoading() { 817 void PrintWebViewHelper::DidStartLoading() {
818 is_loading_ = true; 818 is_loading_ = true;
819 } 819 }
820 820
821 void PrintWebViewHelper::DidStopLoading() { 821 void PrintWebViewHelper::DidStopLoading() {
822 is_loading_ = false; 822 is_loading_ = false;
823 ShowScriptedPrintPreview(); 823 if (request_print_preview_closure_.is_null()) {
824 ShowScriptedPrintPreview();
Vitaly Buka (NO REVIEWS) 2014/08/05 06:05:06 please remove ShowScriptedPrintPreview() from here
ivandavid 2014/08/05 19:30:17 Done.
825 } else {
826 request_print_preview_closure_.Run();
827 request_print_preview_closure_.Reset();
828 }
824 } 829 }
825 830
826 // Prints |frame| which called window.print(). 831 // Prints |frame| which called window.print().
827 void PrintWebViewHelper::PrintPage(blink::WebLocalFrame* frame, 832 void PrintWebViewHelper::PrintPage(blink::WebLocalFrame* frame,
828 bool user_initiated) { 833 bool user_initiated) {
829 DCHECK(frame); 834 DCHECK(frame);
830 835
831 // Allow Prerendering to cancel this print request if necessary. 836 // Allow Prerendering to cancel this print request if necessary.
832 if (prerender::PrerenderHelper::IsPrerendering( 837 if (prerender::PrerenderHelper::IsPrerendering(
833 render_view()->GetMainRenderFrame())) { 838 render_view()->GetMainRenderFrame())) {
(...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after
1717 base::Bind(&PrintWebViewHelper::ShowScriptedPrintPreview, 1722 base::Bind(&PrintWebViewHelper::ShowScriptedPrintPreview,
1718 weak_ptr_factory_.GetWeakPtr())); 1723 weak_ptr_factory_.GetWeakPtr()));
1719 } 1724 }
1720 IPC::SyncMessage* msg = 1725 IPC::SyncMessage* msg =
1721 new PrintHostMsg_SetupScriptedPrintPreview(routing_id()); 1726 new PrintHostMsg_SetupScriptedPrintPreview(routing_id());
1722 msg->EnableMessagePumping(); 1727 msg->EnableMessagePumping();
1723 Send(msg); 1728 Send(msg);
1724 is_scripted_preview_delayed_ = false; 1729 is_scripted_preview_delayed_ = false;
1725 return; 1730 return;
1726 } 1731 }
1727 case PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME: { 1732 case PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME: {
ivandavid 2014/07/29 20:02:51 I encountered a similar problem to the one describ
Vitaly Buka (NO REVIEWS) 2014/08/05 05:49:57 My understanding is that it's by design. is_loadin
ivandavid 2014/08/05 19:30:17 Done.
1733 // If |is_loading_| is true and the function proceeds, Print Preview will
1734 // hang. Save |type| and call this function when DidStopLoading() is
1735 // called, ie. right when |is_loading_| is set to false.
1736 if (is_loading_) {
1737 request_print_preview_closure_ =
1738 base::Bind(&PrintWebViewHelper::RequestPrintPreview,
1739 base::Unretained(this),
1740 type);
1741 return;
1742 }
1743
1728 break; 1744 break;
1729 } 1745 }
1730 case PRINT_PREVIEW_USER_INITIATED_SELECTION: { 1746 case PRINT_PREVIEW_USER_INITIATED_SELECTION: {
1731 DCHECK(has_selection); 1747 DCHECK(has_selection);
1732 params.selection_only = has_selection; 1748 params.selection_only = has_selection;
1733 break; 1749 break;
1734 } 1750 }
1735 case PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE: { 1751 case PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE: {
1736 params.webnode_only = true; 1752 params.webnode_only = true;
1737 break; 1753 break;
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
2031 } 2047 }
2032 2048
2033 void PrintWebViewHelper::PrintPreviewContext::ClearContext() { 2049 void PrintWebViewHelper::PrintPreviewContext::ClearContext() {
2034 prep_frame_view_.reset(); 2050 prep_frame_view_.reset();
2035 metafile_.reset(); 2051 metafile_.reset();
2036 pages_to_render_.clear(); 2052 pages_to_render_.clear();
2037 error_ = PREVIEW_ERROR_NONE; 2053 error_ = PREVIEW_ERROR_NONE;
2038 } 2054 }
2039 2055
2040 } // namespace printing 2056 } // namespace printing
OLDNEW
« 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