summaryrefslogtreecommitdiffstats
path: root/extensions/renderer/guest_view
diff options
context:
space:
mode:
authorfsamuel <fsamuel@chromium.org>2015-03-09 20:29:14 -0700
committerCommit bot <commit-bot@chromium.org>2015-03-10 03:30:13 +0000
commit60b42286b4f63882bc5f1ffc4fd7e94bc5d319f0 (patch)
treea3faa36e3fc883a3dfad5ee37e175f736343b7c6 /extensions/renderer/guest_view
parent301745a2a1928177800d44110d5745bb12bc556a (diff)
downloadchromium_src-60b42286b4f63882bc5f1ffc4fd7e94bc5d319f0.zip
chromium_src-60b42286b4f63882bc5f1ffc4fd7e94bc5d319f0.tar.gz
chromium_src-60b42286b4f63882bc5f1ffc4fd7e94bc5d319f0.tar.bz2
<webview>: Make contentWindow available prior to attachment (on display:none).
This CL updates the createGuest API to return an optional contentWindow. This CL renames GuestSizer to GuestProxyHost which better represents what it does. GuestProxyHost exposes "LoadURLWithParams" which, after navigating, creates a swapped out RenderView for the guest in the embedder's process. This CL removes RegisterDestructionCallback from BrowserPluginGuestDelegate. BUG=456118 Test=WebViewTest.NoContentSettingsAPI runs with display:none now. Review URL: https://codereview.chromium.org/910073003 Cr-Commit-Position: refs/heads/master@{#319833}
Diffstat (limited to 'extensions/renderer/guest_view')
-rw-r--r--extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc30
-rw-r--r--extensions/renderer/guest_view/guest_view_internal_custom_bindings.h4
2 files changed, 34 insertions, 0 deletions
diff --git a/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc b/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc
index ff18e04..a57f454 100644
--- a/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc
+++ b/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc
@@ -14,6 +14,8 @@
#include "extensions/common/guest_view/guest_view_constants.h"
#include "extensions/renderer/guest_view/extensions_guest_view_container.h"
#include "extensions/renderer/script_context.h"
+#include "third_party/WebKit/public/web/WebFrame.h"
+#include "third_party/WebKit/public/web/WebView.h"
#include "v8/include/v8.h"
using content::V8ValueConverter;
@@ -29,6 +31,9 @@ GuestViewInternalCustomBindings::GuestViewInternalCustomBindings(
RouteFunction("DetachGuest",
base::Bind(&GuestViewInternalCustomBindings::DetachGuest,
base::Unretained(this)));
+ RouteFunction("GetContentWindow",
+ base::Bind(&GuestViewInternalCustomBindings::GetContentWindow,
+ base::Unretained(this)));
RouteFunction(
"RegisterDestructionCallback",
base::Bind(&GuestViewInternalCustomBindings::RegisterDestructionCallback,
@@ -122,6 +127,31 @@ void GuestViewInternalCustomBindings::DetachGuest(
args.GetReturnValue().Set(v8::Boolean::New(context()->isolate(), true));
}
+void GuestViewInternalCustomBindings::GetContentWindow(
+ const v8::FunctionCallbackInfo<v8::Value>& args) {
+ // Default to returning null.
+ args.GetReturnValue().SetNull();
+
+ if (args.Length() != 1)
+ return;
+
+ // The routing ID for the RenderView.
+ if (!args[0]->IsInt32())
+ return;
+
+ int view_id = args[0]->Int32Value();
+ if (view_id == MSG_ROUTING_NONE)
+ return;
+
+ content::RenderView* view = content::RenderView::FromRoutingID(view_id);
+ if (!view)
+ return;
+
+ blink::WebFrame* frame = view->GetWebView()->mainFrame();
+ v8::Local<v8::Value> window = frame->mainWorldScriptContext()->Global();
+ args.GetReturnValue().Set(window);
+}
+
void GuestViewInternalCustomBindings::RegisterDestructionCallback(
const v8::FunctionCallbackInfo<v8::Value>& args) {
// There are two parameters.
diff --git a/extensions/renderer/guest_view/guest_view_internal_custom_bindings.h b/extensions/renderer/guest_view/guest_view_internal_custom_bindings.h
index 0c29435..2c19137 100644
--- a/extensions/renderer/guest_view/guest_view_internal_custom_bindings.h
+++ b/extensions/renderer/guest_view/guest_view_internal_custom_bindings.h
@@ -40,6 +40,10 @@ class GuestViewInternalCustomBindings : public ObjectBackedNativeHandler {
// been detached.
void DetachGuest(const v8::FunctionCallbackInfo<v8::Value>& args);
+ // GetContentWindow takes in a RenderView routing ID and returns the
+ // Window JavaScript object for that RenderView.
+ void GetContentWindow(const v8::FunctionCallbackInfo<v8::Value>& args);
+
// RegisterDestructionCallback registers a JavaScript callback function to be
// called when the guestview's container is destroyed.
// RegisterDestructionCallback takes in a single paramater, |callback|.