| OLD | NEW |
| 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 return content::RenderWidgetMusConnection::GetOrCreate( | 205 return content::RenderWidgetMusConnection::GetOrCreate( |
| 206 widget->routing_id()); | 206 widget->routing_id()); |
| 207 } | 207 } |
| 208 #endif | 208 #endif |
| 209 // If we don't have a connection to the Mojo shell, then we want to route IPCs | 209 // If we don't have a connection to the Mojo shell, then we want to route IPCs |
| 210 // back to the browser process rather than Mus so we use the |widget| as the | 210 // back to the browser process rather than Mus so we use the |widget| as the |
| 211 // RenderWidgetInputHandlerDelegate. | 211 // RenderWidgetInputHandlerDelegate. |
| 212 return widget; | 212 return widget; |
| 213 } | 213 } |
| 214 | 214 |
| 215 content::RenderWidget::CreateRenderWidgetFunction g_create_render_widget = |
| 216 nullptr; |
| 217 |
| 215 } // namespace | 218 } // namespace |
| 216 | 219 |
| 217 namespace content { | 220 namespace content { |
| 218 | 221 |
| 219 // RenderWidget --------------------------------------------------------------- | 222 // RenderWidget --------------------------------------------------------------- |
| 220 | 223 |
| 221 RenderWidget::RenderWidget(CompositorDependencies* compositor_deps, | 224 RenderWidget::RenderWidget(CompositorDependencies* compositor_deps, |
| 222 blink::WebPopupType popup_type, | 225 blink::WebPopupType popup_type, |
| 223 const blink::WebScreenInfo& screen_info, | 226 const blink::WebScreenInfo& screen_info, |
| 224 bool swapped_out, | 227 bool swapped_out, |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 281 |
| 279 RenderWidget::~RenderWidget() { | 282 RenderWidget::~RenderWidget() { |
| 280 DCHECK(!webwidget_) << "Leaking our WebWidget!"; | 283 DCHECK(!webwidget_) << "Leaking our WebWidget!"; |
| 281 | 284 |
| 282 // If we are swapped out, we have released already. | 285 // If we are swapped out, we have released already. |
| 283 if (!is_swapped_out_ && RenderProcess::current()) | 286 if (!is_swapped_out_ && RenderProcess::current()) |
| 284 RenderProcess::current()->ReleaseProcess(); | 287 RenderProcess::current()->ReleaseProcess(); |
| 285 } | 288 } |
| 286 | 289 |
| 287 // static | 290 // static |
| 291 void RenderWidget::InstallCreateHook( |
| 292 CreateRenderWidgetFunction create_render_widget) { |
| 293 CHECK(!g_create_render_widget); |
| 294 g_create_render_widget = create_render_widget; |
| 295 } |
| 296 |
| 297 // static |
| 288 RenderWidget* RenderWidget::Create(int32_t opener_id, | 298 RenderWidget* RenderWidget::Create(int32_t opener_id, |
| 289 CompositorDependencies* compositor_deps, | 299 CompositorDependencies* compositor_deps, |
| 290 blink::WebPopupType popup_type, | 300 blink::WebPopupType popup_type, |
| 291 const blink::WebScreenInfo& screen_info) { | 301 const blink::WebScreenInfo& screen_info) { |
| 292 DCHECK(opener_id != MSG_ROUTING_NONE); | 302 DCHECK(opener_id != MSG_ROUTING_NONE); |
| 293 scoped_refptr<RenderWidget> widget(new RenderWidget( | 303 scoped_refptr<RenderWidget> widget(new RenderWidget( |
| 294 compositor_deps, popup_type, screen_info, false, false, false)); | 304 compositor_deps, popup_type, screen_info, false, false, false)); |
| 295 if (widget->Init(opener_id)) { // adds reference on success. | 305 if (widget->Init(opener_id)) { // adds reference on success. |
| 296 return widget.get(); | 306 return widget.get(); |
| 297 } | 307 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 309 // TODO(avi): Before RenderViewImpl has-a RenderWidget, the browser passes the | 319 // TODO(avi): Before RenderViewImpl has-a RenderWidget, the browser passes the |
| 310 // same routing ID for both the view routing ID and the main frame widget | 320 // same routing ID for both the view routing ID and the main frame widget |
| 311 // routing ID. https://crbug.com/545684 | 321 // routing ID. https://crbug.com/545684 |
| 312 RenderViewImpl* view = RenderViewImpl::FromRoutingID(routing_id); | 322 RenderViewImpl* view = RenderViewImpl::FromRoutingID(routing_id); |
| 313 if (view) { | 323 if (view) { |
| 314 view->AttachWebFrameWidget( | 324 view->AttachWebFrameWidget( |
| 315 RenderWidget::CreateWebFrameWidget(view->GetWidget(), frame)); | 325 RenderWidget::CreateWebFrameWidget(view->GetWidget(), frame)); |
| 316 return view->GetWidget(); | 326 return view->GetWidget(); |
| 317 } | 327 } |
| 318 scoped_refptr<RenderWidget> widget( | 328 scoped_refptr<RenderWidget> widget( |
| 319 new RenderWidget(compositor_deps, blink::WebPopupTypeNone, screen_info, | 329 g_create_render_widget |
| 320 false, hidden, false)); | 330 ? g_create_render_widget(compositor_deps, blink::WebPopupTypeNone, |
| 331 screen_info, false, hidden, false) |
| 332 : new RenderWidget(compositor_deps, blink::WebPopupTypeNone, |
| 333 screen_info, false, hidden, false)); |
| 321 widget->SetRoutingID(routing_id); | 334 widget->SetRoutingID(routing_id); |
| 322 widget->for_oopif_ = true; | 335 widget->for_oopif_ = true; |
| 323 // DoInit increments the reference count on |widget|, keeping it alive after | 336 // DoInit increments the reference count on |widget|, keeping it alive after |
| 324 // this function returns. | 337 // this function returns. |
| 325 if (widget->DoInit(MSG_ROUTING_NONE, | 338 if (widget->DoInit(MSG_ROUTING_NONE, |
| 326 RenderWidget::CreateWebFrameWidget(widget.get(), frame), | 339 RenderWidget::CreateWebFrameWidget(widget.get(), frame), |
| 327 nullptr)) { | 340 nullptr)) { |
| 328 return widget.get(); | 341 return widget.get(); |
| 329 } | 342 } |
| 330 return nullptr; | 343 return nullptr; |
| (...skipping 1709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2040 void RenderWidget::requestPointerUnlock() { | 2053 void RenderWidget::requestPointerUnlock() { |
| 2041 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); | 2054 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); |
| 2042 } | 2055 } |
| 2043 | 2056 |
| 2044 bool RenderWidget::isPointerLocked() { | 2057 bool RenderWidget::isPointerLocked() { |
| 2045 return mouse_lock_dispatcher_->IsMouseLockedTo( | 2058 return mouse_lock_dispatcher_->IsMouseLockedTo( |
| 2046 webwidget_mouse_lock_target_.get()); | 2059 webwidget_mouse_lock_target_.get()); |
| 2047 } | 2060 } |
| 2048 | 2061 |
| 2049 } // namespace content | 2062 } // namespace content |
| OLD | NEW |