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

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: Addressed nit Created 5 years, 9 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 c1fffde836affbb34fcccdfc6a917f40932578e0..fd53a0c31a5cd16d81fd1f9a7f1e6e7f22cd68a6 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_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,46 @@ 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->SetGuestHost(this);
+}
+
+int BrowserPluginGuest::GetGuestProxyRoutingID() {
+ if (guest_proxy_routing_id_ != MSG_ROUTING_NONE)
+ return guest_proxy_routing_id_;
+
+ // 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.
+ //
+ // 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();
}
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 +152,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 +646,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;
« no previous file with comments | « content/browser/browser_plugin/browser_plugin_guest.h ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698