electron/patches/chromium/web_contents.patch
Shelley Vohr beee3737a9
fix: offscreen mode under window.open creation (#48070)
fix: offscreen mode under window.open creation
2025-08-18 16:17:22 -04:00

66 lines
2.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: deepak1556 <hop2deep@gmail.com>
Date: Sat, 24 Apr 2021 18:07:09 -0700
Subject: web_contents.patch
This allows overriding the RenderViewHostDelegateView of a WebContents, which
is needed for OSR.
Originally landed in https://github.com/electron/libchromiumcontent/pull/226.
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index bf6a239f566ec39efdacce5b74014d2995ba868e..e233701dddea01dd727dcd02d096b331c8aeff97 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -4079,6 +4079,13 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params,
params.main_frame_name, GetOpener(), primary_main_frame_policy,
base::UnguessableToken::Create());
+ if (params.view && params.delegate_view) {
+ view_.reset(params.view);
+ render_view_host_delegate_view_ = params.delegate_view;
+ }
+
+ if (!view_) {
+
std::unique_ptr<WebContentsViewDelegate> delegate =
GetContentClient()->browser()->GetWebContentsViewDelegate(this);
@@ -4089,6 +4096,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params,
view_ = CreateWebContentsView(this, std::move(delegate),
&render_view_host_delegate_view_);
}
+ } // !view_
CHECK(render_view_host_delegate_view_);
CHECK(view_.get());
diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h
index ab2df2fac23584574ca75a30084b3a47c626a1a1..754d083e1c8500092e60f484e4e9d97679704431 100644
--- a/content/public/browser/web_contents.h
+++ b/content/public/browser/web_contents.h
@@ -121,11 +121,14 @@ class BrowserPluginGuestDelegate;
class GuestPageHolder;
class RenderFrameHost;
class RenderViewHost;
+class RenderViewHostDelegateView;
class RenderWidgetHostView;
+class RenderWidgetHostViewBase;
class ScreenOrientationDelegate;
class SiteInstance;
class UnownedInnerWebContentsClient;
class WebContentsDelegate;
+class WebContentsView;
class WebUI;
struct DropData;
struct MHTMLGenerationParams;
@@ -279,6 +282,10 @@ class WebContents : public PageNavigator, public base::SupportsUserData {
network::mojom::WebSandboxFlags starting_sandbox_flags =
network::mojom::WebSandboxFlags::kNone;
+ // Optionally specify the view and delegate view.
+ raw_ptr<content::WebContentsView> view = nullptr;
+ raw_ptr<content::RenderViewHostDelegateView> delegate_view = nullptr;
+
// Value used to set the last time the WebContents was made active, this is
// the value that'll be returned by GetLastActiveTimeTicks(). If this is
// left default initialized then the value is not passed on to the