2018-10-24 18:24:11 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2018-09-21 00:30:26 +00:00
|
|
|
From: Anonymous <anonymous@electronjs.org>
|
|
|
|
Date: Thu, 20 Sep 2018 17:46:53 -0700
|
|
|
|
Subject: web_contents.patch
|
|
|
|
|
|
|
|
|
2018-09-14 05:02:16 +00:00
|
|
|
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
|
2019-10-28 22:12:35 +00:00
|
|
|
index f82a5fd1362ff9ca7d44e5a5366cb8e5be61d674..03ae4f288371d85493561f22e2429ade5de32339 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/content/browser/web_contents/web_contents_impl.cc
|
|
|
|
+++ b/content/browser/web_contents/web_contents_impl.cc
|
2019-10-28 22:12:35 +00:00
|
|
|
@@ -2120,6 +2120,12 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) {
|
2018-09-14 05:02:16 +00:00
|
|
|
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);
|
|
|
|
|
2019-10-28 22:12:35 +00:00
|
|
|
@@ -2135,6 +2141,7 @@ void WebContentsImpl::Init(const WebContents::CreateParams& params) {
|
2018-09-14 05:02:16 +00:00
|
|
|
&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
|
2019-09-18 19:58:00 +00:00
|
|
|
index c45581fd22b7ba28b76bdebfffdc872b820798c8..f22ac0e611cc79aa1bc7f85836d69e3a8e326a6e 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/content/browser/web_contents/web_contents_view_guest.cc
|
|
|
|
+++ b/content/browser/web_contents/web_contents_view_guest.cc
|
2019-05-13 18:49:01 +00:00
|
|
|
@@ -68,19 +68,27 @@ gfx::NativeWindow WebContentsViewGuest::GetTopLevelNativeWindow() const {
|
2018-09-14 05:02:16 +00:00
|
|
|
|
|
|
|
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.
|
2019-05-13 18:49:01 +00:00
|
|
|
- parent_view->GetNativeView()->AddChild(platform_view_->GetNativeView());
|
|
|
|
+ if (parent_view->GetNativeView() != platform_view_->GetNativeView()) {
|
|
|
|
+ parent_view->GetNativeView()->AddChild(platform_view_->GetNativeView());
|
2019-01-12 01:00:43 +00:00
|
|
|
+ }
|
2018-09-14 05:02:16 +00:00
|
|
|
#endif // defined(USE_AURA)
|
|
|
|
}
|
|
|
|
|
|
|
|
void WebContentsViewGuest::OnGuestDetached(WebContentsView* old_parent_view) {
|
|
|
|
#if defined(USE_AURA)
|
2019-05-13 18:49:01 +00:00
|
|
|
- old_parent_view->GetNativeView()->RemoveChild(
|
|
|
|
- platform_view_->GetNativeView());
|
2018-09-14 05:02:16 +00:00
|
|
|
+ if (!platform_view_->GetNativeView())
|
|
|
|
+ return;
|
2019-05-13 18:49:01 +00:00
|
|
|
+ if (old_parent_view->GetNativeView() != platform_view_->GetNativeView()) {
|
|
|
|
+ old_parent_view->GetNativeView()->RemoveChild(
|
|
|
|
+ platform_view_->GetNativeView());
|
|
|
|
+ }
|
|
|
|
#endif // defined(USE_AURA)
|
|
|
|
}
|
|
|
|
|
2019-09-18 19:58:00 +00:00
|
|
|
@@ -130,11 +138,22 @@ RenderWidgetHostViewBase* WebContentsViewGuest::CreateViewForWidget(
|
2018-09-14 05:02:16 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2019-01-12 01:00:43 +00:00
|
|
|
RenderWidgetHostViewBase* WebContentsViewGuest::CreateViewForChildWidget(
|
2018-09-14 05:02:16 +00:00
|
|
|
diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h
|
2019-10-28 22:12:35 +00:00
|
|
|
index 075dd25454306b3f689cf58245ac448b25a64f93..750de66b8002ba66d0f2247d0075da1e51ac764c 100644
|
2018-09-14 05:02:16 +00:00
|
|
|
--- a/content/public/browser/web_contents.h
|
|
|
|
+++ b/content/public/browser/web_contents.h
|
2019-09-18 19:58:00 +00:00
|
|
|
@@ -79,9 +79,12 @@ class BrowserPluginGuestDelegate;
|
2018-09-14 05:02:16 +00:00
|
|
|
class InterstitialPage;
|
|
|
|
class RenderFrameHost;
|
|
|
|
class RenderViewHost;
|
|
|
|
+class RenderViewHostDelegateView;
|
|
|
|
class RenderWidgetHost;
|
|
|
|
class RenderWidgetHostView;
|
|
|
|
+class RenderWidgetHostViewBase;
|
|
|
|
class WebContentsDelegate;
|
|
|
|
+class WebContentsView;
|
|
|
|
struct CustomContextMenuContext;
|
|
|
|
struct DropData;
|
2018-09-14 18:03:43 +00:00
|
|
|
struct MHTMLGenerationParams;
|
2019-07-24 22:58:51 +00:00
|
|
|
@@ -214,6 +217,10 @@ class WebContents : public PageNavigator,
|
2018-09-14 18:03:43 +00:00
|
|
|
kInitializeAndWarmupRendererProcess,
|
|
|
|
} desired_renderer_state;
|
2018-09-14 05:02:16 +00:00
|
|
|
|
|
|
|
+ // 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;
|
2018-09-21 00:30:26 +00:00
|
|
|
|