2015-07-16 23:40:01 +02:00
|
|
|
diff --git mime_handler_view_guest.cc mime_handler_view_guest.cc
|
2016-10-21 21:52:29 +02:00
|
|
|
index dcf7527..46fe51e 100644
|
2015-07-16 23:40:01 +02:00
|
|
|
--- mime_handler_view_guest.cc
|
|
|
|
+++ mime_handler_view_guest.cc
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -138,6 +138,8 @@ void MimeHandlerViewGuest::CreateWebContents(
|
2015-07-16 23:40:01 +02:00
|
|
|
WebContents::CreateParams params(browser_context(),
|
|
|
|
guest_site_instance.get());
|
|
|
|
params.guest_delegate = this;
|
|
|
|
+ if (delegate_)
|
|
|
|
+ delegate_->OverrideWebContentsCreateParams(¶ms);
|
|
|
|
callback.Run(WebContents::Create(params));
|
|
|
|
}
|
|
|
|
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -162,6 +164,30 @@ bool MimeHandlerViewGuest::ZoomPropagatesFromEmbedderToGuest() const {
|
2015-07-16 23:40:01 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
+void MimeHandlerViewGuest::OnGuestAttached(
|
|
|
|
+ content::WebContentsView* guest_view,
|
|
|
|
+ content::WebContentsView* parent_view) {
|
|
|
|
+ if (!delegate_ || !delegate_->OnGuestAttached(guest_view, parent_view))
|
|
|
|
+ BrowserPluginGuestDelegate::OnGuestAttached(guest_view, parent_view);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void MimeHandlerViewGuest::OnGuestDetached(
|
|
|
|
+ content::WebContentsView* guest_view,
|
|
|
|
+ content::WebContentsView* parent_view) {
|
|
|
|
+ if (!delegate_ || !delegate_->OnGuestDetached(guest_view, parent_view))
|
|
|
|
+ BrowserPluginGuestDelegate::OnGuestDetached(guest_view, parent_view);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void MimeHandlerViewGuest::CreateViewForWidget(
|
|
|
|
+ content::WebContentsView* guest_view,
|
|
|
|
+ content::RenderWidgetHost* render_widget_host) {
|
|
|
|
+ if (!delegate_ ||
|
|
|
|
+ !delegate_->CreateViewForWidget(guest_view, render_widget_host)) {
|
|
|
|
+ BrowserPluginGuestDelegate::CreateViewForWidget(guest_view,
|
|
|
|
+ render_widget_host);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
2015-08-26 00:33:31 +02:00
|
|
|
WebContents* MimeHandlerViewGuest::OpenURLFromTab(
|
|
|
|
WebContents* source,
|
2015-07-16 23:40:01 +02:00
|
|
|
const content::OpenURLParams& params) {
|
|
|
|
diff --git mime_handler_view_guest.h mime_handler_view_guest.h
|
2016-10-21 21:52:29 +02:00
|
|
|
index 87d249e..c6a8ad3 100644
|
2015-07-16 23:40:01 +02:00
|
|
|
--- mime_handler_view_guest.h
|
|
|
|
+++ mime_handler_view_guest.h
|
2016-10-21 21:52:29 +02:00
|
|
|
@@ -77,6 +77,15 @@ class MimeHandlerViewGuest :
|
2015-11-10 21:18:16 +01:00
|
|
|
bool ShouldHandleFindRequestsForEmbedder() const final;
|
|
|
|
bool ZoomPropagatesFromEmbedderToGuest() const final;
|
2015-08-26 00:33:31 +02:00
|
|
|
|
|
|
|
+ // content::BrowserPluginGuestDelegate implementation
|
2015-07-16 23:40:01 +02:00
|
|
|
+ void OnGuestAttached(content::WebContentsView* guest_view,
|
|
|
|
+ content::WebContentsView* parent_view) override;
|
|
|
|
+ void OnGuestDetached(content::WebContentsView* guest_view,
|
|
|
|
+ content::WebContentsView* parent_view) override;
|
|
|
|
+ void CreateViewForWidget(
|
|
|
|
+ content::WebContentsView* guest_view,
|
|
|
|
+ content::RenderWidgetHost* render_widget_host) override;
|
2015-08-26 00:33:31 +02:00
|
|
|
+
|
2015-07-16 23:40:01 +02:00
|
|
|
// WebContentsDelegate implementation.
|
|
|
|
content::WebContents* OpenURLFromTab(
|
2015-08-26 00:33:31 +02:00
|
|
|
content::WebContents* source,
|
2015-07-16 23:40:01 +02:00
|
|
|
diff --git mime_handler_view_guest_delegate.cc mime_handler_view_guest_delegate.cc
|
|
|
|
index 63b81b8..0f63f48 100644
|
|
|
|
--- mime_handler_view_guest_delegate.cc
|
|
|
|
+++ mime_handler_view_guest_delegate.cc
|
|
|
|
@@ -6,6 +6,24 @@
|
|
|
|
|
|
|
|
namespace extensions {
|
|
|
|
|
|
|
|
+bool MimeHandlerViewGuestDelegate::OnGuestAttached(
|
|
|
|
+ content::WebContentsView* guest_view,
|
|
|
|
+ content::WebContentsView* parent_view) {
|
|
|
|
+ return false;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool MimeHandlerViewGuestDelegate::OnGuestDetached(
|
|
|
|
+ content::WebContentsView* guest_view,
|
|
|
|
+ content::WebContentsView* parent_view) {
|
|
|
|
+ return false;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+bool MimeHandlerViewGuestDelegate::CreateViewForWidget(
|
|
|
|
+ content::WebContentsView* guest_view,
|
|
|
|
+ content::RenderWidgetHost* render_widget_host) {
|
|
|
|
+ return false;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
bool MimeHandlerViewGuestDelegate::HandleContextMenu(
|
|
|
|
content::WebContents* web_contents,
|
|
|
|
const content::ContextMenuParams& params) {
|
|
|
|
diff --git mime_handler_view_guest_delegate.h mime_handler_view_guest_delegate.h
|
2015-10-09 17:23:12 +02:00
|
|
|
index e065104d..f68b66c 100644
|
2015-07-16 23:40:01 +02:00
|
|
|
--- mime_handler_view_guest_delegate.h
|
|
|
|
+++ mime_handler_view_guest_delegate.h
|
|
|
|
@@ -6,10 +6,11 @@
|
|
|
|
#define EXTENSIONS_BROWSER_GUEST_VIEW_MIME_HANDLER_VIEW_MIME_HANDLER_VIEW_GUEST_DELEGATE_H_
|
|
|
|
|
|
|
|
#include "base/macros.h"
|
|
|
|
+#include "content/public/browser/web_contents.h"
|
|
|
|
|
|
|
|
namespace content {
|
|
|
|
-class WebContents;
|
|
|
|
struct ContextMenuParams;
|
|
|
|
+class RenderWidgetHost;
|
|
|
|
} // namespace content
|
|
|
|
|
|
|
|
namespace extensions {
|
2015-07-24 02:06:56 +02:00
|
|
|
@@ -21,6 +22,21 @@ class MimeHandlerViewGuestDelegate {
|
|
|
|
public:
|
|
|
|
MimeHandlerViewGuestDelegate() {}
|
2015-07-16 23:40:01 +02:00
|
|
|
virtual ~MimeHandlerViewGuestDelegate() {}
|
2015-07-24 02:06:56 +02:00
|
|
|
+
|
2015-07-16 23:40:01 +02: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 bool OnGuestAttached(content::WebContentsView* guest_view,
|
|
|
|
+ content::WebContentsView* parent_view);
|
|
|
|
+ virtual bool OnGuestDetached(content::WebContentsView* guest_view,
|
|
|
|
+ content::WebContentsView* parent_view);
|
|
|
|
+
|
|
|
|
+ // Called to create the view for the widget.
|
|
|
|
+ virtual bool CreateViewForWidget(
|
|
|
|
+ content::WebContentsView* guest_view,
|
|
|
|
+ content::RenderWidgetHost* render_widget_host);
|
|
|
|
|
2015-07-24 02:06:56 +02:00
|
|
|
// Handles context menu, or returns false if unhandled.
|
|
|
|
virtual bool HandleContextMenu(content::WebContents* web_contents,
|