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
|
2024-02-22 19:36:15 +01:00
|
|
|
index e0887cdb49c7c..d2bf0571793cf 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
|
2024-02-22 19:36:15 +01:00
|
|
|
@@ -26,7 +26,7 @@ struct DropData;
|
2022-05-19 12:28:44 +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.
|
2017-07-27 01:19:27 +02:00
|
|
|
-class WebContentsView {
|
|
|
|
+class CONTENT_EXPORT WebContentsView {
|
|
|
|
public:
|
2021-12-16 23:35:54 +01:00
|
|
|
virtual ~WebContentsView() = default;
|
2017-07-27 01:19:27 +02:00
|
|
|
|
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
|
2024-02-22 19:36:15 +01:00
|
|
|
index 39def4c0d8ad5..6e856ae9bcd96 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
|
2024-02-22 19:36:15 +01:00
|
|
|
@@ -203,6 +203,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);
|
2022-10-17 19:27:40 +02:00
|
|
|
std::move(callback).Run(std::move(owned_this),
|
|
|
|
WebContents::CreateWithSessionStorage(
|
|
|
|
params, owner_web_contents()
|
2024-02-22 19:36:15 +01:00
|
|
|
@@ -211,6 +213,10 @@ void MimeHandlerViewGuest::CreateWebContents(
|
2017-02-10 23:44:11 +01:00
|
|
|
}
|
|
|
|
|
2020-01-23 22:58:01 +01:00
|
|
|
void MimeHandlerViewGuest::DidAttachToEmbedder() {
|
2021-05-04 19:25:25 +02:00
|
|
|
+ is_guest_attached_ = true;
|
2017-02-10 23:44:11 +01:00
|
|
|
+ if (delegate_)
|
2020-01-23 22:58:01 +01:00
|
|
|
+ delegate_->OnGuestAttached();
|
2017-02-10 23:44:11 +01:00
|
|
|
+
|
2021-03-04 23:36:57 +01:00
|
|
|
DCHECK(stream_->handler_url().SchemeIs(extensions::kExtensionScheme));
|
2022-10-17 19:27:40 +02:00
|
|
|
GetController().LoadURL(stream_->handler_url(), content::Referrer(),
|
|
|
|
ui::PAGE_TRANSITION_AUTO_TOPLEVEL, std::string());
|
2024-02-22 19:36:15 +01:00
|
|
|
@@ -481,6 +487,14 @@ void MimeHandlerViewGuest::DidFinishNavigation(
|
2022-10-17 19:27:40 +02:00
|
|
|
}
|
2020-01-23 22:58:01 +01:00
|
|
|
}
|
|
|
|
|
2022-10-17 19:27:40 +02:00
|
|
|
+void MimeHandlerViewGuest::WebContentsDestroyed() {
|
2021-05-04 19:25:25 +02:00
|
|
|
+ if (is_guest_attached_ && delegate_)
|
2020-01-23 22:58:01 +01:00
|
|
|
+ delegate_->OnGuestDetached();
|
2022-10-17 19:27:40 +02:00
|
|
|
+
|
|
|
|
+ // May delete |this|.
|
|
|
|
+ GuestView<MimeHandlerViewGuest>::WebContentsDestroyed();
|
2017-02-10 23:44:11 +01:00
|
|
|
+}
|
|
|
|
+
|
2022-10-17 19:27:40 +02:00
|
|
|
void MimeHandlerViewGuest::FuseBeforeUnloadControl(
|
|
|
|
mojo::PendingReceiver<mime_handler::BeforeUnloadControl> receiver) {
|
|
|
|
if (!pending_before_unload_control_)
|
2017-02-10 23:44:11 +01:00
|
|
|
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
|
2024-02-22 19:36:15 +01:00
|
|
|
index 5709e978f2d8e..c1f1720a31e1a 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
|
2023-11-21 20:17:55 +01:00
|
|
|
@@ -195,10 +195,12 @@ class MimeHandlerViewGuest
|
2022-10-17 19:27:40 +02:00
|
|
|
void ReadyToCommitNavigation(
|
|
|
|
content::NavigationHandle* navigation_handle) final;
|
|
|
|
void DidFinishNavigation(content::NavigationHandle* navigation_handle) final;
|
|
|
|
+ void WebContentsDestroyed() override;
|
2017-02-10 23:44:11 +01:00
|
|
|
|
2022-10-17 19:27:40 +02:00
|
|
|
std::unique_ptr<MimeHandlerViewGuestDelegate> delegate_;
|
|
|
|
std::unique_ptr<StreamContainer> stream_;
|
2021-05-04 19:25:25 +02:00
|
|
|
|
|
|
|
+ bool is_guest_attached_ = false;
|
|
|
|
bool is_guest_fullscreen_ = false;
|
|
|
|
bool is_embedder_fullscreen_ = false;
|
|
|
|
bool plugin_can_save_ = false;
|
2017-02-10 23:44:11 +01:00
|
|
|
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
|
2022-09-26 21:30:45 +02:00
|
|
|
index 7f59e7925084e..777b8a3cf103a 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
|
2021-12-16 23:35:54 +01:00
|
|
|
@@ -7,6 +7,8 @@
|
|
|
|
|
2019-07-16 19:59:21 +02:00
|
|
|
#include <string>
|
2017-02-10 23:44:11 +01:00
|
|
|
|
|
|
|
+#include "content/public/browser/web_contents.h"
|
2021-12-16 23:35:54 +01:00
|
|
|
+
|
2017-02-10 23:44:11 +01:00
|
|
|
namespace content {
|
2021-11-10 22:57:31 +01:00
|
|
|
class RenderFrameHost;
|
2021-12-16 23:35:54 +01:00
|
|
|
struct ContextMenuParams;
|
|
|
|
@@ -25,6 +27,14 @@ class MimeHandlerViewGuestDelegate {
|
2021-10-19 00:17:16 +02:00
|
|
|
|
2017-02-10 23:44:11 +01:00
|
|
|
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.
|
2020-01-23 22:58:01 +01:00
|
|
|
+ virtual void OnGuestAttached() {}
|
|
|
|
+ virtual void OnGuestDetached() {}
|
2017-04-27 03:59:52 +02:00
|
|
|
+
|
2017-02-10 23:44:11 +01:00
|
|
|
// Handles context menu, or returns false if unhandled.
|
2021-11-10 22:57:31 +01:00
|
|
|
//
|
|
|
|
// The `render_frame_host` represents the frame that requests the context menu
|