Commit 2cde9751 authored by japhet@chromium.org's avatar japhet@chromium.org

Ensure pdf plugin sends DidStartLoading() consistently

There are situations where the pdf plugin will initialize itself in such a way
that it never notifies content/renderer/ that it has started. In so doing, it
also fails to send a stop message, since it tries to ensure it doesn't send
mismatched start/stop messages.

Print preview decides when to display the preview based on when loading
stops. Since this only considers the page's content and not the pdf plugin's
initialization, there is a race condition where we may try to preview before
the plugin is ready. In this cases, we show "Loading preivew..." and never load
the actual preview.

There is a hack in place in print_preview_web_helper.cc to delay the process of
showing the preview to maximize the chance that the pdf plugin will be ready.
This change should allow us to rip that out.

BUG=376969

Review URL: https://codereview.chromium.org/397713005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@283837 0039d316-1c4b-4281-b951-d872f2087c98
parent ab5fd2fd
...@@ -1703,13 +1703,10 @@ void PrintWebViewHelper::RequestPrintPreview(PrintPreviewRequestType type) { ...@@ -1703,13 +1703,10 @@ void PrintWebViewHelper::RequestPrintPreview(PrintPreviewRequestType type) {
// |is_modifiable| value until they are fully loaded, which occurs when // |is_modifiable| value until they are fully loaded, which occurs when
// DidStopLoading() is called. Defer showing the preview until then. // DidStopLoading() is called. Defer showing the preview until then.
} else { } else {
// TODO(japhet): This delay is a terrible hack. See crbug.com/376969 base::MessageLoop::current()->PostTask(
// for the motivation.
base::MessageLoop::current()->PostDelayedTask(
FROM_HERE, FROM_HERE,
base::Bind(&PrintWebViewHelper::ShowScriptedPrintPreview, base::Bind(&PrintWebViewHelper::ShowScriptedPrintPreview,
weak_ptr_factory_.GetWeakPtr()), weak_ptr_factory_.GetWeakPtr()));
base::TimeDelta::FromMilliseconds(100));
} }
IPC::SyncMessage* msg = IPC::SyncMessage* msg =
new PrintHostMsg_SetupScriptedPrintPreview(routing_id()); new PrintHostMsg_SetupScriptedPrintPreview(routing_id());
......
...@@ -349,6 +349,10 @@ bool Instance::Init(uint32_t argc, const char* argn[], const char* argv[]) { ...@@ -349,6 +349,10 @@ bool Instance::Init(uint32_t argc, const char* argn[], const char* argv[]) {
// For PDFs embedded in a frame, we don't get the data automatically like we // For PDFs embedded in a frame, we don't get the data automatically like we
// do for full-frame loads. Start loading the data manually. // do for full-frame loads. Start loading the data manually.
LoadUrl(url); LoadUrl(url);
} else {
DCHECK(!did_call_start_loading_);
pp::PDF::DidStartLoading(this);
did_call_start_loading_ = true;
} }
ZoomLimitsChanged(kMinZoom, kMaxZoom); ZoomLimitsChanged(kMinZoom, kMaxZoom);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment