From 89aa05ab8d8a42d2587e5ad3cc6ac245519ce588 Mon Sep 17 00:00:00 2001 From: nasko Date: Mon, 14 Sep 2015 11:33:40 -0700 Subject: [PATCH] Prepare GuestView for removing swapped out RenderFrame. GuestView code is dependent on the usage of swapped out RenderFrame for the out-of-process component. Since swapped out state is going away, this CL removes this dependency. BUG=357747 Review URL: https://codereview.chromium.org/1337283003 Cr-Commit-Position: refs/heads/master@{#348662} --- components/guest_view/renderer/guest_view_request.cc | 11 ++++++++++- .../guest_view/guest_view_internal_custom_bindings.cc | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/components/guest_view/renderer/guest_view_request.cc b/components/guest_view/renderer/guest_view_request.cc index f666c1c5dc73..2a4fd3157bcd 100644 --- a/components/guest_view/renderer/guest_view_request.cc +++ b/components/guest_view/renderer/guest_view_request.cc @@ -9,6 +9,7 @@ #include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_view.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" +#include "third_party/WebKit/public/web/WebRemoteFrame.h" #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" #include "third_party/WebKit/public/web/WebView.h" @@ -88,7 +89,15 @@ void GuestViewAttachRequest::HandleResponse(const IPC::Message& message) { v8::HandleScope handle_scope(isolate()); blink::WebFrame* frame = guest_proxy_render_view->GetWebView()->mainFrame(); - v8::Local window = frame->mainWorldScriptContext()->Global(); + // TODO(lazyboy,nasko): The WebLocalFrame branch is not used when running + // on top of out-of-process iframes. Remove it once the code is converted. + v8::Local window; + if (frame->isWebLocalFrame()) { + window = frame->mainWorldScriptContext()->Global(); + } else { + window = + frame->toWebRemoteFrame()->deprecatedMainWorldScriptContext()->Global(); + } const int argc = 1; scoped_ptr[]> argv(new v8::Local[argc]); 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 7eb129236551..ee243bf6922e 100644 --- a/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc +++ b/extensions/renderer/guest_view/guest_view_internal_custom_bindings.cc @@ -24,6 +24,7 @@ #include "extensions/renderer/script_context.h" #include "third_party/WebKit/public/web/WebFrame.h" #include "third_party/WebKit/public/web/WebLocalFrame.h" +#include "third_party/WebKit/public/web/WebRemoteFrame.h" #include "third_party/WebKit/public/web/WebScopedUserGesture.h" #include "third_party/WebKit/public/web/WebView.h" #include "v8/include/v8.h" @@ -314,7 +315,15 @@ void GuestViewInternalCustomBindings::GetContentWindow( return; blink::WebFrame* frame = view->GetWebView()->mainFrame(); - v8::Local window = frame->mainWorldScriptContext()->Global(); + // TODO(lazyboy,nasko): The WebLocalFrame branch is not used when running + // on top of out-of-process iframes. Remove it once the code is converted. + v8::Local window; + if (frame->isWebLocalFrame()) { + window = frame->mainWorldScriptContext()->Global(); + } else { + window = + frame->toWebRemoteFrame()->deprecatedMainWorldScriptContext()->Global(); + } args.GetReturnValue().Set(window); } -- 2.11.4.GIT