Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: extensions/renderer/guest_view/mime_handler_view/mime_handler_view_container.cc

Issue 1335023004: Prepare MimeHanderViewContainer for removing swapped out RenderFrame. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a TODO. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "components/guest_view/common/guest_view_constants.h" 10 #include "components/guest_view/common/guest_view_constants.h"
11 #include "components/guest_view/common/guest_view_messages.h" 11 #include "components/guest_view/common/guest_view_messages.h"
12 #include "content/public/child/v8_value_converter.h" 12 #include "content/public/child/v8_value_converter.h"
13 #include "content/public/renderer/render_frame.h" 13 #include "content/public/renderer/render_frame.h"
14 #include "content/public/renderer/render_view.h" 14 #include "content/public/renderer/render_view.h"
15 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_cons tants.h" 15 #include "extensions/browser/guest_view/mime_handler_view/mime_handler_view_cons tants.h"
16 #include "extensions/common/extension_messages.h" 16 #include "extensions/common/extension_messages.h"
17 #include "extensions/common/guest_view/extensions_guest_view_messages.h" 17 #include "extensions/common/guest_view/extensions_guest_view_messages.h"
18 #include "gin/arguments.h" 18 #include "gin/arguments.h"
19 #include "gin/dictionary.h" 19 #include "gin/dictionary.h"
20 #include "gin/handle.h" 20 #include "gin/handle.h"
21 #include "gin/interceptor.h" 21 #include "gin/interceptor.h"
22 #include "gin/object_template_builder.h" 22 #include "gin/object_template_builder.h"
23 #include "gin/wrappable.h" 23 #include "gin/wrappable.h"
24 #include "third_party/WebKit/public/web/WebDocument.h" 24 #include "third_party/WebKit/public/web/WebDocument.h"
25 #include "third_party/WebKit/public/web/WebLocalFrame.h" 25 #include "third_party/WebKit/public/web/WebLocalFrame.h"
26 #include "third_party/WebKit/public/web/WebRemoteFrame.h"
26 #include "third_party/WebKit/public/web/WebView.h" 27 #include "third_party/WebKit/public/web/WebView.h"
27 28
28 namespace extensions { 29 namespace extensions {
29 30
30 namespace { 31 namespace {
31 32
32 const char kPostMessageName[] = "postMessage"; 33 const char kPostMessageName[] = "postMessage";
33 34
34 // The gin-backed scriptable object which is exposed by the BrowserPlugin for 35 // The gin-backed scriptable object which is exposed by the BrowserPlugin for
35 // MimeHandlerViewContainer. This currently only implements "postMessage". 36 // MimeHandlerViewContainer. This currently only implements "postMessage".
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 content::RenderView::FromRoutingID(guest_proxy_routing_id_); 229 content::RenderView::FromRoutingID(guest_proxy_routing_id_);
229 if (!guest_proxy_render_view) 230 if (!guest_proxy_render_view)
230 return; 231 return;
231 blink::WebFrame* guest_proxy_frame = 232 blink::WebFrame* guest_proxy_frame =
232 guest_proxy_render_view->GetWebView()->mainFrame(); 233 guest_proxy_render_view->GetWebView()->mainFrame();
233 if (!guest_proxy_frame) 234 if (!guest_proxy_frame)
234 return; 235 return;
235 236
236 v8::Context::Scope context_scope( 237 v8::Context::Scope context_scope(
237 render_frame()->GetWebFrame()->mainWorldScriptContext()); 238 render_frame()->GetWebFrame()->mainWorldScriptContext());
238 v8::Local<v8::Object> guest_proxy_window = 239
239 guest_proxy_frame->mainWorldScriptContext()->Global(); 240 // TODO(lazyboy,nasko): The WebLocalFrame branch is not used when running
241 // on top of out-of-process iframes. Remove it once the code is converted.
242 v8::Local<v8::Object> guest_proxy_window;
243 if (guest_proxy_frame->isWebLocalFrame()) {
244 guest_proxy_window =
245 guest_proxy_frame->mainWorldScriptContext()->Global();
246 } else {
247 guest_proxy_window = guest_proxy_frame->toWebRemoteFrame()
248 ->deprecatedMainWorldScriptContext()
249 ->Global();
250 }
240 gin::Dictionary window_object(isolate, guest_proxy_window); 251 gin::Dictionary window_object(isolate, guest_proxy_window);
241 v8::Local<v8::Function> post_message; 252 v8::Local<v8::Function> post_message;
242 if (!window_object.Get(std::string(kPostMessageName), &post_message)) 253 if (!window_object.Get(std::string(kPostMessageName), &post_message))
243 return; 254 return;
244 255
245 v8::Local<v8::Value> args[] = { 256 v8::Local<v8::Value> args[] = {
246 message, 257 message,
247 // Post the message to any domain inside the browser plugin. The embedder 258 // Post the message to any domain inside the browser plugin. The embedder
248 // should already know what is embedded. 259 // should already know what is embedded.
249 gin::StringToV8(isolate, "*")}; 260 gin::StringToV8(isolate, "*")};
250 guest_proxy_frame->callFunctionEvenIfScriptDisabled( 261 render_frame()->GetWebFrame()->callFunctionEvenIfScriptDisabled(
251 post_message.As<v8::Function>(), 262 post_message.As<v8::Function>(),
252 guest_proxy_window, 263 guest_proxy_window,
253 arraysize(args), 264 arraysize(args),
254 args); 265 args);
255 } 266 }
256 267
257 void MimeHandlerViewContainer::PostMessageFromValue( 268 void MimeHandlerViewContainer::PostMessageFromValue(
258 const base::Value& message) { 269 const base::Value& message) {
259 blink::WebFrame* frame = render_frame()->GetWebFrame(); 270 blink::WebFrame* frame = render_frame()->GetWebFrame();
260 if (!frame) 271 if (!frame)
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 if (!render_frame()) 330 if (!render_frame())
320 return; 331 return;
321 332
322 render_frame()->Send( 333 render_frame()->Send(
323 new ExtensionsGuestViewHostMsg_CreateMimeHandlerViewGuest( 334 new ExtensionsGuestViewHostMsg_CreateMimeHandlerViewGuest(
324 render_frame()->GetRoutingID(), view_id_, element_instance_id(), 335 render_frame()->GetRoutingID(), view_id_, element_instance_id(),
325 element_size_)); 336 element_size_));
326 } 337 }
327 338
328 } // namespace extensions 339 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698