Index: extensions/renderer/guest_view/extensions_guest_view_container.cc |
diff --git a/extensions/renderer/guest_view/extensions_guest_view_container.cc b/extensions/renderer/guest_view/extensions_guest_view_container.cc |
index 77456abb02fb81542ba1604dca492864a6d0cfa5..69d228b080c1f709003dc21a0721e100bd16632c 100644 |
--- a/extensions/renderer/guest_view/extensions_guest_view_container.cc |
+++ b/extensions/renderer/guest_view/extensions_guest_view_container.cc |
@@ -42,6 +42,70 @@ ExtensionsGuestViewContainer::Request::GetCallback() const { |
return callback_.NewHandle(isolate_); |
} |
+ExtensionsGuestViewContainer::AttachIframeRequest::AttachIframeRequest( |
+ GuestViewContainer* container, |
+ int guest_instance_id, |
+ v8::Handle<v8::Function> callback, |
+ v8::Isolate* isolate) |
+ : Request(container, callback, isolate), |
+ guest_instance_id_(guest_instance_id) { |
+} |
+ |
+ExtensionsGuestViewContainer::AttachIframeRequest::~AttachIframeRequest() { |
+ |
+} |
+ |
+void ExtensionsGuestViewContainer::AttachIframeRequest::PerformRequest() { |
+ LOG(INFO) << "AttachIframeRequest::PerformRequest, guest_instance_id: " |
+ << guest_instance_id_; |
+ // Only store callback. |
+ DCHECK(container()->render_frame()); |
+} |
+ |
+void ExtensionsGuestViewContainer::AttachIframeRequest::HandleResponse( |
+ const IPC::Message& message) { |
+ GuestViewMsg_ContentWindowReady::Param param; |
+ bool message_read_status = |
+ GuestViewMsg_ContentWindowReady::Read(&message, ¶m); |
+ DCHECK(message_read_status); |
+ |
+ // If we don't have a callback then there's nothing more to do. |
+ if (!HasCallback()) { |
+ LOG(INFO) << "AttachIframeRequest, no callback, bail out"; |
+ return; |
+ } |
+ |
+ int render_view_proxy_routing_id = get<1>(param); |
+ content::RenderView* guest_proxy_render_view = |
+ content::RenderView::FromRoutingID(render_view_proxy_routing_id); |
+ |
+ // TODO(fsamuel): Should we be reporting an error to JavaScript or DCHECKing? |
+ if (!guest_proxy_render_view) { |
+ LOG(ERROR) << "Guest proxy render view not found, routing ID was" << |
+ render_view_proxy_routing_id; |
+ return; |
+ } |
+ |
+ v8::HandleScope handle_scope(isolate()); |
+ v8::Handle<v8::Function> callback = GetCallback(); |
+ v8::Handle<v8::Context> context = callback->CreationContext(); |
+ if (context.IsEmpty()) |
+ return; |
+ |
+ blink::WebFrame* frame = guest_proxy_render_view->GetWebView()->mainFrame(); |
+ v8::Local<v8::Value> window = frame->mainWorldScriptContext()->Global(); |
+ |
+ const int argc = 1; |
+ v8::Handle<v8::Value> argv[argc] = { window }; |
+ |
+ v8::Context::Scope context_scope(context); |
+ blink::WebScopedMicrotaskSuppression suppression; |
+ |
+ // Call the AttachGuest API's callback with the guest proxy as the first |
+ // parameter. |
+ callback->Call(context->Global(), argc, argv); |
+} |
+ |
ExtensionsGuestViewContainer::AttachRequest::AttachRequest( |
GuestViewContainer* container, |
int guest_instance_id, |
@@ -148,6 +212,7 @@ ExtensionsGuestViewContainer::ExtensionsGuestViewContainer( |
ready_(false), |
destruction_isolate_(nullptr), |
element_resize_isolate_(nullptr) { |
+ ready_ = true; |
Fady Samuel
2015/03/04 20:44:47
Really? This is weird. Have we determined a size?
|
} |
ExtensionsGuestViewContainer::~ExtensionsGuestViewContainer() { |