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

Side by Side Diff: content/renderer/render_widget.cc

Issue 2238573002: Add WebWidgetTestProxy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix site_isolation bot Created 4 years, 4 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/renderer/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 return content::RenderWidgetMusConnection::GetOrCreate( 206 return content::RenderWidgetMusConnection::GetOrCreate(
207 widget->routing_id()); 207 widget->routing_id());
208 } 208 }
209 #endif 209 #endif
210 // If we don't have a connection to the Mojo shell, then we want to route IPCs 210 // If we don't have a connection to the Mojo shell, then we want to route IPCs
211 // back to the browser process rather than Mus so we use the |widget| as the 211 // back to the browser process rather than Mus so we use the |widget| as the
212 // RenderWidgetInputHandlerDelegate. 212 // RenderWidgetInputHandlerDelegate.
213 return widget; 213 return widget;
214 } 214 }
215 215
216 content::RenderWidget::CreateRenderWidgetFunction g_create_render_widget =
217 nullptr;
218
219 content::RenderWidget::RenderWidgetCreatedCallback g_render_widget_created =
220 nullptr;
221
216 } // namespace 222 } // namespace
217 223
218 namespace content { 224 namespace content {
219 225
220 // RenderWidget --------------------------------------------------------------- 226 // RenderWidget ---------------------------------------------------------------
221 227
222 RenderWidget::RenderWidget(CompositorDependencies* compositor_deps, 228 RenderWidget::RenderWidget(CompositorDependencies* compositor_deps,
223 blink::WebPopupType popup_type, 229 blink::WebPopupType popup_type,
224 const blink::WebScreenInfo& screen_info, 230 const blink::WebScreenInfo& screen_info,
225 bool swapped_out, 231 bool swapped_out,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 287
282 RenderWidget::~RenderWidget() { 288 RenderWidget::~RenderWidget() {
283 DCHECK(!webwidget_) << "Leaking our WebWidget!"; 289 DCHECK(!webwidget_) << "Leaking our WebWidget!";
284 290
285 // If we are swapped out, we have released already. 291 // If we are swapped out, we have released already.
286 if (!is_swapped_out_ && RenderProcess::current()) 292 if (!is_swapped_out_ && RenderProcess::current())
287 RenderProcess::current()->ReleaseProcess(); 293 RenderProcess::current()->ReleaseProcess();
288 } 294 }
289 295
290 // static 296 // static
297 void RenderWidget::InstallCreateHook(
298 CreateRenderWidgetFunction create_render_widget,
299 RenderWidgetCreatedCallback render_widget_created) {
300 CHECK(!g_create_render_widget && !g_render_widget_created);
301 g_create_render_widget = create_render_widget;
302 g_render_widget_created = render_widget_created;
303 }
304
305 // static
291 RenderWidget* RenderWidget::Create(int32_t opener_id, 306 RenderWidget* RenderWidget::Create(int32_t opener_id,
292 CompositorDependencies* compositor_deps, 307 CompositorDependencies* compositor_deps,
293 blink::WebPopupType popup_type, 308 blink::WebPopupType popup_type,
294 const blink::WebScreenInfo& screen_info) { 309 const blink::WebScreenInfo& screen_info) {
295 DCHECK(opener_id != MSG_ROUTING_NONE); 310 DCHECK(opener_id != MSG_ROUTING_NONE);
296 scoped_refptr<RenderWidget> widget(new RenderWidget( 311 scoped_refptr<RenderWidget> widget(new RenderWidget(
297 compositor_deps, popup_type, screen_info, false, false, false)); 312 compositor_deps, popup_type, screen_info, false, false, false));
298 if (widget->Init(opener_id)) { // adds reference on success. 313 if (widget->Init(opener_id)) { // adds reference on success.
299 return widget.get(); 314 return widget.get();
300 } 315 }
(...skipping 11 matching lines...) Expand all
312 // TODO(avi): Before RenderViewImpl has-a RenderWidget, the browser passes the 327 // TODO(avi): Before RenderViewImpl has-a RenderWidget, the browser passes the
313 // same routing ID for both the view routing ID and the main frame widget 328 // same routing ID for both the view routing ID and the main frame widget
314 // routing ID. https://crbug.com/545684 329 // routing ID. https://crbug.com/545684
315 RenderViewImpl* view = RenderViewImpl::FromRoutingID(routing_id); 330 RenderViewImpl* view = RenderViewImpl::FromRoutingID(routing_id);
316 if (view) { 331 if (view) {
317 view->AttachWebFrameWidget( 332 view->AttachWebFrameWidget(
318 RenderWidget::CreateWebFrameWidget(view->GetWidget(), frame)); 333 RenderWidget::CreateWebFrameWidget(view->GetWidget(), frame));
319 return view->GetWidget(); 334 return view->GetWidget();
320 } 335 }
321 scoped_refptr<RenderWidget> widget( 336 scoped_refptr<RenderWidget> widget(
322 new RenderWidget(compositor_deps, blink::WebPopupTypeNone, screen_info, 337 g_create_render_widget
323 false, hidden, false)); 338 ? g_create_render_widget(compositor_deps, blink::WebPopupTypeNone,
339 screen_info, false, hidden, false)
340 : new RenderWidget(compositor_deps, blink::WebPopupTypeNone,
341 screen_info, false, hidden, false));
324 widget->SetRoutingID(routing_id); 342 widget->SetRoutingID(routing_id);
325 widget->for_oopif_ = true; 343 widget->for_oopif_ = true;
326 // DoInit increments the reference count on |widget|, keeping it alive after 344 // DoInit increments the reference count on |widget|, keeping it alive after
327 // this function returns. 345 // this function returns.
328 if (widget->DoInit(MSG_ROUTING_NONE, 346 if (widget->DoInit(MSG_ROUTING_NONE,
329 RenderWidget::CreateWebFrameWidget(widget.get(), frame), 347 RenderWidget::CreateWebFrameWidget(widget.get(), frame),
330 nullptr)) { 348 nullptr)) {
349 if (g_render_widget_created)
350 g_render_widget_created(widget.get());
331 return widget.get(); 351 return widget.get();
332 } 352 }
333 return nullptr; 353 return nullptr;
334 } 354 }
335 355
336 // static 356 // static
337 blink::WebFrameWidget* RenderWidget::CreateWebFrameWidget( 357 blink::WebFrameWidget* RenderWidget::CreateWebFrameWidget(
338 RenderWidget* render_widget, 358 RenderWidget* render_widget,
339 blink::WebLocalFrame* frame) { 359 blink::WebLocalFrame* frame) {
340 if (!frame->parent()) { 360 if (!frame->parent()) {
(...skipping 1725 matching lines...) Expand 10 before | Expand all | Expand 10 after
2066 void RenderWidget::requestPointerUnlock() { 2086 void RenderWidget::requestPointerUnlock() {
2067 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); 2087 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get());
2068 } 2088 }
2069 2089
2070 bool RenderWidget::isPointerLocked() { 2090 bool RenderWidget::isPointerLocked() {
2071 return mouse_lock_dispatcher_->IsMouseLockedTo( 2091 return mouse_lock_dispatcher_->IsMouseLockedTo(
2072 webwidget_mouse_lock_target_.get()); 2092 webwidget_mouse_lock_target_.get());
2073 } 2093 }
2074 2094
2075 } // namespace content 2095 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698