diff options
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/browser_plugin/browser_plugin_guest.cc | 14 | ||||
-rw-r--r-- | content/browser/browser_plugin/browser_plugin_guest.h | 4 | ||||
-rw-r--r-- | content/public/browser/browser_plugin_guest_delegate.h | 5 |
3 files changed, 21 insertions, 2 deletions
diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc index 79e0dff..c43717b 100644 --- a/content/browser/browser_plugin/browser_plugin_guest.cc +++ b/content/browser/browser_plugin/browser_plugin_guest.cc @@ -631,9 +631,21 @@ void BrowserPluginGuest::Attach( ack); last_pending_frame_.reset(); } + + // The guest is owned by the embedder. Attach is queued up so we cannot + // change embedders before attach completes. If the embedder goes away, + // so does the guest and so we will never call WillAttachComplete because + // we have a weak ptr. delegate_->WillAttach(embedder_web_contents, browser_plugin_instance_id, - params.is_full_page_plugin); + params.is_full_page_plugin, + base::Bind(&BrowserPluginGuest::OnWillAttachComplete, + weak_ptr_factory_.GetWeakPtr(), + embedder_web_contents, params)); +} +void BrowserPluginGuest::OnWillAttachComplete( + WebContentsImpl* embedder_web_contents, + const BrowserPluginHostMsg_Attach_Params& params) { // If a RenderView has already been created for this new window, then we need // to initialize the browser-side state now so that the RenderFrameHostManager // does not create a new RenderView on navigation. diff --git a/content/browser/browser_plugin/browser_plugin_guest.h b/content/browser/browser_plugin/browser_plugin_guest.h index 946d8d9..86278b9 100644 --- a/content/browser/browser_plugin/browser_plugin_guest.h +++ b/content/browser/browser_plugin/browser_plugin_guest.h @@ -339,6 +339,10 @@ class CONTENT_EXPORT BrowserPluginGuest : public GuestHost, bool is_top_level, const std::string& name); + // Called when WillAttach is complete. + void OnWillAttachComplete(WebContentsImpl* embedder_web_contents, + const BrowserPluginHostMsg_Attach_Params& params); + // Forwards all messages from the |pending_messages_| queue to the embedder. void SendQueuedMessages(); diff --git a/content/public/browser/browser_plugin_guest_delegate.h b/content/public/browser/browser_plugin_guest_delegate.h index fdc3037..000e3b6 100644 --- a/content/public/browser/browser_plugin_guest_delegate.h +++ b/content/public/browser/browser_plugin_guest_delegate.h @@ -31,9 +31,12 @@ class CONTENT_EXPORT BrowserPluginGuestDelegate { // Notification that the embedder will begin attachment. This is called // prior to resuming resource loads. |element_instance_id| uniquely identifies // the element that will serve as a container for the guest. + // Once the content embedder has completed setting up state for attachment, it + // must call the |completion_callback| to complete attachment. virtual void WillAttach(content::WebContents* embedder_web_contents, int element_instance_id, - bool is_full_page_plugin) {} + bool is_full_page_plugin, + const base::Closure& completion_callback) {} virtual WebContents* CreateNewGuestWindow( const WebContents::CreateParams& create_params); |