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 v8::Local<v8::Value> window; |
93 if (frame->isWebLocalFrame()) { | |
Fady Samuel
2015/09/14 15:42:46
nit: comment would be helpful.
| |
94 window = frame->mainWorldScriptContext()->Global(); | |
95 } else { | |
96 window = | |
97 frame->toWebRemoteFrame()->deprecatedMainWorldScriptContext()->Global(); | |
98 } | |
92 | 99 |
93 const int argc = 1; | 100 const int argc = 1; |
94 scoped_ptr<v8::Local<v8::Value>[]> argv(new v8::Local<v8::Value>[argc]); | 101 scoped_ptr<v8::Local<v8::Value>[]> argv(new v8::Local<v8::Value>[argc]); |
95 argv[0] = window; | 102 argv[0] = window; |
96 | 103 |
97 // Call the AttachGuest API's callback with the guest proxy as the first | 104 // Call the AttachGuest API's callback with the guest proxy as the first |
98 // parameter. | 105 // parameter. |
99 ExecuteCallbackIfAvailable(argc, argv.Pass()); | 106 ExecuteCallbackIfAvailable(argc, argv.Pass()); |
100 } | 107 } |
101 | 108 |
(...skipping 12 matching lines...) Expand all Loading... | |
114 return; | 121 return; |
115 | 122 |
116 container()->render_frame()->DetachGuest(container()->element_instance_id()); | 123 container()->render_frame()->DetachGuest(container()->element_instance_id()); |
117 } | 124 } |
118 | 125 |
119 void GuestViewDetachRequest::HandleResponse(const IPC::Message& message) { | 126 void GuestViewDetachRequest::HandleResponse(const IPC::Message& message) { |
120 ExecuteCallbackIfAvailable(0 /* argc */, nullptr); | 127 ExecuteCallbackIfAvailable(0 /* argc */, nullptr); |
121 } | 128 } |
122 | 129 |
123 } // namespace guest_view | 130 } // namespace guest_view |
OLD | NEW |