From 993c38816404ba88b532bbaef4aaf232cdcf1dea Mon Sep 17 00:00:00 2001 From: "raymes@chromium.org" Date: Fri, 13 Jun 2014 07:14:45 +0000 Subject: [PATCH] Merge DidStartLoading/DidStopLoading imbalance patch to OOP PDF This merges this CL https://chromereviews.googleplex.com/32997013/ to OOP PDF and also corrects some minor differences that had arisen in document loading. BUG=303491 Review URL: https://codereview.chromium.org/333553003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276954 0039d316-1c4b-4281-b951-d872f2087c98 --- pdf/out_of_process_instance.cc | 37 +++++++++++++++++++++++-------------- pdf/out_of_process_instance.h | 5 +++++ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/pdf/out_of_process_instance.cc b/pdf/out_of_process_instance.cc index 49b14ee1c9e9..8a692c9bc626 100644 --- a/pdf/out_of_process_instance.cc +++ b/pdf/out_of_process_instance.cc @@ -243,7 +243,8 @@ OutOfProcessInstance::OutOfProcessInstance(PP_Instance instance) print_preview_page_count_(0), last_progress_sent_(0), recently_sent_find_update_(false), - received_viewport_message_(false) { + received_viewport_message_(false), + did_call_start_loading_(false) { loader_factory_.Initialize(this); timer_factory_.Initialize(this); form_factory_.Initialize(this); @@ -1002,6 +1003,19 @@ std::string OutOfProcessInstance::ShowFileSelectionDialog() { } pp::URLLoader OutOfProcessInstance::CreateURLLoader() { + if (full_) { + if (!did_call_start_loading_) { + did_call_start_loading_ = true; + pp::PDF::DidStartLoading(this); + } + + // Disable save and print until the document is fully loaded, since they + // would generate an incomplete document. Need to do this each time we + // call DidStartLoading since that resets the content restrictions. + pp::PDF::SetContentRestriction(this, CONTENT_RESTRICTION_SAVE | + CONTENT_RESTRICTION_PRINT); + } + return CreateURLLoaderInternal(); } @@ -1065,7 +1079,10 @@ void OutOfProcessInstance::DocumentLoadComplete(int page_count) { if (!full_) return; - pp::PDF::DidStopLoading(this); + if (did_call_start_loading_) { + pp::PDF::DidStopLoading(this); + did_call_start_loading_ = false; + } int content_restrictions = CONTENT_RESTRICTION_CUT | CONTENT_RESTRICTION_PASTE; @@ -1119,10 +1136,12 @@ void OutOfProcessInstance::DocumentLoadFailed() { DCHECK(document_load_state_ == LOAD_STATE_LOADING); UserMetricsRecordAction("PDF.LoadFailure"); - if (full_) + if (did_call_start_loading_) { pp::PDF::DidStopLoading(this); - document_load_state_ = LOAD_STATE_FAILED; + did_call_start_loading_ = false; + } + document_load_state_ = LOAD_STATE_FAILED; paint_manager_.InvalidateRect(pp::Rect(pp::Point(), plugin_size_)); // Send a progress value of -1 to indicate a failure. @@ -1263,16 +1282,6 @@ void OutOfProcessInstance::LoadUrlInternal( } pp::URLLoader OutOfProcessInstance::CreateURLLoaderInternal() { - if (full_) { - pp::PDF::DidStartLoading(this); - - // Disable save and print until the document is fully loaded, since they - // would generate an incomplete document. Need to do this each time we - // call DidStartLoading since that resets the content restrictions. - pp::PDF::SetContentRestriction(this, CONTENT_RESTRICTION_SAVE | - CONTENT_RESTRICTION_PRINT); - } - pp::URLLoader loader(this); const PPB_URLLoaderTrusted* trusted_interface = diff --git a/pdf/out_of_process_instance.h b/pdf/out_of_process_instance.h index ada259fd65c9..bd70be2c4ed7 100644 --- a/pdf/out_of_process_instance.h +++ b/pdf/out_of_process_instance.h @@ -328,6 +328,11 @@ class OutOfProcessInstance : public pp::Instance, // be painted until this is received. bool received_viewport_message_; + // If true, this means we told the RenderView that we're starting a network + // request so that it can start the throbber. We will tell it again once the + // document finishes loading. + bool did_call_start_loading_; + // The callback for receiving the password from the page. scoped_ptr > password_callback_; }; -- 2.11.4.GIT