From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: deepak1556 <hop2deep@gmail.com>
Date: Fri, 10 Apr 2020 15:14:49 -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 3049fe6aa54b1f57e94769fcf300e02d13c361da..d07957e1ff00a28feb9d3dee854c9b8d0d33f1fe 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -2771,6 +2771,12 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) {
   std::string unique_name;
   frame_tree_.root()->SetFrameName(params.main_frame_name, unique_name);
 
+  if (params.view && params.delegate_view) {
+    view_.reset(params.view);
+    render_view_host_delegate_view_ = params.delegate_view;
+  }
+
+  if (!view_) {
   WebContentsViewDelegate* delegate =
       GetContentClient()->browser()->GetWebContentsViewDelegate(this);
 
@@ -2781,6 +2787,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) {
     view_.reset(CreateWebContentsView(this, 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 0426cc1550f11bbe978fd8a98462b3899a627c74..a43c9972377f6365c3fe0e33f0d29700f597bd2d 100644
--- a/content/public/browser/web_contents.h
+++ b/content/public/browser/web_contents.h
@@ -86,8 +86,11 @@ class BrowserContext;
 class BrowserPluginGuestDelegate;
 class RenderFrameHost;
 class RenderViewHost;
+class RenderViewHostDelegateView;
 class RenderWidgetHostView;
+class RenderWidgetHostViewBase;
 class WebContentsDelegate;
+class WebContentsView;
 class WebUI;
 struct CustomContextMenuContext;
 struct DropData;
@@ -221,6 +224,10 @@ class WebContents : public PageNavigator,
     // Sandboxing flags set on the new WebContents.
     network::mojom::WebSandboxFlags starting_sandbox_flags;
 
+    // Optionally specify the view and delegate view.
+    content::WebContentsView* view = nullptr;
+    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 GetLastActiveTime(). If this is left
     // default initialized then the value is not passed on to the WebContents
