Chromium Code Reviews| Index: content/browser/browser_plugin/browser_plugin_guest.cc |
| diff --git a/content/browser/browser_plugin/browser_plugin_guest.cc b/content/browser/browser_plugin/browser_plugin_guest.cc |
| index 111e7a0812e659d525ecec153f0c4a7bc7889edd..c8492a81ffa5139ddf364936c4e04e97d251be6a 100644 |
| --- a/content/browser/browser_plugin/browser_plugin_guest.cc |
| +++ b/content/browser/browser_plugin/browser_plugin_guest.cc |
| @@ -31,7 +31,7 @@ |
| #include "content/public/browser/browser_context.h" |
| #include "content/public/browser/browser_plugin_guest_manager.h" |
| #include "content/public/browser/content_browser_client.h" |
| -#include "content/public/browser/guest_sizer.h" |
| +#include "content/public/browser/guest_proxy_host.h" |
| #include "content/public/browser/render_widget_host_view.h" |
| #include "content/public/browser/user_metrics.h" |
| #include "content/public/browser/web_contents_observer.h" |
| @@ -99,15 +99,45 @@ BrowserPluginGuest::BrowserPluginGuest(bool has_render_view, |
| DCHECK(delegate); |
| RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Create")); |
| web_contents->SetBrowserPluginGuest(this); |
| - delegate->RegisterDestructionCallback( |
| - base::Bind(&BrowserPluginGuest::WillDestroy, AsWeakPtr())); |
| - delegate->SetGuestSizer(this); |
| + delegate->SetGuestProxyHost(this); |
| +} |
| + |
| +int BrowserPluginGuest::GetGuestProxyRoutingID() { |
| + // Create a swapped out RenderView for the guest in the embedder renderer |
| + // process, so that the embedder can access the guest's window object. |
| + // On reattachment, we can reuse the same swapped out RenderView because |
| + // the embedder process will always be the same even if the embedder |
| + // WebContents changes. |
| + if (guest_proxy_routing_id_ != MSG_ROUTING_NONE) |
|
Charlie Reis
2015/03/09 18:52:58
nit: Move these two lines above the previous comme
Fady Samuel
2015/03/09 23:02:41
Done.
|
| + return guest_proxy_routing_id_; |
| + |
| + // TODO(fsamuel): Make sure this works for transferring guests across |
| + // owners in different processes. We probably need to clear the |
| + // |guest_proxy_routing_id_| and perform any necessary cleanup on Detach |
| + // to enable this. |
| + SiteInstance* owner_site_instance = owner_web_contents_->GetSiteInstance(); |
| + guest_proxy_routing_id_ = |
| + GetWebContents()->CreateSwappedOutRenderView(owner_site_instance); |
| + |
| + return guest_proxy_routing_id_; |
| +} |
| + |
| +int BrowserPluginGuest::LoadURLWithParams( |
| + const NavigationController::LoadURLParams& load_params) { |
| + GetWebContents()->GetController().LoadURLWithParams(load_params); |
| + return GetGuestProxyRoutingID(); |
|
Charlie Reis
2015/03/09 18:52:58
Should we be calling this before the navigation?
Fady Samuel
2015/03/09 23:02:41
As discussed offline, this should happen after nav
|
| } |
| void BrowserPluginGuest::SizeContents(const gfx::Size& new_size) { |
| GetWebContents()->GetView()->SizeContents(new_size); |
| } |
| +void BrowserPluginGuest::WillDestroy() { |
| + is_in_destruction_ = true; |
| + owner_web_contents_ = nullptr; |
| + attached_ = false; |
| +} |
| + |
| void BrowserPluginGuest::Init() { |
| if (initialized_) |
| return; |
| @@ -121,15 +151,10 @@ void BrowserPluginGuest::Init() { |
| WebContentsImpl* owner_web_contents = static_cast<WebContentsImpl*>( |
| delegate_->GetOwnerWebContents()); |
| + owner_web_contents->CreateBrowserPluginEmbedderIfNecessary(); |
| InitInternal(BrowserPluginHostMsg_Attach_Params(), owner_web_contents); |
| } |
| -void BrowserPluginGuest::WillDestroy() { |
| - is_in_destruction_ = true; |
| - owner_web_contents_ = nullptr; |
| - attached_ = false; |
| -} |
| - |
| base::WeakPtr<BrowserPluginGuest> BrowserPluginGuest::AsWeakPtr() { |
| return weak_ptr_factory_.GetWeakPtr(); |
| } |
| @@ -620,18 +645,7 @@ void BrowserPluginGuest::Attach( |
| attached_ = true; |
| SendQueuedMessages(); |
| - // Create a swapped out RenderView for the guest in the embedder render |
| - // process, so that the embedder can access the guest's window object. |
| - // On reattachment, we can reuse the same swapped out RenderView because |
| - // the embedder process will always be the same even if the embedder |
| - // WebContents changes. |
| - if (guest_proxy_routing_id_ == MSG_ROUTING_NONE) { |
| - guest_proxy_routing_id_ = |
| - GetWebContents()->CreateSwappedOutRenderView( |
| - owner_web_contents_->GetSiteInstance()); |
| - } |
| - |
| - delegate_->DidAttach(guest_proxy_routing_id_); |
| + delegate_->DidAttach(GetGuestProxyRoutingID()); |
| has_render_view_ = true; |