Skip to content

Commit

Permalink
Merge DidStartLoading/DidStopLoading imbalance patch to OOP PDF
Browse files Browse the repository at this point in the history
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
  • Loading branch information
raymes@chromium.org committed Jun 13, 2014
1 parent 244722b commit 993c388
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
37 changes: 23 additions & 14 deletions pdf/out_of_process_instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 =
Expand Down
5 changes: 5 additions & 0 deletions pdf/out_of_process_instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<pp::CompletionCallbackWithOutput<pp::Var> > password_callback_;
};
Expand Down

0 comments on commit 993c388

Please sign in to comment.