From 708d90a6ffb70acdc21fdd537f449e89ec211a71 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Wed, 24 Apr 2024 17:35:45 -0400 Subject: [PATCH] chrome: osr: Create CefWebContentsViewOSR for guest views (see #3681) Match the logic in Alloy's CefMimeHandlerViewGuestDelegate. --- ...rome_mime_handler_view_guest_delegate_cef.cc | 17 +++++++++++++++++ ...hrome_mime_handler_view_guest_delegate_cef.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/libcef/browser/chrome/extensions/chrome_mime_handler_view_guest_delegate_cef.cc b/libcef/browser/chrome/extensions/chrome_mime_handler_view_guest_delegate_cef.cc index ace733691..fc08dcedc 100644 --- a/libcef/browser/chrome/extensions/chrome_mime_handler_view_guest_delegate_cef.cc +++ b/libcef/browser/chrome/extensions/chrome_mime_handler_view_guest_delegate_cef.cc @@ -7,6 +7,7 @@ #include "libcef/browser/browser_host_base.h" #include "libcef/browser/chrome/chrome_context_menu_handler.h" +#include "libcef/browser/osr/web_contents_view_osr.h" #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h" @@ -19,6 +20,22 @@ ChromeMimeHandlerViewGuestDelegateCef::ChromeMimeHandlerViewGuestDelegateCef( ChromeMimeHandlerViewGuestDelegateCef:: ~ChromeMimeHandlerViewGuestDelegateCef() = default; +void ChromeMimeHandlerViewGuestDelegateCef::OverrideWebContentsCreateParams( + content::WebContents::CreateParams* params) { + DCHECK(params->guest_delegate); + + auto owner_browser = + CefBrowserHostBase::GetBrowserForContents(owner_web_contents_); + DCHECK(owner_browser); + + if (owner_browser->IsWindowless()) { + CefWebContentsViewOSR* view_osr = new CefWebContentsViewOSR( + owner_browser->GetBackgroundColor(), false, false); + params->view = view_osr; + params->delegate_view = view_osr; + } +} + bool ChromeMimeHandlerViewGuestDelegateCef::HandleContextMenu( content::RenderFrameHost& render_frame_host, const content::ContextMenuParams& params) { diff --git a/libcef/browser/chrome/extensions/chrome_mime_handler_view_guest_delegate_cef.h b/libcef/browser/chrome/extensions/chrome_mime_handler_view_guest_delegate_cef.h index d3ee13df3..3ca0d5bb2 100644 --- a/libcef/browser/chrome/extensions/chrome_mime_handler_view_guest_delegate_cef.h +++ b/libcef/browser/chrome/extensions/chrome_mime_handler_view_guest_delegate_cef.h @@ -25,6 +25,8 @@ class ChromeMimeHandlerViewGuestDelegateCef ~ChromeMimeHandlerViewGuestDelegateCef() override; // MimeHandlerViewGuestDelegate methods. + void OverrideWebContentsCreateParams( + content::WebContents::CreateParams* params) override; bool HandleContextMenu(content::RenderFrameHost& render_frame_host, const content::ContextMenuParams& params) override;