electron/patches/common/chromium/web_contents.patch
Jeremy Apthorp 6555be2636 chore: bump chromium to 74.0.3729.27 (master) (#17345)
* chore: bump chromium to 74.0.3729.5 (master)

* Remove ScopedBlockingCall constructor without location

https://chromium-review.googlesource.com/c/chromium/src/+/1496560

* Use XCode 9.4.1 for Mac SDK 10.13

* chore: roll chromium 74.0.3729.27
2019-03-21 11:45:22 -04:00

119 lines
5 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Anonymous <anonymous@electronjs.org>
Date: Thu, 20 Sep 2018 17:46:53 -0700
Subject: web_contents.patch
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 9ad76884fa8cff7e9940a478a50df0260dda366a..d6590498e9f188a829440e61a169fb57221a3b5f 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -2068,6 +2068,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);
@@ -2083,6 +2089,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) {
&render_view_host_delegate_view_);
}
}
+ } // !view_
CHECK(render_view_host_delegate_view_);
CHECK(view_.get());
diff --git a/content/browser/web_contents/web_contents_view_guest.cc b/content/browser/web_contents/web_contents_view_guest.cc
index 9d91d225fd9f3eeef7d9beec126e6cc6a58a76d7..8a443514dfbdab37f951bc7c54cf1989a2b01a16 100644
--- a/content/browser/web_contents/web_contents_view_guest.cc
+++ b/content/browser/web_contents/web_contents_view_guest.cc
@@ -69,19 +69,26 @@ gfx::NativeWindow WebContentsViewGuest::GetTopLevelNativeWindow() const {
void WebContentsViewGuest::OnGuestAttached(WebContentsView* parent_view) {
#if defined(USE_AURA)
+ if (!platform_view_->GetNativeView())
+ return;
// In aura, ScreenPositionClient doesn't work properly if we do
// not have the native view associated with this WebContentsViewGuest in the
// view hierarchy. We add this view as embedder's child here.
// This would go in WebContentsViewGuest::CreateView, but that is too early to
// access embedder_web_contents(). Therefore, we do it here.
- if (!features::IsMultiProcessMash())
+ if (!features::IsMultiProcessMash() &&
+ parent_view->GetNativeView() != platform_view_->GetNativeView()) {
parent_view->GetNativeView()->AddChild(platform_view_->GetNativeView());
+ }
#endif // defined(USE_AURA)
}
void WebContentsViewGuest::OnGuestDetached(WebContentsView* old_parent_view) {
#if defined(USE_AURA)
- if (!features::IsMultiProcessMash()) {
+ if (!platform_view_->GetNativeView())
+ return;
+ if (!features::IsMultiProcessMash() &&
+ old_parent_view->GetNativeView() != platform_view_->GetNativeView()) {
old_parent_view->GetNativeView()->RemoveChild(
platform_view_->GetNativeView());
}
@@ -136,11 +143,22 @@ RenderWidgetHostViewBase* WebContentsViewGuest::CreateViewForWidget(
render_widget_host->GetView());
}
+ RenderWidgetHost* embedder_render_widget_host =
+ guest_->embedder_web_contents()->GetRenderViewHost()->GetWidget();
+ RenderWidgetHostViewBase* embedder_render_widget_host_view =
+ static_cast<RenderWidgetHostViewBase*>(
+ embedder_render_widget_host->GetView());
RenderWidgetHostViewBase* platform_widget =
- platform_view_->CreateViewForWidget(render_widget_host, true);
-
- return RenderWidgetHostViewGuest::Create(render_widget_host, guest_,
- platform_widget->GetWeakPtr());
+ embedder_render_widget_host_view->CreateViewForWidget(
+ render_widget_host,
+ embedder_render_widget_host,
+ platform_view_.get());
+ RenderWidgetHostViewGuest* guest_view = RenderWidgetHostViewGuest::Create(
+ render_widget_host, guest_, platform_widget->GetWeakPtr());
+ platform_widget->InitAsGuest(embedder_render_widget_host->GetView(),
+ guest_view);
+
+ return guest_view;
}
RenderWidgetHostViewBase* WebContentsViewGuest::CreateViewForChildWidget(
diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h
index 2fe0a25aed9f2fbcf6a7d308fa4deefb7c051f79..cce64cb2b376ee3445eed94b1399a6efb19c0d79 100644
--- a/content/public/browser/web_contents.h
+++ b/content/public/browser/web_contents.h
@@ -75,9 +75,12 @@ class BrowserPluginGuestDelegate;
class InterstitialPage;
class RenderFrameHost;
class RenderViewHost;
+class RenderViewHostDelegateView;
class RenderWidgetHost;
class RenderWidgetHostView;
+class RenderWidgetHostViewBase;
class WebContentsDelegate;
+class WebContentsView;
struct CustomContextMenuContext;
struct DropData;
struct MHTMLGenerationParams;
@@ -213,6 +216,10 @@ class WebContents : public PageNavigator,
kInitializeAndWarmupRendererProcess,
} desired_renderer_state;
+ // Optionally specify the view and delegate view.
+ content::WebContentsView* view = nullptr;
+ content::RenderViewHostDelegateView* delegate_view = nullptr;
+
// Sandboxing flags set on the new WebContents.
blink::WebSandboxFlags starting_sandbox_flags;