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
|
2022-05-19 12:28:44 +02:00
|
|
|
index 17f203b11ce39..0a5277b686d61 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
|
2022-06-17 15:28:55 +02:00
|
|
|
index aef9d1a79fcea..015206dd88756 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
|
2022-03-26 02:12:30 +01:00
|
|
|
@@ -224,6 +224,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);
|
2018-05-18 12:45:18 +02:00
|
|
|
// TODO(erikchen): Fix ownership semantics for guest views.
|
|
|
|
// https://crbug.com/832879.
|
2018-07-02 19:11:49 +02:00
|
|
|
std::move(callback).Run(
|
2022-03-26 02:12:30 +01:00
|
|
|
@@ -234,6 +236,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));
|
2020-01-23 22:58:01 +01:00
|
|
|
web_contents()->GetController().LoadURL(
|
|
|
|
stream_->handler_url(), content::Referrer(),
|
2022-03-26 02:12:30 +01:00
|
|
|
@@ -264,6 +270,11 @@ bool MimeHandlerViewGuest::ShouldDestroyOnDetach() const {
|
2020-01-23 22:58:01 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
+void MimeHandlerViewGuest::WillDestroy() {
|
2021-05-04 19:25:25 +02:00
|
|
|
+ if (is_guest_attached_ && delegate_)
|
2020-01-23 22:58:01 +01:00
|
|
|
+ delegate_->OnGuestDetached();
|
2017-02-10 23:44:11 +01:00
|
|
|
+}
|
|
|
|
+
|
|
|
|
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
|
2022-02-21 23:23:40 +01:00
|
|
|
index ef6faf317dd41..8675c305d489c 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
|
2021-12-16 23:35:54 +01:00
|
|
|
@@ -143,6 +143,7 @@ class MimeHandlerViewGuest
|
2020-01-23 22:58:01 +01:00
|
|
|
void EmbedderFullscreenToggled(bool entered_fullscreen) final;
|
2017-02-10 23:44:11 +01:00
|
|
|
bool ZoomPropagatesFromEmbedderToGuest() const final;
|
2017-09-06 23:40:58 +02:00
|
|
|
bool ShouldDestroyOnDetach() const final;
|
2020-01-23 22:58:01 +01:00
|
|
|
+ void WillDestroy() override;
|
2017-02-10 23:44:11 +01:00
|
|
|
|
|
|
|
// WebContentsDelegate implementation.
|
|
|
|
content::WebContents* OpenURLFromTab(
|
2022-01-25 21:26:51 +01:00
|
|
|
@@ -200,6 +201,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
|
2021-12-16 23:35:54 +01:00
|
|
|
index d97b054a8d6c7..9fd96a8f7826d 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
|