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

Side by Side Diff: extensions/renderer/guest_view/extensions_guest_view_container.cc

Issue 972313002: Make <webview> use out-of-process iframe architecture. (Closed) Base URL: ssh://saopaulo.wat/mnt/dev/shared/src@testoopif2z-better-chrome
Patch Set: Revert unused changes from previous attempt + more cleanup. Created 5 years, 9 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
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/extensions_guest_view_container.h" 5 #include "extensions/renderer/guest_view/extensions_guest_view_container.h"
6 6
7 #include "content/public/renderer/render_frame.h" 7 #include "content/public/renderer/render_frame.h"
8 #include "content/public/renderer/render_view.h" 8 #include "content/public/renderer/render_view.h"
9 #include "extensions/common/guest_view/guest_view_constants.h" 9 #include "extensions/common/guest_view/guest_view_constants.h"
10 #include "extensions/common/guest_view/guest_view_messages.h" 10 #include "extensions/common/guest_view/guest_view_messages.h"
(...skipping 24 matching lines...) Expand all
35 35
36 bool ExtensionsGuestViewContainer::Request::HasCallback() const { 36 bool ExtensionsGuestViewContainer::Request::HasCallback() const {
37 return !callback_.IsEmpty(); 37 return !callback_.IsEmpty();
38 } 38 }
39 39
40 v8::Handle<v8::Function> 40 v8::Handle<v8::Function>
41 ExtensionsGuestViewContainer::Request::GetCallback() const { 41 ExtensionsGuestViewContainer::Request::GetCallback() const {
42 return callback_.NewHandle(isolate_); 42 return callback_.NewHandle(isolate_);
43 } 43 }
44 44
45 ExtensionsGuestViewContainer::AttachIframeRequest::AttachIframeRequest(
46 GuestViewContainer* container,
47 int guest_instance_id,
48 v8::Handle<v8::Function> callback,
49 v8::Isolate* isolate)
50 : Request(container, callback, isolate),
51 guest_instance_id_(guest_instance_id) {
52 }
53
54 ExtensionsGuestViewContainer::AttachIframeRequest::~AttachIframeRequest() {
55
56 }
57
58 void ExtensionsGuestViewContainer::AttachIframeRequest::PerformRequest() {
59 LOG(INFO) << "AttachIframeRequest::PerformRequest, guest_instance_id: "
60 << guest_instance_id_;
61 // Only store callback.
62 DCHECK(container()->render_frame());
63 }
64
65 void ExtensionsGuestViewContainer::AttachIframeRequest::HandleResponse(
66 const IPC::Message& message) {
67 GuestViewMsg_ContentWindowReady::Param param;
68 bool message_read_status =
69 GuestViewMsg_ContentWindowReady::Read(&message, &param);
70 DCHECK(message_read_status);
71
72 // If we don't have a callback then there's nothing more to do.
73 if (!HasCallback()) {
74 LOG(INFO) << "AttachIframeRequest, no callback, bail out";
75 return;
76 }
77
78 int render_view_proxy_routing_id = get<1>(param);
79 content::RenderView* guest_proxy_render_view =
80 content::RenderView::FromRoutingID(render_view_proxy_routing_id);
81
82 // TODO(fsamuel): Should we be reporting an error to JavaScript or DCHECKing?
83 if (!guest_proxy_render_view) {
84 LOG(ERROR) << "Guest proxy render view not found, routing ID was" <<
85 render_view_proxy_routing_id;
86 return;
87 }
88
89 v8::HandleScope handle_scope(isolate());
90 v8::Handle<v8::Function> callback = GetCallback();
91 v8::Handle<v8::Context> context = callback->CreationContext();
92 if (context.IsEmpty())
93 return;
94
95 blink::WebFrame* frame = guest_proxy_render_view->GetWebView()->mainFrame();
96 v8::Local<v8::Value> window = frame->mainWorldScriptContext()->Global();
97
98 const int argc = 1;
99 v8::Handle<v8::Value> argv[argc] = { window };
100
101 v8::Context::Scope context_scope(context);
102 blink::WebScopedMicrotaskSuppression suppression;
103
104 // Call the AttachGuest API's callback with the guest proxy as the first
105 // parameter.
106 callback->Call(context->Global(), argc, argv);
107 }
108
45 ExtensionsGuestViewContainer::AttachRequest::AttachRequest( 109 ExtensionsGuestViewContainer::AttachRequest::AttachRequest(
46 GuestViewContainer* container, 110 GuestViewContainer* container,
47 int guest_instance_id, 111 int guest_instance_id,
48 scoped_ptr<base::DictionaryValue> params, 112 scoped_ptr<base::DictionaryValue> params,
49 v8::Handle<v8::Function> callback, 113 v8::Handle<v8::Function> callback,
50 v8::Isolate* isolate) 114 v8::Isolate* isolate)
51 : Request(container, callback, isolate), 115 : Request(container, callback, isolate),
52 guest_instance_id_(guest_instance_id), 116 guest_instance_id_(guest_instance_id),
53 params_(params.Pass()) { 117 params_(params.Pass()) {
54 } 118 }
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 // Call the DetachGuest's callback. 205 // Call the DetachGuest's callback.
142 callback->Call(context->Global(), 0 /* argc */, nullptr); 206 callback->Call(context->Global(), 0 /* argc */, nullptr);
143 } 207 }
144 208
145 ExtensionsGuestViewContainer::ExtensionsGuestViewContainer( 209 ExtensionsGuestViewContainer::ExtensionsGuestViewContainer(
146 content::RenderFrame* render_frame) 210 content::RenderFrame* render_frame)
147 : GuestViewContainer(render_frame), 211 : GuestViewContainer(render_frame),
148 ready_(false), 212 ready_(false),
149 destruction_isolate_(nullptr), 213 destruction_isolate_(nullptr),
150 element_resize_isolate_(nullptr) { 214 element_resize_isolate_(nullptr) {
215 ready_ = true;
Fady Samuel 2015/03/04 20:44:47 Really? This is weird. Have we determined a size?
151 } 216 }
152 217
153 ExtensionsGuestViewContainer::~ExtensionsGuestViewContainer() { 218 ExtensionsGuestViewContainer::~ExtensionsGuestViewContainer() {
154 if (element_instance_id() != guestview::kInstanceIDNone) { 219 if (element_instance_id() != guestview::kInstanceIDNone) {
155 g_guest_view_container_map.Get().erase(element_instance_id()); 220 g_guest_view_container_map.Get().erase(element_instance_id());
156 } 221 }
157 222
158 // Call the destruction callback, if one is registered. 223 // Call the destruction callback, if one is registered.
159 if (destruction_callback_.IsEmpty()) 224 if (destruction_callback_.IsEmpty())
160 return; 225 return;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } 313 }
249 314
250 void ExtensionsGuestViewContainer::HandlePendingResponseCallback( 315 void ExtensionsGuestViewContainer::HandlePendingResponseCallback(
251 const IPC::Message& message) { 316 const IPC::Message& message) {
252 CHECK(pending_response_.get()); 317 CHECK(pending_response_.get());
253 linked_ptr<Request> pending_response(pending_response_.release()); 318 linked_ptr<Request> pending_response(pending_response_.release());
254 pending_response->HandleResponse(message); 319 pending_response->HandleResponse(message);
255 } 320 }
256 321
257 } // namespace extensions 322 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698