Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/renderer/guest_view/mime_handler_view/mime_handler_view_con tainer.h" | 5 #include "extensions/renderer/guest_view/mime_handler_view/mime_handler_view_con tainer.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 229 if (!guest_proxy_render_view) | 229 if (!guest_proxy_render_view) |
| 230 return; | 230 return; |
| 231 blink::WebFrame* guest_proxy_frame = | 231 blink::WebFrame* guest_proxy_frame = |
| 232 guest_proxy_render_view->GetWebView()->MainFrame(); | 232 guest_proxy_render_view->GetWebView()->MainFrame(); |
| 233 if (!guest_proxy_frame) | 233 if (!guest_proxy_frame) |
| 234 return; | 234 return; |
| 235 | 235 |
| 236 v8::Context::Scope context_scope( | 236 v8::Context::Scope context_scope( |
| 237 render_frame()->GetWebFrame()->MainWorldScriptContext()); | 237 render_frame()->GetWebFrame()->MainWorldScriptContext()); |
| 238 | 238 |
| 239 // TODO(lazyboy,nasko): The WebLocalFrame branch is not used when running | 239 // TODO(lazyboy,nasko): The WebLocalFrame branch is not used when running |
|
lfg
2017/06/09 18:53:14
Please remove the comment.
Łukasz Anforowicz
2017/06/09 18:56:26
Ooops. Done.
| |
| 240 // on top of out-of-process iframes. Remove it once the code is converted. | 240 // on top of out-of-process iframes. Remove it once the code is converted. |
| 241 v8::Local<v8::Object> guest_proxy_window; | 241 v8::Local<v8::Object> guest_proxy_window = guest_proxy_frame->GlobalProxy(); |
| 242 if (guest_proxy_frame->IsWebLocalFrame()) { | |
| 243 guest_proxy_window = guest_proxy_frame->MainWorldScriptContext()->Global(); | |
| 244 } else { | |
| 245 guest_proxy_window = guest_proxy_frame->ToWebRemoteFrame()->GlobalProxy(); | |
| 246 } | |
| 247 gin::Dictionary window_object(isolate, guest_proxy_window); | 242 gin::Dictionary window_object(isolate, guest_proxy_window); |
| 248 v8::Local<v8::Function> post_message; | 243 v8::Local<v8::Function> post_message; |
| 249 if (!window_object.Get(std::string(kPostMessageName), &post_message)) | 244 if (!window_object.Get(std::string(kPostMessageName), &post_message)) |
| 250 return; | 245 return; |
| 251 | 246 |
| 252 v8::Local<v8::Value> args[] = { | 247 v8::Local<v8::Value> args[] = { |
| 253 message, | 248 message, |
| 254 // Post the message to any domain inside the browser plugin. The embedder | 249 // Post the message to any domain inside the browser plugin. The embedder |
| 255 // should already know what is embedded. | 250 // should already know what is embedded. |
| 256 gin::StringToV8(isolate, "*")}; | 251 gin::StringToV8(isolate, "*")}; |
| 257 render_frame()->GetWebFrame()->CallFunctionEvenIfScriptDisabled( | 252 render_frame()->GetWebFrame()->CallFunctionEvenIfScriptDisabled( |
| 258 post_message.As<v8::Function>(), guest_proxy_window, arraysize(args), | 253 post_message.As<v8::Function>(), guest_proxy_window, arraysize(args), |
| 259 args); | 254 args); |
| 260 } | 255 } |
| 261 | 256 |
| 262 void MimeHandlerViewContainer::PostMessageFromValue( | 257 void MimeHandlerViewContainer::PostMessageFromValue( |
| 263 const base::Value& message) { | 258 const base::Value& message) { |
| 264 blink::WebFrame* frame = render_frame()->GetWebFrame(); | 259 blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); |
| 265 if (!frame) | 260 if (!frame) |
| 266 return; | 261 return; |
| 267 | 262 |
| 268 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 263 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 269 v8::HandleScope handle_scope(isolate); | 264 v8::HandleScope handle_scope(isolate); |
| 270 v8::Context::Scope context_scope(frame->MainWorldScriptContext()); | 265 v8::Context::Scope context_scope(frame->MainWorldScriptContext()); |
| 271 std::unique_ptr<content::V8ValueConverter> converter( | 266 std::unique_ptr<content::V8ValueConverter> converter( |
| 272 content::V8ValueConverter::create()); | 267 content::V8ValueConverter::create()); |
| 273 PostMessage(isolate, | 268 PostMessage(isolate, |
| 274 converter->ToV8Value(&message, frame->MainWorldScriptContext())); | 269 converter->ToV8Value(&message, frame->MainWorldScriptContext())); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 295 void MimeHandlerViewContainer::OnMimeHandlerViewGuestOnLoadCompleted( | 290 void MimeHandlerViewContainer::OnMimeHandlerViewGuestOnLoadCompleted( |
| 296 int /* unused */) { | 291 int /* unused */) { |
| 297 if (!render_frame()) | 292 if (!render_frame()) |
| 298 return; | 293 return; |
| 299 | 294 |
| 300 guest_loaded_ = true; | 295 guest_loaded_ = true; |
| 301 if (pending_messages_.empty()) | 296 if (pending_messages_.empty()) |
| 302 return; | 297 return; |
| 303 | 298 |
| 304 // Now that the guest has loaded, flush any unsent messages. | 299 // Now that the guest has loaded, flush any unsent messages. |
| 305 blink::WebFrame* frame = render_frame()->GetWebFrame(); | 300 blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); |
| 306 if (!frame) | 301 if (!frame) |
| 307 return; | 302 return; |
| 308 | 303 |
| 309 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 304 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 310 v8::HandleScope handle_scope(isolate); | 305 v8::HandleScope handle_scope(isolate); |
| 311 v8::Context::Scope context_scope(frame->MainWorldScriptContext()); | 306 v8::Context::Scope context_scope(frame->MainWorldScriptContext()); |
| 312 for (const auto& pending_message : pending_messages_) | 307 for (const auto& pending_message : pending_messages_) |
| 313 PostMessage(isolate, v8::Local<v8::Value>::New(isolate, pending_message)); | 308 PostMessage(isolate, v8::Local<v8::Value>::New(isolate, pending_message)); |
| 314 | 309 |
| 315 pending_messages_.clear(); | 310 pending_messages_.clear(); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 327 if (!render_frame()) | 322 if (!render_frame()) |
| 328 return; | 323 return; |
| 329 | 324 |
| 330 render_frame()->Send( | 325 render_frame()->Send( |
| 331 new ExtensionsGuestViewHostMsg_CreateMimeHandlerViewGuest( | 326 new ExtensionsGuestViewHostMsg_CreateMimeHandlerViewGuest( |
| 332 render_frame()->GetRoutingID(), view_id_, element_instance_id(), | 327 render_frame()->GetRoutingID(), view_id_, element_instance_id(), |
| 333 element_size_)); | 328 element_size_)); |
| 334 } | 329 } |
| 335 | 330 |
| 336 } // namespace extensions | 331 } // namespace extensions |
| OLD | NEW |