Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(467)

Unified Diff: content/browser/browser_plugin/browser_plugin_guest.cc

Issue 910073003: <webview>: Make contentWindow available prior to attachment (on display:none). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use constants Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..41c2fade0c77e9e9157b4ccd02c0e1c6ea668d0c 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,43 @@ 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() const {
+ return guest_proxy_routing_id_;
+}
+
+int BrowserPluginGuest::GetOrCreateGuestProxyInOwnerProcess() {
Charlie Reis 2015/03/04 20:08:36 I don't think we need the "OrCreate" in the name i
Fady Samuel 2015/03/05 20:56:23 Done.
+ // Create a swapped out RenderView for the guest in the embedder render
Charlie Reis 2015/03/04 20:08:36 nit: render -> renderer
Fady Samuel 2015/03/05 20:56:23 Done.
+ // 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
Charlie Reis 2015/03/04 20:08:36 Do you mean the guest WebContents? (The embedder
Fady Samuel 2015/03/05 20:56:23 The embedder WebContents can change. If the guest
Charlie Reis 2015/03/06 00:05:35 Acknowledged.
+ // WebContents changes.
+ // 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.
+ if (guest_proxy_routing_id_ != MSG_ROUTING_NONE)
Charlie Reis 2015/03/04 20:08:36 These two lines should go above the comment.
Fady Samuel 2015/03/05 20:56:23 Done.
+ return guest_proxy_routing_id_;
+
+ SiteInstance* owner_site_instance = owner_web_contents_->GetSiteInstance();
+ guest_proxy_routing_id_ =
+ GetWebContents()->CreateSwappedOutRenderView(owner_site_instance);
+
+ return guest_proxy_routing_id_;
}
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 +149,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 +643,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();
has_render_view_ = true;

Powered by Google App Engine
This is Rietveld 408576698