Commit 2f671168 authored by Lei Zhang's avatar Lei Zhang Committed by Commit Bot

Always dispatch onafterprint event in PrintFrameContent().

In the rare case where the renderer cannot send its data, it exits early
from PrintFrameContent() and forgets to send the onafterprint event. Fix
the code to always send the event when possible.

Change-Id: I31cf4fec8f17fcd64742d22056c0c445b422c7a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2340356Reviewed-by: default avatarWei Li <weili@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796024}
parent cdbc056a
...@@ -1358,18 +1358,18 @@ void PrintRenderFrameHelper::PrintFrameContent( ...@@ -1358,18 +1358,18 @@ void PrintRenderFrameHelper::PrintFrameContent(
metafile.FinishFrameContent(); metafile.FinishFrameContent();
// Send the printed result back. // Send the printed result back, if possible. Do not return early here on
// failure, as DispatchAfterPrintEvent() still need to be called.
mojom::DidPrintContentParamsPtr printed_frame_params = mojom::DidPrintContentParamsPtr printed_frame_params =
mojom::DidPrintContentParams::New(); mojom::DidPrintContentParams::New();
if (!CopyMetafileDataToReadOnlySharedMem(metafile, if (CopyMetafileDataToReadOnlySharedMem(metafile,
printed_frame_params.get())) { printed_frame_params.get())) {
std::move(callback).Run(params->document_cookie,
std::move(printed_frame_params));
} else {
DLOG(ERROR) << "CopyMetafileDataToSharedMem failed"; DLOG(ERROR) << "CopyMetafileDataToSharedMem failed";
return;
} }
std::move(callback).Run(params->document_cookie,
std::move(printed_frame_params));
if (!render_frame_gone_) if (!render_frame_gone_)
frame->DispatchAfterPrintEvent(); frame->DispatchAfterPrintEvent();
} }
......
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