| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/guest_view/renderer/guest_view_request.h" | 5 #include "components/guest_view/renderer/guest_view_request.h" |
| 6 | 6 |
| 7 #include <tuple> | 7 #include <tuple> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "components/guest_view/common/guest_view_messages.h" | 10 #include "components/guest_view/common/guest_view_messages.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 return; | 84 return; |
| 85 | 85 |
| 86 content::RenderView* guest_proxy_render_view = | 86 content::RenderView* guest_proxy_render_view = |
| 87 content::RenderView::FromRoutingID(std::get<1>(param)); | 87 content::RenderView::FromRoutingID(std::get<1>(param)); |
| 88 // TODO(fsamuel): Should we be reporting an error to JavaScript or DCHECKing? | 88 // TODO(fsamuel): Should we be reporting an error to JavaScript or DCHECKing? |
| 89 if (!guest_proxy_render_view) | 89 if (!guest_proxy_render_view) |
| 90 return; | 90 return; |
| 91 | 91 |
| 92 v8::HandleScope handle_scope(isolate()); | 92 v8::HandleScope handle_scope(isolate()); |
| 93 blink::WebFrame* frame = guest_proxy_render_view->GetWebView()->MainFrame(); | 93 blink::WebFrame* frame = guest_proxy_render_view->GetWebView()->MainFrame(); |
| 94 // TODO(lazyboy,nasko): The WebLocalFrame branch is not used when running | 94 v8::Local<v8::Value> window = frame->GlobalProxy(); |
| 95 // on top of out-of-process iframes. Remove it once the code is converted. | |
| 96 v8::Local<v8::Value> window; | |
| 97 if (frame->IsWebLocalFrame()) { | |
| 98 window = frame->MainWorldScriptContext()->Global(); | |
| 99 } else { | |
| 100 window = frame->ToWebRemoteFrame()->GlobalProxy(); | |
| 101 } | |
| 102 | 95 |
| 103 const int argc = 1; | 96 const int argc = 1; |
| 104 std::unique_ptr<v8::Local<v8::Value>[]> argv(new v8::Local<v8::Value>[argc]); | 97 std::unique_ptr<v8::Local<v8::Value>[]> argv(new v8::Local<v8::Value>[argc]); |
| 105 argv[0] = window; | 98 argv[0] = window; |
| 106 | 99 |
| 107 // Call the AttachGuest API's callback with the guest proxy as the first | 100 // Call the AttachGuest API's callback with the guest proxy as the first |
| 108 // parameter. | 101 // parameter. |
| 109 ExecuteCallbackIfAvailable(argc, std::move(argv)); | 102 ExecuteCallbackIfAvailable(argc, std::move(argv)); |
| 110 } | 103 } |
| 111 | 104 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 125 | 118 |
| 126 container()->render_frame()->DetachGuest(container()->element_instance_id()); | 119 container()->render_frame()->DetachGuest(container()->element_instance_id()); |
| 127 } | 120 } |
| 128 | 121 |
| 129 void GuestViewDetachRequest::HandleResponse(const IPC::Message& message) { | 122 void GuestViewDetachRequest::HandleResponse(const IPC::Message& message) { |
| 130 DCHECK(message.type() == GuestViewMsg_GuestDetached::ID); | 123 DCHECK(message.type() == GuestViewMsg_GuestDetached::ID); |
| 131 ExecuteCallbackIfAvailable(0 /* argc */, nullptr); | 124 ExecuteCallbackIfAvailable(0 /* argc */, nullptr); |
| 132 } | 125 } |
| 133 | 126 |
| 134 } // namespace guest_view | 127 } // namespace guest_view |
| OLD | NEW |