Commit ef170b7f authored by Alan Screen's avatar Alan Screen Committed by Chromium LUCI CQ

Don't send a closed message to a terminated PrintRenderFrame.

Bug: 1151726
Change-Id: I294554670b0ee4fe4281389d0c87cfbae87b1a81
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2580878Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Commit-Queue: Alan Screen <awscreen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#835043}
parent a04d221d
...@@ -163,8 +163,11 @@ void PrintViewManager::PrintPreviewDone() { ...@@ -163,8 +163,11 @@ void PrintViewManager::PrintPreviewDone() {
// dispatch 'afterprint' event. // dispatch 'afterprint' event.
bool send_message = !is_switching_to_system_dialog_; bool send_message = !is_switching_to_system_dialog_;
#endif #endif
if (send_message) if (send_message) {
GetPrintRenderFrame(print_preview_rfh_)->OnPrintPreviewDialogClosed(); // Only send a message about having closed if it is still connected.
if (IsPrintRenderFrameConnected(print_preview_rfh_))
GetPrintRenderFrame(print_preview_rfh_)->OnPrintPreviewDialogClosed();
}
is_switching_to_system_dialog_ = false; is_switching_to_system_dialog_ = false;
if (print_preview_state_ == SCRIPTED_PREVIEW) { if (print_preview_state_ == SCRIPTED_PREVIEW) {
......
...@@ -96,6 +96,14 @@ void PrintManager::PrintingFailed(int32_t cookie) { ...@@ -96,6 +96,14 @@ void PrintManager::PrintingFailed(int32_t cookie) {
void PrintManager::ShowScriptedPrintPreview(bool source_is_modifiable) {} void PrintManager::ShowScriptedPrintPreview(bool source_is_modifiable) {}
#endif #endif
bool PrintManager::IsPrintRenderFrameConnected(content::RenderFrameHost* rfh) {
auto it = print_render_frames_.find(rfh);
if (it == print_render_frames_.end())
return false;
return it->second.is_bound() && it->second.is_connected();
}
const mojo::AssociatedRemote<printing::mojom::PrintRenderFrame>& const mojo::AssociatedRemote<printing::mojom::PrintRenderFrame>&
PrintManager::GetPrintRenderFrame(content::RenderFrameHost* rfh) { PrintManager::GetPrintRenderFrame(content::RenderFrameHost* rfh) {
auto it = print_render_frames_.find(rfh); auto it = print_render_frames_.find(rfh);
......
...@@ -67,6 +67,10 @@ class PrintManager : public content::WebContentsObserver, ...@@ -67,6 +67,10 @@ class PrintManager : public content::WebContentsObserver,
protected: protected:
explicit PrintManager(content::WebContents* contents); explicit PrintManager(content::WebContents* contents);
// Helper method to determine if PrintRenderFrame associated remote interface
// is still connected.
bool IsPrintRenderFrameConnected(content::RenderFrameHost* rfh);
// Helper method to fetch the PrintRenderFrame associated remote interface // Helper method to fetch the PrintRenderFrame associated remote interface
// pointer. // pointer.
const mojo::AssociatedRemote<printing::mojom::PrintRenderFrame>& const mojo::AssociatedRemote<printing::mojom::PrintRenderFrame>&
......
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