cef/patch/patches/browser_plugin_guest_1565.p...

121 lines
5.0 KiB
Diff

diff --git browser/browser_plugin/browser_plugin_guest.cc browser/browser_plugin/browser_plugin_guest.cc
index 97ea047..1efbcf9 100644
--- browser/browser_plugin/browser_plugin_guest.cc
+++ browser/browser_plugin/browser_plugin_guest.cc
@@ -29,7 +29,7 @@
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include "content/browser/web_contents/web_contents_impl.h"
-#include "content/browser/web_contents/web_contents_view_guest.h"
+#include "content/browser/web_contents/web_contents_view.h"
#include "content/common/browser_plugin/browser_plugin_constants.h"
#include "content/common/browser_plugin/browser_plugin_messages.h"
#include "content/common/content_constants_internal.h"
@@ -310,20 +310,19 @@ void BrowserPluginGuest::InitInternal(
guest_window_rect_ = params.view_rect;
if (owner_web_contents_ != owner_web_contents) {
- WebContentsViewGuest* new_view = nullptr;
+ WebContentsView* new_view = nullptr;
if (!GuestMode::IsCrossProcessFrameGuest(GetWebContents())) {
- new_view =
- static_cast<WebContentsViewGuest*>(GetWebContents()->GetView());
+ new_view = GetWebContents()->GetView();
}
if (owner_web_contents_ && new_view)
- new_view->OnGuestDetached(owner_web_contents_->GetView());
+ delegate_->OnGuestDetached(new_view, owner_web_contents_->GetView());
// Once a BrowserPluginGuest has an embedder WebContents, it's considered to
// be attached.
owner_web_contents_ = owner_web_contents;
if (new_view)
- new_view->OnGuestAttached(owner_web_contents_->GetView());
+ delegate_->OnGuestAttached(new_view, owner_web_contents_->GetView());
}
RendererPreferences* renderer_prefs =
@@ -787,11 +786,10 @@ void BrowserPluginGuest::OnWillAttachComplete(
->GetWidget()
->Init();
GetWebContents()->GetMainFrame()->Init();
- WebContentsViewGuest* web_contents_view =
- static_cast<WebContentsViewGuest*>(GetWebContents()->GetView());
if (!web_contents()->GetRenderViewHost()->GetWidget()->GetView()) {
- web_contents_view->CreateViewForWidget(
- web_contents()->GetRenderViewHost()->GetWidget(), true);
+ delegate_->CreateViewForWidget(
+ GetWebContents()->GetView(),
+ web_contents()->GetRenderViewHost()->GetWidget());
}
}
diff --git public/browser/browser_plugin_guest_delegate.cc public/browser/browser_plugin_guest_delegate.cc
index 8d691ef..eb13b5d 100644
--- public/browser/browser_plugin_guest_delegate.cc
+++ public/browser/browser_plugin_guest_delegate.cc
@@ -4,6 +4,8 @@
#include "content/public/browser/browser_plugin_guest_delegate.h"
+#include "content/browser/web_contents/web_contents_view_guest.h"
+
namespace content {
bool BrowserPluginGuestDelegate::CanRunInDetachedState() const {
@@ -48,4 +50,23 @@ SiteInstance* BrowserPluginGuestDelegate::GetOwnerSiteInstance() {
return nullptr;
}
+void BrowserPluginGuestDelegate::OnGuestAttached(
+ content::WebContentsView* guest_view,
+ content::WebContentsView* parent_view) {
+ static_cast<WebContentsViewGuest*>(guest_view)->OnGuestAttached(parent_view);
+}
+
+void BrowserPluginGuestDelegate::OnGuestDetached(
+ content::WebContentsView* guest_view,
+ content::WebContentsView* parent_view) {
+ static_cast<WebContentsViewGuest*>(guest_view)->OnGuestAttached(parent_view);
+}
+
+void BrowserPluginGuestDelegate::CreateViewForWidget(
+ content::WebContentsView* guest_view,
+ content::RenderWidgetHost* render_widget_host) {
+ static_cast<WebContentsViewGuest*>(guest_view)->CreateViewForWidget(
+ render_widget_host, true);
+}
+
} // namespace content
diff --git public/browser/browser_plugin_guest_delegate.h public/browser/browser_plugin_guest_delegate.h
index a32205c..1d93d7b 100644
--- public/browser/browser_plugin_guest_delegate.h
+++ public/browser/browser_plugin_guest_delegate.h
@@ -19,6 +19,7 @@ namespace content {
class GuestHost;
class RenderWidgetHost;
class SiteInstance;
+class WebContentsView;
// Objects implement this interface to get notified about changes in the guest
// WebContents and to provide necessary functionality.
@@ -85,6 +86,17 @@ class CONTENT_EXPORT BrowserPluginGuestDelegate {
// content module.
virtual void SetGuestHost(GuestHost* guest_host) {}
+ // Called when a guest is attached or detached.
+ virtual void OnGuestAttached(content::WebContentsView* guest_view,
+ content::WebContentsView* parent_view);
+ virtual void OnGuestDetached(content::WebContentsView* guest_view,
+ content::WebContentsView* parent_view);
+
+ // Called to create the view for the widget.
+ virtual void CreateViewForWidget(
+ content::WebContentsView* guest_view,
+ content::RenderWidgetHost* render_widget_host);
+
// Sets the position of the context menu for the guest contents. The value
// reported from the guest renderer should be ignored. The reported value
// from the guest renderer is incorrect in situations where BrowserPlugin is