web_contents.patch 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: deepak1556 <[email protected]>
  3. Date: Sat, 24 Apr 2021 18:07:09 -0700
  4. Subject: web_contents.patch
  5. This allows overriding the RenderViewHostDelegateView of a WebContents, which
  6. is needed for OSR.
  7. Originally landed in https://github.com/electron/libchromiumcontent/pull/226.
  8. diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
  9. index cc2e4302ad121d658bb43af1014b6af42a62d47a..2585728e652de91cbc9839cb1500e04f87635866 100644
  10. --- a/content/browser/web_contents/web_contents_impl.cc
  11. +++ b/content/browser/web_contents/web_contents_impl.cc
  12. @@ -3651,6 +3651,13 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params,
  13. params.main_frame_name, GetOpener(), primary_main_frame_policy,
  14. base::UnguessableToken::Create());
  15. + if (params.view && params.delegate_view) {
  16. + view_.reset(params.view);
  17. + render_view_host_delegate_view_ = params.delegate_view;
  18. + }
  19. +
  20. + if (!view_) {
  21. +
  22. std::unique_ptr<WebContentsViewDelegate> delegate =
  23. GetContentClient()->browser()->GetWebContentsViewDelegate(this);
  24. @@ -3661,6 +3668,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params,
  25. view_ = CreateWebContentsView(this, std::move(delegate),
  26. &render_view_host_delegate_view_);
  27. }
  28. + } // !view_
  29. CHECK(render_view_host_delegate_view_);
  30. CHECK(view_.get());
  31. diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h
  32. index 09099f8ba7b051d89bc43da5b8ae96222d9b0f7f..3cebb9b8fc035550523beac742cb27ce404a9e89 100644
  33. --- a/content/public/browser/web_contents.h
  34. +++ b/content/public/browser/web_contents.h
  35. @@ -110,10 +110,13 @@ class BrowserContext;
  36. class BrowserPluginGuestDelegate;
  37. class RenderFrameHost;
  38. class RenderViewHost;
  39. +class RenderViewHostDelegateView;
  40. class RenderWidgetHostView;
  41. +class RenderWidgetHostViewBase;
  42. class ScreenOrientationDelegate;
  43. class SiteInstance;
  44. class WebContentsDelegate;
  45. +class WebContentsView;
  46. class WebUI;
  47. struct DropData;
  48. struct MHTMLGenerationParams;
  49. @@ -259,6 +262,10 @@ class WebContents : public PageNavigator, public base::SupportsUserData {
  50. network::mojom::WebSandboxFlags starting_sandbox_flags =
  51. network::mojom::WebSandboxFlags::kNone;
  52. + // Optionally specify the view and delegate view.
  53. + raw_ptr<content::WebContentsView> view = nullptr;
  54. + raw_ptr<content::RenderViewHostDelegateView> delegate_view = nullptr;
  55. +
  56. // Value used to set the last time the WebContents was made active, this is
  57. // the value that'll be returned by GetLastActiveTimeTicks(). If this is
  58. // left default initialized then the value is not passed on to the