chrome: osr: Create CefWebContentsViewOSR for guest views (see #3681)

Match the logic in Alloy's CefMimeHandlerViewGuestDelegate.
This commit is contained in:
Marshall Greenblatt 2024-04-24 17:35:45 -04:00
parent 5065aba1b4
commit 708d90a6ff
2 changed files with 19 additions and 0 deletions

View File

@ -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) {

View File

@ -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;