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 "components/guest_view/common/guest_view_messages.h" | 7 #include "components/guest_view/common/guest_view_messages.h" |
8 #include "components/guest_view/renderer/guest_view_container.h" | 8 #include "components/guest_view/renderer/guest_view_container.h" |
9 #include "content/public/renderer/render_frame.h" | 9 #include "content/public/renderer/render_frame.h" |
10 #include "content/public/renderer/render_view.h" | 10 #include "content/public/renderer/render_view.h" |
11 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 11 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 12 #include "third_party/WebKit/public/web/WebRemoteFrame.h" |
12 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" | 13 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" |
13 #include "third_party/WebKit/public/web/WebView.h" | 14 #include "third_party/WebKit/public/web/WebView.h" |
14 | 15 |
15 namespace guest_view { | 16 namespace guest_view { |
16 | 17 |
17 GuestViewRequest::GuestViewRequest(GuestViewContainer* container, | 18 GuestViewRequest::GuestViewRequest(GuestViewContainer* container, |
18 v8::Local<v8::Function> callback, | 19 v8::Local<v8::Function> callback, |
19 v8::Isolate* isolate) | 20 v8::Isolate* isolate) |
20 : container_(container), | 21 : container_(container), |
21 callback_(isolate, callback), | 22 callback_(isolate, callback), |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 return; | 82 return; |
82 | 83 |
83 content::RenderView* guest_proxy_render_view = | 84 content::RenderView* guest_proxy_render_view = |
84 content::RenderView::FromRoutingID(base::get<1>(param)); | 85 content::RenderView::FromRoutingID(base::get<1>(param)); |
85 // TODO(fsamuel): Should we be reporting an error to JavaScript or DCHECKing? | 86 // TODO(fsamuel): Should we be reporting an error to JavaScript or DCHECKing? |
86 if (!guest_proxy_render_view) | 87 if (!guest_proxy_render_view) |
87 return; | 88 return; |
88 | 89 |
89 v8::HandleScope handle_scope(isolate()); | 90 v8::HandleScope handle_scope(isolate()); |
90 blink::WebFrame* frame = guest_proxy_render_view->GetWebView()->mainFrame(); | 91 blink::WebFrame* frame = guest_proxy_render_view->GetWebView()->mainFrame(); |
91 v8::Local<v8::Value> window = frame->mainWorldScriptContext()->Global(); | 92 // TODO(lazyboy,nasko): The WebLocalFrame branch is not used when running |
| 93 // on top of out-of-process iframes. Remove it once the code is converted. |
| 94 v8::Local<v8::Value> window; |
| 95 if (frame->isWebLocalFrame()) { |
| 96 window = frame->mainWorldScriptContext()->Global(); |
| 97 } else { |
| 98 window = |
| 99 frame->toWebRemoteFrame()->deprecatedMainWorldScriptContext()->Global(); |
| 100 } |
92 | 101 |
93 const int argc = 1; | 102 const int argc = 1; |
94 scoped_ptr<v8::Local<v8::Value>[]> argv(new v8::Local<v8::Value>[argc]); | 103 scoped_ptr<v8::Local<v8::Value>[]> argv(new v8::Local<v8::Value>[argc]); |
95 argv[0] = window; | 104 argv[0] = window; |
96 | 105 |
97 // Call the AttachGuest API's callback with the guest proxy as the first | 106 // Call the AttachGuest API's callback with the guest proxy as the first |
98 // parameter. | 107 // parameter. |
99 ExecuteCallbackIfAvailable(argc, argv.Pass()); | 108 ExecuteCallbackIfAvailable(argc, argv.Pass()); |
100 } | 109 } |
101 | 110 |
(...skipping 12 matching lines...) Expand all Loading... |
114 return; | 123 return; |
115 | 124 |
116 container()->render_frame()->DetachGuest(container()->element_instance_id()); | 125 container()->render_frame()->DetachGuest(container()->element_instance_id()); |
117 } | 126 } |
118 | 127 |
119 void GuestViewDetachRequest::HandleResponse(const IPC::Message& message) { | 128 void GuestViewDetachRequest::HandleResponse(const IPC::Message& message) { |
120 ExecuteCallbackIfAvailable(0 /* argc */, nullptr); | 129 ExecuteCallbackIfAvailable(0 /* argc */, nullptr); |
121 } | 130 } |
122 | 131 |
123 } // namespace guest_view | 132 } // namespace guest_view |
OLD | NEW |