2017-02-10 23:44:11 +01:00
|
|
|
diff --git content/browser/browser_plugin/browser_plugin_guest.cc content/browser/browser_plugin/browser_plugin_guest.cc
|
2019-10-01 15:55:16 +02:00
|
|
|
index 6eb21be63dec..87ccc46f4d43 100644
|
2017-02-10 23:44:11 +01:00
|
|
|
--- content/browser/browser_plugin/browser_plugin_guest.cc
|
|
|
|
+++ content/browser/browser_plugin/browser_plugin_guest.cc
|
2019-10-01 15:55:16 +02:00
|
|
|
@@ -306,8 +306,11 @@ void BrowserPluginGuest::InitInternal(
|
2017-02-10 23:44:11 +01:00
|
|
|
static_cast<WebContentsViewGuest*>(GetWebContents()->GetView());
|
2015-07-24 02:06:56 +02:00
|
|
|
}
|
|
|
|
|
2017-02-10 23:44:11 +01:00
|
|
|
- if (owner_web_contents_ && new_view)
|
|
|
|
+ if (owner_web_contents_ && new_view) {
|
|
|
|
new_view->OnGuestDetached(owner_web_contents_->GetView());
|
|
|
|
+ if (delegate_)
|
|
|
|
+ delegate_->OnGuestDetached(owner_web_contents_->GetView());
|
|
|
|
+ }
|
2015-07-16 23:40:01 +02:00
|
|
|
|
|
|
|
// Once a BrowserPluginGuest has an embedder WebContents, it's considered to
|
|
|
|
// be attached.
|
2019-10-01 15:55:16 +02:00
|
|
|
@@ -820,10 +823,19 @@ void BrowserPluginGuest::OnWillAttachComplete(
|
2017-02-10 23:44:11 +01:00
|
|
|
static_cast<WebContentsViewGuest*>(GetWebContents()->GetView());
|
2015-11-10 21:18:16 +01:00
|
|
|
if (!web_contents()->GetRenderViewHost()->GetWidget()->GetView()) {
|
2017-02-10 23:44:11 +01:00
|
|
|
web_contents_view->CreateViewForWidget(
|
2015-11-10 21:18:16 +01:00
|
|
|
- web_contents()->GetRenderViewHost()->GetWidget(), true);
|
2017-02-10 23:44:11 +01:00
|
|
|
+ web_contents()->GetRenderViewHost()->GetWidget(),
|
|
|
|
+ embedder_web_contents->GetRenderViewHost()->GetWidget());
|
2015-11-10 21:18:16 +01:00
|
|
|
}
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
2017-09-06 23:40:58 +02:00
|
|
|
+ if (delegate_) {
|
|
|
|
+ // Notify the delegate here instead of in InitInternal because InitInternal
|
|
|
|
+ // will now be called from Init before GuestViewBase::CompleteInit has set
|
|
|
|
+ // web_contents() to the guest WebContents. This behavior change is due to
|
|
|
|
+ // https://crrev.com/07263b56.
|
|
|
|
+ delegate_->OnGuestAttached(embedder_web_contents->GetView());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
InitInternal(params, embedder_web_contents);
|
|
|
|
|
|
|
|
attached_ = true;
|
2017-02-10 23:44:11 +01:00
|
|
|
diff --git content/browser/frame_host/interstitial_page_impl.cc content/browser/frame_host/interstitial_page_impl.cc
|
2019-10-01 15:55:16 +02:00
|
|
|
index be1334c46132..60abcebf7422 100644
|
2017-02-10 23:44:11 +01:00
|
|
|
--- content/browser/frame_host/interstitial_page_impl.cc
|
|
|
|
+++ content/browser/frame_host/interstitial_page_impl.cc
|
2019-10-01 15:55:16 +02:00
|
|
|
@@ -622,7 +622,7 @@ WebContentsView* InterstitialPageImpl::CreateWebContentsView() {
|
2017-02-10 23:44:11 +01:00
|
|
|
WebContentsView* wcv =
|
|
|
|
static_cast<WebContentsImpl*>(web_contents())->GetView();
|
|
|
|
RenderWidgetHostViewBase* view =
|
|
|
|
- wcv->CreateViewForWidget(render_view_host_->GetWidget(), false);
|
|
|
|
+ wcv->CreateViewForWidget(render_view_host_->GetWidget(), nullptr);
|
2018-02-15 01:12:09 +01:00
|
|
|
render_view_host_->GetWidget()->SetView(view);
|
2017-03-03 23:37:23 +01:00
|
|
|
render_view_host_->GetMainFrame()->AllowBindings(
|
|
|
|
BINDINGS_POLICY_DOM_AUTOMATION);
|
2017-02-10 23:44:11 +01:00
|
|
|
diff --git content/browser/web_contents/web_contents_view.h content/browser/web_contents/web_contents_view.h
|
2019-04-16 16:38:48 +02:00
|
|
|
index bfb918a2cba3..a193b5a0fed8 100644
|
2017-02-10 23:44:11 +01:00
|
|
|
--- content/browser/web_contents/web_contents_view.h
|
|
|
|
+++ content/browser/web_contents/web_contents_view.h
|
2019-04-16 16:38:48 +02:00
|
|
|
@@ -23,7 +23,7 @@ struct DropData;
|
2017-07-27 01:19:27 +02:00
|
|
|
// The WebContentsView is an interface that is implemented by the platform-
|
|
|
|
// dependent web contents views. The WebContents uses this interface to talk to
|
|
|
|
// them.
|
|
|
|
-class WebContentsView {
|
|
|
|
+class CONTENT_EXPORT WebContentsView {
|
|
|
|
public:
|
|
|
|
virtual ~WebContentsView() {}
|
|
|
|
|
2019-04-16 16:38:48 +02:00
|
|
|
@@ -84,13 +84,9 @@ class WebContentsView {
|
2017-02-10 23:44:11 +01:00
|
|
|
// Sets up the View that holds the rendered web page, receives messages for
|
|
|
|
// it and contains page plugins. The host view should be sized to the current
|
|
|
|
// size of the WebContents.
|
|
|
|
- //
|
|
|
|
- // |is_guest_view_hack| is temporary hack and will be removed once
|
|
|
|
- // RenderWidgetHostViewGuest is not dependent on platform view.
|
|
|
|
- // TODO(lazyboy): Remove |is_guest_view_hack| once http://crbug.com/330264 is
|
|
|
|
- // fixed.
|
|
|
|
virtual RenderWidgetHostViewBase* CreateViewForWidget(
|
|
|
|
- RenderWidgetHost* render_widget_host, bool is_guest_view_hack) = 0;
|
|
|
|
+ RenderWidgetHost* render_widget_host,
|
|
|
|
+ RenderWidgetHost* embedder_render_widget_host) = 0;
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2018-10-02 14:14:11 +02:00
|
|
|
// Creates a new View that holds a non-top-level widget and receives messages
|
|
|
|
// for it.
|
2017-02-10 23:44:11 +01:00
|
|
|
diff --git content/browser/web_contents/web_contents_view_aura.cc content/browser/web_contents/web_contents_view_aura.cc
|
2019-10-01 15:55:16 +02:00
|
|
|
index dda92e4006db..23f86f9f1564 100644
|
2017-02-10 23:44:11 +01:00
|
|
|
--- content/browser/web_contents/web_contents_view_aura.cc
|
|
|
|
+++ content/browser/web_contents/web_contents_view_aura.cc
|
2019-10-01 15:55:16 +02:00
|
|
|
@@ -948,7 +948,8 @@ void WebContentsViewAura::CreateView(const gfx::Size& initial_size,
|
2017-02-10 23:44:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForWidget(
|
|
|
|
- RenderWidgetHost* render_widget_host, bool is_guest_view_hack) {
|
|
|
|
+ RenderWidgetHost* render_widget_host,
|
|
|
|
+ RenderWidgetHost* embedder_render_widget_host) {
|
|
|
|
if (render_widget_host->GetView()) {
|
|
|
|
// During testing, the view will already be set up in most cases to the
|
|
|
|
// test view, so we don't want to clobber it with a real one. To verify that
|
2019-10-01 15:55:16 +02:00
|
|
|
@@ -960,6 +961,7 @@ RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForWidget(
|
2017-03-03 23:37:23 +01:00
|
|
|
render_widget_host->GetView());
|
2017-02-10 23:44:11 +01:00
|
|
|
}
|
|
|
|
|
2017-03-03 23:37:23 +01:00
|
|
|
+ const bool is_guest_view_hack = !!embedder_render_widget_host;
|
2017-02-10 23:44:11 +01:00
|
|
|
RenderWidgetHostViewAura* view =
|
2017-03-03 23:37:23 +01:00
|
|
|
g_create_render_widget_host_view
|
|
|
|
? g_create_render_widget_host_view(render_widget_host,
|
2017-02-10 23:44:11 +01:00
|
|
|
diff --git content/browser/web_contents/web_contents_view_aura.h content/browser/web_contents/web_contents_view_aura.h
|
2019-10-01 15:55:16 +02:00
|
|
|
index ed3c8d86cacc..70f869da762f 100644
|
2017-02-10 23:44:11 +01:00
|
|
|
--- content/browser/web_contents/web_contents_view_aura.h
|
|
|
|
+++ content/browser/web_contents/web_contents_view_aura.h
|
2019-09-04 17:13:32 +02:00
|
|
|
@@ -122,7 +122,7 @@ class CONTENT_EXPORT WebContentsViewAura
|
2017-02-10 23:44:11 +01:00
|
|
|
gfx::NativeView context) override;
|
|
|
|
RenderWidgetHostViewBase* CreateViewForWidget(
|
|
|
|
RenderWidgetHost* render_widget_host,
|
|
|
|
- bool is_guest_view_hack) override;
|
|
|
|
+ RenderWidgetHost* embedder_render_widget_host) override;
|
2018-10-02 14:14:11 +02:00
|
|
|
RenderWidgetHostViewBase* CreateViewForChildWidget(
|
2017-02-10 23:44:11 +01:00
|
|
|
RenderWidgetHost* render_widget_host) override;
|
|
|
|
void SetPageTitle(const base::string16& title) override;
|
|
|
|
diff --git content/browser/web_contents/web_contents_view_child_frame.cc content/browser/web_contents/web_contents_view_child_frame.cc
|
2019-03-13 22:27:37 +01:00
|
|
|
index 1a68298648a2..a54af8a7f735 100644
|
2017-02-10 23:44:11 +01:00
|
|
|
--- content/browser/web_contents/web_contents_view_child_frame.cc
|
|
|
|
+++ content/browser/web_contents/web_contents_view_child_frame.cc
|
2018-03-20 21:15:08 +01:00
|
|
|
@@ -84,7 +84,7 @@ void WebContentsViewChildFrame::CreateView(const gfx::Size& initial_size,
|
2015-07-16 23:40:01 +02:00
|
|
|
|
2017-02-10 23:44:11 +01:00
|
|
|
RenderWidgetHostViewBase* WebContentsViewChildFrame::CreateViewForWidget(
|
|
|
|
RenderWidgetHost* render_widget_host,
|
|
|
|
- bool is_guest_view_hack) {
|
|
|
|
+ RenderWidgetHost* embedder_render_widget_host) {
|
|
|
|
return RenderWidgetHostViewChildFrame::Create(render_widget_host);
|
2015-07-16 23:40:01 +02:00
|
|
|
}
|
|
|
|
|
2017-02-10 23:44:11 +01:00
|
|
|
diff --git content/browser/web_contents/web_contents_view_child_frame.h content/browser/web_contents/web_contents_view_child_frame.h
|
2019-03-13 22:27:37 +01:00
|
|
|
index 8aaa80183dd1..b9df8a87be07 100644
|
2017-02-10 23:44:11 +01:00
|
|
|
--- content/browser/web_contents/web_contents_view_child_frame.h
|
|
|
|
+++ content/browser/web_contents/web_contents_view_child_frame.h
|
2018-03-20 21:15:08 +01:00
|
|
|
@@ -40,7 +40,7 @@ class WebContentsViewChildFrame : public WebContentsView,
|
2017-02-10 23:44:11 +01:00
|
|
|
gfx::NativeView context) override;
|
|
|
|
RenderWidgetHostViewBase* CreateViewForWidget(
|
|
|
|
RenderWidgetHost* render_widget_host,
|
|
|
|
- bool is_guest_view_hack) override;
|
|
|
|
+ RenderWidgetHost* embedder_render_widget_host) override;
|
2018-10-02 14:14:11 +02:00
|
|
|
RenderWidgetHostViewBase* CreateViewForChildWidget(
|
2017-02-10 23:44:11 +01:00
|
|
|
RenderWidgetHost* render_widget_host) override;
|
|
|
|
void SetPageTitle(const base::string16& title) override;
|
|
|
|
diff --git content/browser/web_contents/web_contents_view_guest.cc content/browser/web_contents/web_contents_view_guest.cc
|
2019-07-16 19:59:21 +02:00
|
|
|
index ecaf30bcb7b9..7c65a61fe158 100644
|
2017-02-10 23:44:11 +01:00
|
|
|
--- content/browser/web_contents/web_contents_view_guest.cc
|
|
|
|
+++ content/browser/web_contents/web_contents_view_guest.cc
|
2019-07-16 19:59:21 +02:00
|
|
|
@@ -68,6 +68,8 @@ gfx::NativeWindow WebContentsViewGuest::GetTopLevelNativeWindow() const {
|
2017-02-10 23:44:11 +01: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.
|
2019-07-16 19:59:21 +02:00
|
|
|
@@ -78,6 +80,8 @@ void WebContentsViewGuest::OnGuestAttached(WebContentsView* parent_view) {
|
2018-06-19 00:08:20 +02:00
|
|
|
}
|
2017-02-10 23:44:11 +01:00
|
|
|
|
|
|
|
void WebContentsViewGuest::OnGuestDetached(WebContentsView* old_parent_view) {
|
|
|
|
+ if (!platform_view_->GetNativeView())
|
|
|
|
+ return;
|
2018-06-19 00:08:20 +02:00
|
|
|
#if defined(USE_AURA)
|
2019-07-16 19:59:21 +02:00
|
|
|
old_parent_view->GetNativeView()->RemoveChild(
|
|
|
|
platform_view_->GetNativeView());
|
|
|
|
@@ -120,7 +124,8 @@ void WebContentsViewGuest::CreateView(const gfx::Size& initial_size,
|
2017-02-10 23:44:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
RenderWidgetHostViewBase* WebContentsViewGuest::CreateViewForWidget(
|
|
|
|
- RenderWidgetHost* render_widget_host, bool is_guest_view_hack) {
|
|
|
|
+ RenderWidgetHost* render_widget_host,
|
|
|
|
+ RenderWidgetHost* embedder_render_widget_host) {
|
|
|
|
if (render_widget_host->GetView()) {
|
|
|
|
// During testing, the view will already be set up in most cases to the
|
|
|
|
// test view, so we don't want to clobber it with a real one. To verify that
|
2019-07-16 19:59:21 +02:00
|
|
|
@@ -132,11 +137,19 @@ RenderWidgetHostViewBase* WebContentsViewGuest::CreateViewForWidget(
|
2017-02-10 23:44:11 +01:00
|
|
|
render_widget_host->GetView());
|
|
|
|
}
|
|
|
|
|
|
|
|
+ embedder_render_widget_host =
|
|
|
|
+ guest_->embedder_web_contents()->GetRenderViewHost()->GetWidget();
|
|
|
|
RenderWidgetHostViewBase* platform_widget =
|
|
|
|
- platform_view_->CreateViewForWidget(render_widget_host, true);
|
|
|
|
+ platform_view_->CreateViewForWidget(render_widget_host,
|
|
|
|
+ embedder_render_widget_host);
|
|
|
|
|
|
|
|
- return RenderWidgetHostViewGuest::Create(render_widget_host, guest_,
|
|
|
|
- platform_widget->GetWeakPtr());
|
|
|
|
+ RenderWidgetHostViewGuest* guest_view =
|
|
|
|
+ RenderWidgetHostViewGuest::Create(render_widget_host, guest_,
|
|
|
|
+ platform_widget->GetWeakPtr());
|
|
|
|
+ platform_widget->InitAsGuest(embedder_render_widget_host->GetView(),
|
|
|
|
+ guest_view);
|
2015-07-16 23:40:01 +02:00
|
|
|
+
|
2017-02-10 23:44:11 +01:00
|
|
|
+ return guest_view;
|
|
|
|
}
|
|
|
|
|
2018-10-02 14:14:11 +02:00
|
|
|
RenderWidgetHostViewBase* WebContentsViewGuest::CreateViewForChildWidget(
|
2017-02-10 23:44:11 +01:00
|
|
|
diff --git content/browser/web_contents/web_contents_view_guest.h content/browser/web_contents/web_contents_view_guest.h
|
2019-03-13 22:27:37 +01:00
|
|
|
index 913fbc4bb00e..731a81c72803 100644
|
2017-02-10 23:44:11 +01:00
|
|
|
--- content/browser/web_contents/web_contents_view_guest.h
|
|
|
|
+++ content/browser/web_contents/web_contents_view_guest.h
|
2018-03-20 21:15:08 +01:00
|
|
|
@@ -58,7 +58,7 @@ class WebContentsViewGuest : public WebContentsView,
|
2017-02-10 23:44:11 +01:00
|
|
|
gfx::NativeView context) override;
|
|
|
|
RenderWidgetHostViewBase* CreateViewForWidget(
|
|
|
|
RenderWidgetHost* render_widget_host,
|
|
|
|
- bool is_guest_view_hack) override;
|
|
|
|
+ RenderWidgetHost* embedder_render_widget_host) override;
|
2018-10-02 14:14:11 +02:00
|
|
|
RenderWidgetHostViewBase* CreateViewForChildWidget(
|
2017-02-10 23:44:11 +01:00
|
|
|
RenderWidgetHost* render_widget_host) override;
|
|
|
|
void SetPageTitle(const base::string16& title) override;
|
|
|
|
diff --git content/browser/web_contents/web_contents_view_mac.h content/browser/web_contents/web_contents_view_mac.h
|
2019-09-04 17:13:32 +02:00
|
|
|
index 35da7e53b6a6..df938f455be2 100644
|
2017-02-10 23:44:11 +01:00
|
|
|
--- content/browser/web_contents/web_contents_view_mac.h
|
|
|
|
+++ content/browser/web_contents/web_contents_view_mac.h
|
2019-09-04 17:13:32 +02:00
|
|
|
@@ -77,7 +77,7 @@ class WebContentsViewMac : public WebContentsView,
|
2017-02-10 23:44:11 +01:00
|
|
|
gfx::NativeView context) override;
|
|
|
|
RenderWidgetHostViewBase* CreateViewForWidget(
|
|
|
|
RenderWidgetHost* render_widget_host,
|
|
|
|
- bool is_guest_view_hack) override;
|
|
|
|
+ RenderWidgetHost* embedder_render_widget_host) override;
|
2018-10-02 14:14:11 +02:00
|
|
|
RenderWidgetHostViewBase* CreateViewForChildWidget(
|
2017-02-10 23:44:11 +01:00
|
|
|
RenderWidgetHost* render_widget_host) override;
|
|
|
|
void SetPageTitle(const base::string16& title) override;
|
|
|
|
diff --git content/browser/web_contents/web_contents_view_mac.mm content/browser/web_contents/web_contents_view_mac.mm
|
2019-10-01 15:55:16 +02:00
|
|
|
index b35b9b48b53c..bfa5f5409d5d 100644
|
2017-02-10 23:44:11 +01:00
|
|
|
--- content/browser/web_contents/web_contents_view_mac.mm
|
|
|
|
+++ content/browser/web_contents/web_contents_view_mac.mm
|
2019-09-04 17:13:32 +02:00
|
|
|
@@ -327,7 +327,8 @@ void WebContentsViewMac::CreateView(
|
2017-02-10 23:44:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
RenderWidgetHostViewBase* WebContentsViewMac::CreateViewForWidget(
|
|
|
|
- RenderWidgetHost* render_widget_host, bool is_guest_view_hack) {
|
|
|
|
+ RenderWidgetHost* render_widget_host,
|
|
|
|
+ RenderWidgetHost* embedder_render_widget_host) {
|
|
|
|
if (render_widget_host->GetView()) {
|
|
|
|
// During testing, the view will already be set up in most cases to the
|
|
|
|
// test view, so we don't want to clobber it with a real one. To verify that
|
2019-09-04 17:13:32 +02:00
|
|
|
@@ -339,6 +340,7 @@ RenderWidgetHostViewBase* WebContentsViewMac::CreateViewForWidget(
|
2017-03-03 23:37:23 +01:00
|
|
|
render_widget_host->GetView());
|
2017-02-10 23:44:11 +01:00
|
|
|
}
|
|
|
|
|
2017-03-03 23:37:23 +01:00
|
|
|
+ const bool is_guest_view_hack = !!embedder_render_widget_host;
|
|
|
|
RenderWidgetHostViewMac* view =
|
|
|
|
g_create_render_widget_host_view
|
|
|
|
? g_create_render_widget_host_view(render_widget_host,
|
2017-02-10 23:44:11 +01:00
|
|
|
diff --git content/public/browser/browser_plugin_guest_delegate.h content/public/browser/browser_plugin_guest_delegate.h
|
2019-09-04 17:13:32 +02:00
|
|
|
index ea12af6b86b8..f1211f374328 100644
|
2017-02-10 23:44:11 +01:00
|
|
|
--- content/public/browser/browser_plugin_guest_delegate.h
|
|
|
|
+++ content/public/browser/browser_plugin_guest_delegate.h
|
2019-07-16 19:59:21 +02:00
|
|
|
@@ -20,6 +20,7 @@ class GuestHost;
|
|
|
|
class RenderFrameHost;
|
2016-11-23 21:54:29 +01:00
|
|
|
class RenderWidgetHost;
|
|
|
|
class SiteInstance;
|
2015-07-16 23:40:01 +02:00
|
|
|
+class WebContentsView;
|
|
|
|
|
|
|
|
// Objects implement this interface to get notified about changes in the guest
|
|
|
|
// WebContents and to provide necessary functionality.
|
2019-07-16 19:59:21 +02:00
|
|
|
@@ -68,6 +69,10 @@ class CONTENT_EXPORT BrowserPluginGuestDelegate {
|
2015-07-16 23:40:01 +02:00
|
|
|
// content module.
|
|
|
|
virtual void SetGuestHost(GuestHost* guest_host) {}
|
2015-10-09 17:23:12 +02:00
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
+ // Called when a guest is attached or detached.
|
2017-02-10 23:44:11 +01:00
|
|
|
+ virtual void OnGuestAttached(content::WebContentsView* parent_view) {}
|
|
|
|
+ virtual void OnGuestDetached(content::WebContentsView* parent_view) {}
|
2015-10-09 17:23:12 +02:00
|
|
|
+
|
2018-03-20 21:15:08 +01:00
|
|
|
// TODO(ekaramad): A short workaround to force some types of guests to use
|
|
|
|
// a BrowserPlugin even when we are using cross process frames for guests. It
|
|
|
|
// should be removed after resolving https://crbug.com/642826).
|
2017-02-10 23:44:11 +01:00
|
|
|
diff --git extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc
|
2019-10-01 15:55:16 +02:00
|
|
|
index 1578ad4f86bd..a07ed1044d60 100644
|
2017-02-10 23:44:11 +01:00
|
|
|
--- extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc
|
|
|
|
+++ extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc
|
2019-09-04 17:13:32 +02:00
|
|
|
@@ -212,6 +212,8 @@ void MimeHandlerViewGuest::CreateWebContents(
|
2017-02-10 23:44:11 +01:00
|
|
|
WebContents::CreateParams params(browser_context(),
|
|
|
|
guest_site_instance.get());
|
|
|
|
params.guest_delegate = this;
|
|
|
|
+ if (delegate_)
|
|
|
|
+ delegate_->OverrideWebContentsCreateParams(¶ms);
|
2018-05-18 12:45:18 +02:00
|
|
|
// TODO(erikchen): Fix ownership semantics for guest views.
|
|
|
|
// https://crbug.com/832879.
|
2018-07-02 19:11:49 +02:00
|
|
|
std::move(callback).Run(
|
2019-09-04 17:13:32 +02:00
|
|
|
@@ -256,6 +258,18 @@ bool MimeHandlerViewGuest::ShouldDestroyOnDetach() const {
|
2017-09-06 23:40:58 +02:00
|
|
|
return true;
|
2017-02-10 23:44:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
+void MimeHandlerViewGuest::OnGuestAttached(
|
|
|
|
+ content::WebContentsView* parent_view) {
|
|
|
|
+ if (delegate_)
|
|
|
|
+ delegate_->OnGuestAttached(parent_view);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void MimeHandlerViewGuest::OnGuestDetached(
|
|
|
|
+ content::WebContentsView* parent_view) {
|
|
|
|
+ if (delegate_)
|
|
|
|
+ delegate_->OnGuestDetached(parent_view);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
WebContents* MimeHandlerViewGuest::OpenURLFromTab(
|
|
|
|
WebContents* source,
|
|
|
|
const content::OpenURLParams& params) {
|
|
|
|
diff --git extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h
|
2019-09-04 17:13:32 +02:00
|
|
|
index a608b0f31be0..025e4ed3af85 100644
|
2017-02-10 23:44:11 +01:00
|
|
|
--- extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h
|
|
|
|
+++ extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h
|
2019-09-04 17:13:32 +02:00
|
|
|
@@ -125,6 +125,10 @@ class MimeHandlerViewGuest
|
2017-02-10 23:44:11 +01:00
|
|
|
bool ZoomPropagatesFromEmbedderToGuest() const final;
|
2017-09-06 23:40:58 +02:00
|
|
|
bool ShouldDestroyOnDetach() const final;
|
2017-02-10 23:44:11 +01:00
|
|
|
|
|
|
|
+ // content::BrowserPluginGuestDelegate implementation
|
|
|
|
+ void OnGuestAttached(content::WebContentsView* parent_view) override;
|
|
|
|
+ void OnGuestDetached(content::WebContentsView* parent_view) override;
|
|
|
|
+
|
|
|
|
// WebContentsDelegate implementation.
|
|
|
|
content::WebContents* OpenURLFromTab(
|
|
|
|
content::WebContents* source,
|
|
|
|
diff --git extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h
|
2019-07-16 19:59:21 +02:00
|
|
|
index 98689e261460..c501568b6f70 100644
|
2017-02-10 23:44:11 +01:00
|
|
|
--- extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h
|
|
|
|
+++ extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h
|
2019-07-16 19:59:21 +02:00
|
|
|
@@ -8,9 +8,9 @@
|
|
|
|
#include <string>
|
2017-02-10 23:44:11 +01:00
|
|
|
|
|
|
|
#include "base/macros.h"
|
|
|
|
+#include "content/public/browser/web_contents.h"
|
|
|
|
|
|
|
|
namespace content {
|
|
|
|
-class WebContents;
|
|
|
|
struct ContextMenuParams;
|
|
|
|
} // namespace content
|
|
|
|
|
2019-07-16 19:59:21 +02:00
|
|
|
@@ -22,6 +22,14 @@ class MimeHandlerViewGuestDelegate {
|
2017-02-10 23:44:11 +01:00
|
|
|
MimeHandlerViewGuestDelegate() {}
|
|
|
|
virtual ~MimeHandlerViewGuestDelegate() {}
|
2017-04-27 03:59:52 +02:00
|
|
|
|
2017-02-10 23:44:11 +01:00
|
|
|
+ // Provides an opportunity to supply a custom view implementation.
|
|
|
|
+ virtual void OverrideWebContentsCreateParams(
|
|
|
|
+ content::WebContents::CreateParams* params) {}
|
|
|
|
+
|
|
|
|
+ // Called when a guest is attached or detached.
|
|
|
|
+ virtual void OnGuestAttached(content::WebContentsView* parent_view) {}
|
|
|
|
+ virtual void OnGuestDetached(content::WebContentsView* parent_view) {}
|
2017-04-27 03:59:52 +02:00
|
|
|
+
|
2017-02-10 23:44:11 +01:00
|
|
|
// Handles context menu, or returns false if unhandled.
|
|
|
|
virtual bool HandleContextMenu(content::WebContents* web_contents,
|
2017-04-27 03:59:52 +02:00
|
|
|
const content::ContextMenuParams& params);
|