98 lines
4.2 KiB
Diff
98 lines
4.2 KiB
Diff
diff --git content/browser/web_contents/web_contents_view.h content/browser/web_contents/web_contents_view.h
|
|
index 66c632b1818a6..fca4dcbb4a38b 100644
|
|
--- content/browser/web_contents/web_contents_view.h
|
|
+++ content/browser/web_contents/web_contents_view.h
|
|
@@ -25,7 +25,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() = default;
|
|
|
|
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 02f204564a67e..2500ebbc92cb3 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
|
|
@@ -202,6 +202,8 @@ void MimeHandlerViewGuest::CreateWebContents(
|
|
WebContents::CreateParams params(browser_context(),
|
|
guest_site_instance.get());
|
|
params.guest_delegate = this;
|
|
+ if (delegate_)
|
|
+ delegate_->OverrideWebContentsCreateParams(¶ms);
|
|
std::move(callback).Run(std::move(owned_this),
|
|
WebContents::CreateWithSessionStorage(
|
|
params, owner_web_contents()
|
|
@@ -210,6 +212,10 @@ void MimeHandlerViewGuest::CreateWebContents(
|
|
}
|
|
|
|
void MimeHandlerViewGuest::DidAttachToEmbedder() {
|
|
+ is_guest_attached_ = true;
|
|
+ if (delegate_)
|
|
+ delegate_->OnGuestAttached();
|
|
+
|
|
DCHECK(stream_->handler_url().SchemeIs(extensions::kExtensionScheme));
|
|
GetController().LoadURL(stream_->handler_url(), content::Referrer(),
|
|
ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string());
|
|
@@ -480,6 +486,14 @@ void MimeHandlerViewGuest::DidFinishNavigation(
|
|
}
|
|
}
|
|
|
|
+void MimeHandlerViewGuest::WebContentsDestroyed() {
|
|
+ if (is_guest_attached_ && delegate_)
|
|
+ delegate_->OnGuestDetached();
|
|
+
|
|
+ // May delete |this|.
|
|
+ GuestView<MimeHandlerViewGuest>::WebContentsDestroyed();
|
|
+}
|
|
+
|
|
void MimeHandlerViewGuest::FuseBeforeUnloadControl(
|
|
mojo::PendingReceiver<mime_handler::BeforeUnloadControl> receiver) {
|
|
if (!pending_before_unload_control_)
|
|
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 a5066da1a593c..880fc3c87e48f 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
|
|
@@ -195,10 +195,12 @@ class MimeHandlerViewGuest
|
|
void ReadyToCommitNavigation(
|
|
content::NavigationHandle* navigation_handle) final;
|
|
void DidFinishNavigation(content::NavigationHandle* navigation_handle) final;
|
|
+ void WebContentsDestroyed() override;
|
|
|
|
std::unique_ptr<MimeHandlerViewGuestDelegate> delegate_;
|
|
std::unique_ptr<StreamContainer> stream_;
|
|
|
|
+ bool is_guest_attached_ = false;
|
|
bool is_guest_fullscreen_ = false;
|
|
bool is_embedder_fullscreen_ = false;
|
|
bool plugin_can_save_ = false;
|
|
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 7f59e7925084e..777b8a3cf103a 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
|
|
@@ -7,6 +7,8 @@
|
|
|
|
#include <string>
|
|
|
|
+#include "content/public/browser/web_contents.h"
|
|
+
|
|
namespace content {
|
|
class RenderFrameHost;
|
|
struct ContextMenuParams;
|
|
@@ -25,6 +27,14 @@ class 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.
|
|
//
|
|
// The `render_frame_host` represents the frame that requests the context menu
|