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
|
2021-04-21 00:52:34 +02:00
|
|
|
index cdbc0273838e5..ee2809a0bb98a 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
|
2021-04-21 00:52:34 +02:00
|
|
|
@@ -22,7 +22,7 @@ struct DropData;
|
2017-07-27 01:19:27 +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.
|
|
|
|
-class WebContentsView {
|
|
|
|
+class CONTENT_EXPORT WebContentsView {
|
|
|
|
public:
|
|
|
|
virtual ~WebContentsView() {}
|
|
|
|
|
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
|
2021-06-04 03:34:56 +02:00
|
|
|
index a28112a99dfdc..bcd58be410e10 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
|
2021-04-21 00:52:34 +02:00
|
|
|
@@ -205,6 +205,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(
|
2021-05-04 19:25:25 +02:00
|
|
|
@@ -215,6 +217,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(),
|
2021-05-04 19:25:25 +02:00
|
|
|
@@ -245,6 +251,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
|
2021-05-04 19:25:25 +02:00
|
|
|
index 7d27e12c4e9a7..fc234840104ea 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-04-21 00:52:34 +02:00
|
|
|
@@ -130,6 +130,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(
|
2021-05-04 19:25:25 +02:00
|
|
|
@@ -188,6 +189,7 @@ class MimeHandlerViewGuest
|
|
|
|
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-04-21 00:52:34 +02:00
|
|
|
index 98689e2614604..a1b08274f4556 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
|
2019-07-16 19:59:21 +02:00
|
|
|
@@ -8,9 +8,9 @@
|
|
|
|
#include <string>
|
2017-02-10 23:44:11 +01:00
|
|
|
|
|
|
|
#include "base/macros.h"
|
|
|
|
+#include "content/public/browser/web_contents.h"
|
|
|
|
|
|
|
|
namespace content {
|
|
|
|
-class WebContents;
|
|
|
|
struct ContextMenuParams;
|
|
|
|
} // namespace content
|
|
|
|
|
2019-07-16 19:59:21 +02:00
|
|
|
@@ -22,6 +22,14 @@ class MimeHandlerViewGuestDelegate {
|
2017-02-10 23:44:11 +01:00
|
|
|
MimeHandlerViewGuestDelegate() {}
|
|
|
|
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.
|
|
|
|
virtual bool HandleContextMenu(content::WebContents* web_contents,
|
2017-04-27 03:59:52 +02:00
|
|
|
const content::ContextMenuParams& params);
|