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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 void RenderWidget::CloseForFrame() { | 378 void RenderWidget::CloseForFrame() { |
379 OnClose(); | 379 OnClose(); |
380 } | 380 } |
381 | 381 |
382 void RenderWidget::SetRoutingID(int32_t routing_id) { | 382 void RenderWidget::SetRoutingID(int32_t routing_id) { |
383 routing_id_ = routing_id; | 383 routing_id_ = routing_id; |
384 input_handler_.reset(new RenderWidgetInputHandler( | 384 input_handler_.reset(new RenderWidgetInputHandler( |
385 GetRenderWidgetInputHandlerDelegate(this), this)); | 385 GetRenderWidgetInputHandlerDelegate(this), this)); |
386 } | 386 } |
387 | 387 |
| 388 void RenderWidget::SetSwappedOut(bool is_swapped_out) { |
| 389 // We should only toggle between states. |
| 390 DCHECK(is_swapped_out_ != is_swapped_out); |
| 391 is_swapped_out_ = is_swapped_out; |
| 392 |
| 393 // If we are swapping out, we will call ReleaseProcess, allowing the process |
| 394 // to exit if all of its RenderViews are swapped out. We wait until the |
| 395 // WasSwappedOut call to do this, to allow the unload handler to finish. |
| 396 // If we are swapping in, we call AddRefProcess to prevent the process from |
| 397 // exiting. |
| 398 if (!is_swapped_out_) |
| 399 RenderProcess::current()->AddRefProcess(); |
| 400 } |
| 401 |
388 bool RenderWidget::Init(int32_t opener_id) { | 402 bool RenderWidget::Init(int32_t opener_id) { |
389 bool success = DoInit( | 403 bool success = DoInit( |
390 opener_id, RenderWidget::CreateWebWidget(this), | 404 opener_id, RenderWidget::CreateWebWidget(this), |
391 new ViewHostMsg_CreateWidget(opener_id, popup_type_, &routing_id_)); | 405 new ViewHostMsg_CreateWidget(opener_id, popup_type_, &routing_id_)); |
392 if (success) { | 406 if (success) { |
393 SetRoutingID(routing_id_); | 407 SetRoutingID(routing_id_); |
394 return true; | 408 return true; |
395 } | 409 } |
396 return false; | 410 return false; |
397 } | 411 } |
(...skipping 26 matching lines...) Expand all Loading... |
424 RenderThreadImpl::current()->WidgetHidden(); | 438 RenderThreadImpl::current()->WidgetHidden(); |
425 } | 439 } |
426 | 440 |
427 return true; | 441 return true; |
428 } else { | 442 } else { |
429 // The above Send can fail when the tab is closing. | 443 // The above Send can fail when the tab is closing. |
430 return false; | 444 return false; |
431 } | 445 } |
432 } | 446 } |
433 | 447 |
434 void RenderWidget::SetSwappedOut(bool is_swapped_out) { | |
435 // We should only toggle between states. | |
436 DCHECK(is_swapped_out_ != is_swapped_out); | |
437 is_swapped_out_ = is_swapped_out; | |
438 | |
439 // If we are swapping out, we will call ReleaseProcess, allowing the process | |
440 // to exit if all of its RenderViews are swapped out. We wait until the | |
441 // WasSwappedOut call to do this, to allow the unload handler to finish. | |
442 // If we are swapping in, we call AddRefProcess to prevent the process from | |
443 // exiting. | |
444 if (!is_swapped_out_) | |
445 RenderProcess::current()->AddRefProcess(); | |
446 } | |
447 | |
448 void RenderWidget::WasSwappedOut() { | 448 void RenderWidget::WasSwappedOut() { |
449 // If we have been swapped out and no one else is using this process, | 449 // If we have been swapped out and no one else is using this process, |
450 // it's safe to exit now. | 450 // it's safe to exit now. |
451 CHECK(is_swapped_out_); | 451 CHECK(is_swapped_out_); |
452 RenderProcess::current()->ReleaseProcess(); | 452 RenderProcess::current()->ReleaseProcess(); |
453 } | 453 } |
454 | 454 |
455 void RenderWidget::SetPopupOriginAdjustmentsForEmulation( | 455 void RenderWidget::SetPopupOriginAdjustmentsForEmulation( |
456 RenderWidgetScreenMetricsEmulator* emulator) { | 456 RenderWidgetScreenMetricsEmulator* emulator) { |
457 popup_origin_scale_for_emulation_ = emulator->scale(); | 457 popup_origin_scale_for_emulation_ = emulator->scale(); |
(...skipping 1719 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2177 bool RenderWidget::isPointerLocked() { | 2177 bool RenderWidget::isPointerLocked() { |
2178 return mouse_lock_dispatcher_->IsMouseLockedTo( | 2178 return mouse_lock_dispatcher_->IsMouseLockedTo( |
2179 webwidget_mouse_lock_target_.get()); | 2179 webwidget_mouse_lock_target_.get()); |
2180 } | 2180 } |
2181 | 2181 |
2182 blink::WebWidget* RenderWidget::GetWebWidget() const { | 2182 blink::WebWidget* RenderWidget::GetWebWidget() const { |
2183 return webwidget_internal_; | 2183 return webwidget_internal_; |
2184 } | 2184 } |
2185 | 2185 |
2186 } // namespace content | 2186 } // namespace content |
OLD | NEW |