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

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: not using NPAPI bindings anymore, yay! Created 5 years, 7 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 "base/command_line.h"
8 #include "content/public/common/content_switches.h"
7 #include "content/public/renderer/render_frame.h" 9 #include "content/public/renderer/render_frame.h"
8 #include "content/public/renderer/render_view.h" 10 #include "content/public/renderer/render_view.h"
11 #include "extensions/common/guest_view/extensions_guest_view_messages.h"
9 #include "extensions/common/guest_view/guest_view_constants.h" 12 #include "extensions/common/guest_view/guest_view_constants.h"
10 #include "extensions/common/guest_view/guest_view_messages.h" 13 #include "extensions/common/guest_view/guest_view_messages.h"
11 #include "third_party/WebKit/public/web/WebLocalFrame.h" 14 #include "third_party/WebKit/public/web/WebLocalFrame.h"
12 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h" 15 #include "third_party/WebKit/public/web/WebScopedMicrotaskSuppression.h"
13 #include "third_party/WebKit/public/web/WebView.h" 16 #include "third_party/WebKit/public/web/WebView.h"
14 17
15 namespace { 18 namespace {
16 typedef std::map<int, extensions::ExtensionsGuestViewContainer*> 19 typedef std::map<int, extensions::ExtensionsGuestViewContainer*>
17 ExtensionsGuestViewContainerMap; 20 ExtensionsGuestViewContainerMap;
18 static base::LazyInstance<ExtensionsGuestViewContainerMap> 21 static base::LazyInstance<ExtensionsGuestViewContainerMap>
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 return; 55 return;
53 56
54 v8::Context::Scope context_scope(context); 57 v8::Context::Scope context_scope(context);
55 blink::WebScopedMicrotaskSuppression suppression; 58 blink::WebScopedMicrotaskSuppression suppression;
56 59
57 // Call the AttachGuest API's callback with the guest proxy as the first 60 // Call the AttachGuest API's callback with the guest proxy as the first
58 // parameter. 61 // parameter.
59 callback->Call(context->Global(), argc, argv.get()); 62 callback->Call(context->Global(), argc, argv.get());
60 } 63 }
61 64
65 ExtensionsGuestViewContainer::AttachIframeRequest::AttachIframeRequest(
66 GuestViewContainer* container,
67 int guest_instance_id,
68 v8::Handle<v8::Function> callback,
69 v8::Isolate* isolate)
70 : Request(container, callback, isolate),
71 guest_instance_id_(guest_instance_id) {
72 }
73
74 ExtensionsGuestViewContainer::AttachIframeRequest::~AttachIframeRequest() {
75 }
76
77 void ExtensionsGuestViewContainer::AttachIframeRequest::PerformRequest() {
78 LOG(WARNING) << "AttachIframeRequest::PerformRequest, guest_instance_id: "
79 << guest_instance_id_;
80 // Only store callback.
81 DCHECK(container()->render_frame());
82 }
83
84 void ExtensionsGuestViewContainer::AttachIframeRequest::HandleResponse(
85 const IPC::Message& message) {
86 ExtensionsGuestViewMsg_ContentWindowReady::Param param;
87 bool message_read_status =
88 ExtensionsGuestViewMsg_ContentWindowReady::Read(&message, &param);
89 DCHECK(message_read_status);
90
91 // If we don't have a callback then there's nothing more to do.
92 if (!HasCallback()) {
93 LOG(WARNING) << "AttachIframeRequest, no callback, bail out";
94 return;
95 }
96
97 v8::HandleScope handle_scope(isolate());
98 const int argc = 0;
99 scoped_ptr<v8::Handle<v8::Value>[]> argv(new v8::Handle<v8::Value>[argc]);
100 ExecuteCallbackIfAvailable(argc, argv.Pass());
101 }
102
62 ExtensionsGuestViewContainer::AttachRequest::AttachRequest( 103 ExtensionsGuestViewContainer::AttachRequest::AttachRequest(
63 GuestViewContainer* container, 104 GuestViewContainer* container,
64 int guest_instance_id, 105 int guest_instance_id,
65 scoped_ptr<base::DictionaryValue> params, 106 scoped_ptr<base::DictionaryValue> params,
66 v8::Local<v8::Function> callback, 107 v8::Local<v8::Function> callback,
67 v8::Isolate* isolate) 108 v8::Isolate* isolate)
68 : Request(container, callback, isolate), 109 : Request(container, callback, isolate),
69 guest_instance_id_(guest_instance_id), 110 guest_instance_id_(guest_instance_id),
70 params_(params.Pass()) { 111 params_(params.Pass()) {
71 } 112 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 ExecuteCallbackIfAvailable(0 /* argc */, nullptr); 173 ExecuteCallbackIfAvailable(0 /* argc */, nullptr);
133 } 174 }
134 175
135 ExtensionsGuestViewContainer::ExtensionsGuestViewContainer( 176 ExtensionsGuestViewContainer::ExtensionsGuestViewContainer(
136 content::RenderFrame* render_frame) 177 content::RenderFrame* render_frame)
137 : GuestViewContainer(render_frame), 178 : GuestViewContainer(render_frame),
138 ready_(false), 179 ready_(false),
139 destruction_isolate_(nullptr), 180 destruction_isolate_(nullptr),
140 element_resize_isolate_(nullptr), 181 element_resize_isolate_(nullptr),
141 weak_ptr_factory_(this) { 182 weak_ptr_factory_(this) {
183 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
184 switches::kSitePerProcess)) {
185 // There is not BrowserPluginDelegate to wait for.
186 ready_ = true;
187 }
142 } 188 }
143 189
144 ExtensionsGuestViewContainer::~ExtensionsGuestViewContainer() { 190 ExtensionsGuestViewContainer::~ExtensionsGuestViewContainer() {
145 if (element_instance_id() != guestview::kInstanceIDNone) 191 if (element_instance_id() != guestview::kInstanceIDNone)
146 g_guest_view_container_map.Get().erase(element_instance_id()); 192 g_guest_view_container_map.Get().erase(element_instance_id());
147 193
148 if (pending_response_.get()) 194 if (pending_response_.get())
149 pending_response_->ExecuteCallbackIfAvailable(0 /* argc */, nullptr); 195 pending_response_->ExecuteCallbackIfAvailable(0 /* argc */, nullptr);
150 196
151 while (pending_requests_.size() > 0) { 197 while (pending_requests_.size() > 0) {
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 } 324 }
279 325
280 void ExtensionsGuestViewContainer::HandlePendingResponseCallback( 326 void ExtensionsGuestViewContainer::HandlePendingResponseCallback(
281 const IPC::Message& message) { 327 const IPC::Message& message) {
282 CHECK(pending_response_.get()); 328 CHECK(pending_response_.get());
283 linked_ptr<Request> pending_response(pending_response_.release()); 329 linked_ptr<Request> pending_response(pending_response_.release());
284 pending_response->HandleResponse(message); 330 pending_response->HandleResponse(message);
285 } 331 }
286 332
287 } // namespace extensions 333 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698