From 7a98b3fecec8dbb75295c64f4550e4d2c03bfea9 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Mon, 4 Nov 2024 12:01:19 -0500 Subject: [PATCH] Execute HandleExternalProtocolHelper on the UI thread (fixes #3821) --- libcef/browser/chrome/chrome_content_browser_client_cef.cc | 2 ++ libcef/browser/net_service/resource_request_handler_wrapper.cc | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/libcef/browser/chrome/chrome_content_browser_client_cef.cc b/libcef/browser/chrome/chrome_content_browser_client_cef.cc index f55bddeef..4413884be 100644 --- a/libcef/browser/chrome/chrome_content_browser_client_cef.cc +++ b/libcef/browser/chrome/chrome_content_browser_client_cef.cc @@ -59,6 +59,8 @@ void HandleExternalProtocolHelper( const network::ResourceRequest& resource_request, const std::optional& initiating_origin, content::WeakDocumentPtr initiator_document) { + CEF_REQUIRE_UIT(); + // May return nullptr if frame has been deleted or a cross-document navigation // has committed in the same RenderFrameHost. auto initiator_rfh = initiator_document.AsRenderFrameHostIfValid(); diff --git a/libcef/browser/net_service/resource_request_handler_wrapper.cc b/libcef/browser/net_service/resource_request_handler_wrapper.cc index 045f0229a..895cf2c08 100644 --- a/libcef/browser/net_service/resource_request_handler_wrapper.cc +++ b/libcef/browser/net_service/resource_request_handler_wrapper.cc @@ -1116,7 +1116,7 @@ class InterceptedRequestHandlerWrapper : public InterceptedRequestHandler { init_state_->browser_, init_state_->frame_, state->pending_request_.get(), allow_os_execution); if (allow_os_execution && init_state_->unhandled_request_callback_) { - init_state_->unhandled_request_callback_.Run(); + CEF_POST_TASK(TID_UI, init_state_->unhandled_request_callback_); } } }