Skip to content

Commit

Permalink
chrome: osr: Create CefWebContentsViewOSR for guest views (see #3681)
Browse files Browse the repository at this point in the history
Match the logic in Alloy's CefMimeHandlerViewGuestDelegate.
  • Loading branch information
magreenblatt committed Apr 26, 2024
1 parent 5065aba commit 708d90a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 708d90a

Please sign in to comment.