Index: components/guest_view/browser/guest_view_message_filter.cc |
diff --git a/components/guest_view/browser/guest_view_message_filter.cc b/components/guest_view/browser/guest_view_message_filter.cc |
index c7d1546d125ee89deb394998e23f884f79d390d2..38b7cfd66cfb57e5e12368b59692865a571b0da9 100644 |
--- a/components/guest_view/browser/guest_view_message_filter.cc |
+++ b/components/guest_view/browser/guest_view_message_filter.cc |
@@ -81,7 +81,28 @@ bool GuestViewMessageFilter::OnMessageReceived(const IPC::Message& message) { |
OnViewGarbageCollected) |
IPC_MESSAGE_UNHANDLED(handled = false) |
IPC_END_MESSAGE_MAP() |
- return handled; |
+ if (handled) |
+ return true; |
+ |
+ int element_instance_id = kInstanceIDNone; |
+ base::PickleIterator iter(message); |
+ bool success = iter.ReadInt(&element_instance_id); |
+ DCHECK(success); |
+ |
+ auto manager = GuestViewManager::FromBrowserContext(browser_context_); |
+ |
+ content::WebContents* guest_web_contents = |
+ manager->GetGuestByInstanceID(render_process_id_, element_instance_id); |
+ if (!guest_web_contents) |
+ return true; |
+ |
+ auto guest = GuestViewBase::FromWebContents(guest_web_contents); |
+ if (guest && guest->OnMessageReceivedFromEmbedder(message)) |
+ return true; |
+ |
+ // Always consume GuestView messages because we may not have an available |
+ // guest during tear down. |
+ return true; |
} |
void GuestViewMessageFilter::OnViewCreated(int view_instance_id, |