| 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 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 |
| 216 } // namespace | 219 } // namespace |
| 217 | 220 |
| 218 namespace content { | 221 namespace content { |
| 219 | 222 |
| 220 // RenderWidget --------------------------------------------------------------- | 223 // RenderWidget --------------------------------------------------------------- |
| 221 | 224 |
| 222 RenderWidget::RenderWidget(CompositorDependencies* compositor_deps, | 225 RenderWidget::RenderWidget(CompositorDependencies* compositor_deps, |
| 223 blink::WebPopupType popup_type, | 226 blink::WebPopupType popup_type, |
| 224 const blink::WebScreenInfo& screen_info, | 227 const blink::WebScreenInfo& screen_info, |
| 225 bool swapped_out, | 228 bool swapped_out, |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 | 284 |
| 282 RenderWidget::~RenderWidget() { | 285 RenderWidget::~RenderWidget() { |
| 283 DCHECK(!webwidget_) << "Leaking our WebWidget!"; | 286 DCHECK(!webwidget_) << "Leaking our WebWidget!"; |
| 284 | 287 |
| 285 // If we are swapped out, we have released already. | 288 // If we are swapped out, we have released already. |
| 286 if (!is_swapped_out_ && RenderProcess::current()) | 289 if (!is_swapped_out_ && RenderProcess::current()) |
| 287 RenderProcess::current()->ReleaseProcess(); | 290 RenderProcess::current()->ReleaseProcess(); |
| 288 } | 291 } |
| 289 | 292 |
| 290 // static | 293 // static |
| 294 void RenderWidget::InstallCreateHook( |
| 295 CreateRenderWidgetFunction create_render_widget) { |
| 296 CHECK(!g_create_render_widget); |
| 297 g_create_render_widget = create_render_widget; |
| 298 } |
| 299 |
| 300 // static |
| 291 RenderWidget* RenderWidget::Create(int32_t opener_id, | 301 RenderWidget* RenderWidget::Create(int32_t opener_id, |
| 292 CompositorDependencies* compositor_deps, | 302 CompositorDependencies* compositor_deps, |
| 293 blink::WebPopupType popup_type, | 303 blink::WebPopupType popup_type, |
| 294 const blink::WebScreenInfo& screen_info) { | 304 const blink::WebScreenInfo& screen_info) { |
| 295 DCHECK(opener_id != MSG_ROUTING_NONE); | 305 DCHECK(opener_id != MSG_ROUTING_NONE); |
| 296 scoped_refptr<RenderWidget> widget(new RenderWidget( | 306 scoped_refptr<RenderWidget> widget(new RenderWidget( |
| 297 compositor_deps, popup_type, screen_info, false, false, false)); | 307 compositor_deps, popup_type, screen_info, false, false, false)); |
| 298 if (widget->Init(opener_id)) { // adds reference on success. | 308 if (widget->Init(opener_id)) { // adds reference on success. |
| 299 return widget.get(); | 309 return widget.get(); |
| 300 } | 310 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 312 // TODO(avi): Before RenderViewImpl has-a RenderWidget, the browser passes the | 322 // 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 | 323 // same routing ID for both the view routing ID and the main frame widget |
| 314 // routing ID. https://crbug.com/545684 | 324 // routing ID. https://crbug.com/545684 |
| 315 RenderViewImpl* view = RenderViewImpl::FromRoutingID(routing_id); | 325 RenderViewImpl* view = RenderViewImpl::FromRoutingID(routing_id); |
| 316 if (view) { | 326 if (view) { |
| 317 view->AttachWebFrameWidget( | 327 view->AttachWebFrameWidget( |
| 318 RenderWidget::CreateWebFrameWidget(view->GetWidget(), frame)); | 328 RenderWidget::CreateWebFrameWidget(view->GetWidget(), frame)); |
| 319 return view->GetWidget(); | 329 return view->GetWidget(); |
| 320 } | 330 } |
| 321 scoped_refptr<RenderWidget> widget( | 331 scoped_refptr<RenderWidget> widget( |
| 322 new RenderWidget(compositor_deps, blink::WebPopupTypeNone, screen_info, | 332 g_create_render_widget |
| 323 false, hidden, false)); | 333 ? g_create_render_widget(compositor_deps, blink::WebPopupTypeNone, |
| 334 screen_info, false, hidden, false) |
| 335 : new RenderWidget(compositor_deps, blink::WebPopupTypeNone, |
| 336 screen_info, false, hidden, false)); |
| 324 widget->SetRoutingID(routing_id); | 337 widget->SetRoutingID(routing_id); |
| 325 widget->for_oopif_ = true; | 338 widget->for_oopif_ = true; |
| 326 // DoInit increments the reference count on |widget|, keeping it alive after | 339 // DoInit increments the reference count on |widget|, keeping it alive after |
| 327 // this function returns. | 340 // this function returns. |
| 328 if (widget->DoInit(MSG_ROUTING_NONE, | 341 if (widget->DoInit(MSG_ROUTING_NONE, |
| 329 RenderWidget::CreateWebFrameWidget(widget.get(), frame), | 342 RenderWidget::CreateWebFrameWidget(widget.get(), frame), |
| 330 nullptr)) { | 343 nullptr)) { |
| 331 return widget.get(); | 344 return widget.get(); |
| 332 } | 345 } |
| 333 return nullptr; | 346 return nullptr; |
| (...skipping 1732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2066 void RenderWidget::requestPointerUnlock() { | 2079 void RenderWidget::requestPointerUnlock() { |
| 2067 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); | 2080 mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); |
| 2068 } | 2081 } |
| 2069 | 2082 |
| 2070 bool RenderWidget::isPointerLocked() { | 2083 bool RenderWidget::isPointerLocked() { |
| 2071 return mouse_lock_dispatcher_->IsMouseLockedTo( | 2084 return mouse_lock_dispatcher_->IsMouseLockedTo( |
| 2072 webwidget_mouse_lock_target_.get()); | 2085 webwidget_mouse_lock_target_.get()); |
| 2073 } | 2086 } |
| 2074 | 2087 |
| 2075 } // namespace content | 2088 } // namespace content |
| OLD | NEW |