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
|
2023-01-30 18:43:54 +01:00
|
|
|
index ddf25382e49fc..fe64fa31a7a85 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
|
2022-05-19 12:28:44 +02:00
|
|
|
@@ -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.
|
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
|
2023-02-27 19:52:38 +01:00
|
|
|
index 44d0b99677a74..843c49ccaecc3 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
|
2023-01-30 18:43:54 +01:00
|
|
|
@@ -228,6 +228,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()
|
2023-01-30 18:43:54 +01:00
|
|
|
@@ -236,6 +238,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());
|
2023-02-27 19:52:38 +01:00
|
|
|
@@ -497,6 +503,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
|
2023-02-27 19:52:38 +01:00
|
|
|
index 2ade4d0b28ba4..8ba6293863a93 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-02-27 19:52:38 +01:00
|
|
|
@@ -196,6 +196,7 @@ 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_;
|
2023-02-27 19:52:38 +01:00
|
|
|
@@ -204,6 +205,7 @@ class MimeHandlerViewGuest
|
2021-05-04 19:25:25 +02:00
|
|
|
content::ChildProcessHost::kInvalidUniqueID, MSG_ROUTING_NONE};
|
|
|
|
int embedder_widget_routing_id_ = MSG_ROUTING_NONE;
|
|
|
|
|
|
|
|
+ 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
|