• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1diff --git content/browser/web_contents/web_contents_view.h content/browser/web_contents/web_contents_view.h
2index 2c29b5c5c96b9..9ba3aaa327478 100644
3--- content/browser/web_contents/web_contents_view.h
4+++ content/browser/web_contents/web_contents_view.h
5@@ -21,7 +21,7 @@ struct DropData;
6 // The WebContentsView is an interface that is implemented by the platform-
7 // dependent web contents views. The WebContents uses this interface to talk to
8 // them.
9-class WebContentsView {
10+class CONTENT_EXPORT WebContentsView {
11  public:
12   virtual ~WebContentsView() = default;
13
14diff --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
15index 2a8095bb93264..2ee0f179d1002 100644
16--- extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc
17+++ extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.cc
18@@ -210,6 +210,8 @@ void MimeHandlerViewGuest::CreateWebContents(
19   WebContents::CreateParams params(browser_context(),
20                                    guest_site_instance.get());
21   params.guest_delegate = this;
22+  if (delegate_)
23+    delegate_->OverrideWebContentsCreateParams(&params);
24   // TODO(erikchen): Fix ownership semantics for guest views.
25   // https://crbug.com/832879.
26   std::move(callback).Run(
27@@ -220,6 +222,10 @@ void MimeHandlerViewGuest::CreateWebContents(
28 }
29
30 void MimeHandlerViewGuest::DidAttachToEmbedder() {
31+  is_guest_attached_ = true;
32+  if (delegate_)
33+    delegate_->OnGuestAttached();
34+
35   DCHECK(stream_->handler_url().SchemeIs(extensions::kExtensionScheme));
36   web_contents()->GetController().LoadURL(
37       stream_->handler_url(), content::Referrer(),
38@@ -250,6 +256,11 @@ bool MimeHandlerViewGuest::ShouldDestroyOnDetach() const {
39   return true;
40 }
41
42+void MimeHandlerViewGuest::WillDestroy() {
43+  if (is_guest_attached_ && delegate_)
44+    delegate_->OnGuestDetached();
45+}
46+
47 WebContents* MimeHandlerViewGuest::OpenURLFromTab(
48     WebContents* source,
49     const content::OpenURLParams& params) {
50diff --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
51index 1b388778aac14..0ac4a5294dfa1 100644
52--- extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h
53+++ extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest.h
54@@ -143,6 +143,7 @@ class MimeHandlerViewGuest
55   void EmbedderFullscreenToggled(bool entered_fullscreen) final;
56   bool ZoomPropagatesFromEmbedderToGuest() const final;
57   bool ShouldDestroyOnDetach() const final;
58+  void WillDestroy() override;
59
60   // WebContentsDelegate implementation.
61   content::WebContents* OpenURLFromTab(
62@@ -200,6 +201,7 @@ class MimeHandlerViewGuest
63       content::ChildProcessHost::kInvalidUniqueID, MSG_ROUTING_NONE};
64   int embedder_widget_routing_id_ = MSG_ROUTING_NONE;
65
66+  bool is_guest_attached_ = false;
67   bool is_guest_fullscreen_ = false;
68   bool is_embedder_fullscreen_ = false;
69   bool plugin_can_save_ = false;
70diff --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
71index d97b054a8d6c7..9fd96a8f7826d 100644
72--- extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h
73+++ extensions/browser/guest_view/mime_handler_view/mime_handler_view_guest_delegate.h
74@@ -7,6 +7,8 @@
75
76 #include <string>
77
78+#include "content/public/browser/web_contents.h"
79+
80 namespace content {
81 class RenderFrameHost;
82 struct ContextMenuParams;
83@@ -25,6 +27,14 @@ class MimeHandlerViewGuestDelegate {
84
85   virtual ~MimeHandlerViewGuestDelegate() {}
86
87+  // Provides an opportunity to supply a custom view implementation.
88+  virtual void OverrideWebContentsCreateParams(
89+      content::WebContents::CreateParams* params) {}
90+
91+  // Called when a guest is attached or detached.
92+  virtual void OnGuestAttached() {}
93+  virtual void OnGuestDetached() {}
94+
95   // Handles context menu, or returns false if unhandled.
96   //
97   // The `render_frame_host` represents the frame that requests the context menu
98