cef/patch/patches/mime_handler_view_guest_156...

91 lines
3.8 KiB
Diff

diff --git content/browser/web_contents/web_contents_view.h content/browser/web_contents/web_contents_view.h
index 954e32c842a5..7563507d52d0 100644
--- content/browser/web_contents/web_contents_view.h
+++ content/browser/web_contents/web_contents_view.h
@@ -23,7 +23,7 @@ struct DropData;
// 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() {}
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
index 998d6d0c481f..e0f95ee4f7a0 100644
--- extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc
+++ extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc
@@ -207,6 +207,8 @@ void MimeHandlerViewGuest::CreateWebContents(
WebContents::CreateParams params(browser_context(),
guest_site_instance.get());
params.guest_delegate = this;
+ if (delegate_)
+ delegate_->OverrideWebContentsCreateParams(&params);
// TODO(erikchen): Fix ownership semantics for guest views.
// https://crbug.com/832879.
std::move(callback).Run(
@@ -217,6 +219,9 @@ void MimeHandlerViewGuest::CreateWebContents(
}
void MimeHandlerViewGuest::DidAttachToEmbedder() {
+ if (delegate_)
+ delegate_->OnGuestAttached();
+
web_contents()->GetController().LoadURL(
stream_->handler_url(), content::Referrer(),
ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string());
@@ -246,6 +251,11 @@ bool MimeHandlerViewGuest::ShouldDestroyOnDetach() const {
return true;
}
+void MimeHandlerViewGuest::WillDestroy() {
+ if (delegate_)
+ delegate_->OnGuestDetached();
+}
+
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
index a7f0b19a8ab9..dca296badbf6 100644
--- extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h
+++ extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h
@@ -129,6 +129,7 @@ class MimeHandlerViewGuest
void EmbedderFullscreenToggled(bool entered_fullscreen) final;
bool ZoomPropagatesFromEmbedderToGuest() const final;
bool ShouldDestroyOnDetach() const final;
+ void WillDestroy() override;
// WebContentsDelegate implementation.
content::WebContents* OpenURLFromTab(
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
index 98689e261460..a1b08274f455 100644
--- 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
@@ -8,9 +8,9 @@
#include <string>
#include "base/macros.h"
+#include "content/public/browser/web_contents.h"
namespace content {
-class WebContents;
struct ContextMenuParams;
} // namespace content
@@ -22,6 +22,14 @@ class MimeHandlerViewGuestDelegate {
MimeHandlerViewGuestDelegate() {}
virtual ~MimeHandlerViewGuestDelegate() {}
+ // 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() {}
+ virtual void OnGuestDetached() {}
+
// Handles context menu, or returns false if unhandled.
virtual bool HandleContextMenu(content::WebContents* web_contents,
const content::ContextMenuParams& params);