| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/debug/trace_event_synthetic_delay.h" | 10 #include "base/debug/trace_event_synthetic_delay.h" |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 opener_id_ = opener_id; | 458 opener_id_ = opener_id; |
| 459 | 459 |
| 460 webwidget_ = web_widget; | 460 webwidget_ = web_widget; |
| 461 | 461 |
| 462 bool result = RenderThread::Get()->Send(create_widget_message); | 462 bool result = RenderThread::Get()->Send(create_widget_message); |
| 463 if (result) { | 463 if (result) { |
| 464 RenderThread::Get()->AddRoute(routing_id_, this); | 464 RenderThread::Get()->AddRoute(routing_id_, this); |
| 465 // Take a reference on behalf of the RenderThread. This will be balanced | 465 // Take a reference on behalf of the RenderThread. This will be balanced |
| 466 // when we receive ViewMsg_Close. | 466 // when we receive ViewMsg_Close. |
| 467 AddRef(); | 467 AddRef(); |
| 468 if (is_hidden_) | 468 if (RenderThreadImpl::current()) { |
| 469 RenderThread::Get()->WidgetHidden(); | 469 RenderThreadImpl::current()->WidgetCreated(); |
| 470 if (is_hidden_) |
| 471 RenderThreadImpl::current()->WidgetHidden(); |
| 472 } |
| 470 return true; | 473 return true; |
| 471 } else { | 474 } else { |
| 472 // The above Send can fail when the tab is closing. | 475 // The above Send can fail when the tab is closing. |
| 473 return false; | 476 return false; |
| 474 } | 477 } |
| 475 } | 478 } |
| 476 | 479 |
| 477 // This is used to complete pending inits and non-pending inits. | 480 // This is used to complete pending inits and non-pending inits. |
| 478 void RenderWidget::CompleteInit() { | 481 void RenderWidget::CompleteInit() { |
| 479 DCHECK(routing_id_ != MSG_ROUTING_NONE); | 482 DCHECK(routing_id_ != MSG_ROUTING_NONE); |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 initial_pos_ = new_position; | 718 initial_pos_ = new_position; |
| 716 } | 719 } |
| 717 | 720 |
| 718 void RenderWidget::OnClose() { | 721 void RenderWidget::OnClose() { |
| 719 if (closing_) | 722 if (closing_) |
| 720 return; | 723 return; |
| 721 closing_ = true; | 724 closing_ = true; |
| 722 | 725 |
| 723 // Browser correspondence is no longer needed at this point. | 726 // Browser correspondence is no longer needed at this point. |
| 724 if (routing_id_ != MSG_ROUTING_NONE) { | 727 if (routing_id_ != MSG_ROUTING_NONE) { |
| 728 if (RenderThreadImpl::current()) |
| 729 RenderThreadImpl::current()->WidgetDestroyed(); |
| 725 RenderThread::Get()->RemoveRoute(routing_id_); | 730 RenderThread::Get()->RemoveRoute(routing_id_); |
| 726 SetHidden(false); | 731 SetHidden(false); |
| 727 } | 732 } |
| 728 | 733 |
| 729 // If there is a Send call on the stack, then it could be dangerous to close | 734 // If there is a Send call on the stack, then it could be dangerous to close |
| 730 // now. Post a task that only gets invoked when there are no nested message | 735 // now. Post a task that only gets invoked when there are no nested message |
| 731 // loops. | 736 // loops. |
| 732 base::MessageLoop::current()->PostNonNestableTask( | 737 base::MessageLoop::current()->PostNonNestableTask( |
| 733 FROM_HERE, base::Bind(&RenderWidget::Close, this)); | 738 FROM_HERE, base::Bind(&RenderWidget::Close, this)); |
| 734 | 739 |
| (...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2376 return gfx::Vector2d(); | 2381 return gfx::Vector2d(); |
| 2377 } | 2382 } |
| 2378 | 2383 |
| 2379 void RenderWidget::SetHidden(bool hidden) { | 2384 void RenderWidget::SetHidden(bool hidden) { |
| 2380 if (is_hidden_ == hidden) | 2385 if (is_hidden_ == hidden) |
| 2381 return; | 2386 return; |
| 2382 | 2387 |
| 2383 // The status has changed. Tell the RenderThread about it. | 2388 // The status has changed. Tell the RenderThread about it. |
| 2384 is_hidden_ = hidden; | 2389 is_hidden_ = hidden; |
| 2385 if (is_hidden_) | 2390 if (is_hidden_) |
| 2386 RenderThread::Get()->WidgetHidden(); | 2391 RenderThreadImpl::current()->WidgetHidden(); |
| 2387 else | 2392 else |
| 2388 RenderThread::Get()->WidgetRestored(); | 2393 RenderThreadImpl::current()->WidgetRestored(); |
| 2389 } | 2394 } |
| 2390 | 2395 |
| 2391 void RenderWidget::WillToggleFullscreen() { | 2396 void RenderWidget::WillToggleFullscreen() { |
| 2392 if (!webwidget_) | 2397 if (!webwidget_) |
| 2393 return; | 2398 return; |
| 2394 | 2399 |
| 2395 if (is_fullscreen_) { | 2400 if (is_fullscreen_) { |
| 2396 webwidget_->willExitFullScreen(); | 2401 webwidget_->willExitFullScreen(); |
| 2397 } else { | 2402 } else { |
| 2398 webwidget_->willEnterFullScreen(); | 2403 webwidget_->willEnterFullScreen(); |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2870 surface_id(), | 2875 surface_id(), |
| 2871 GetURLForGraphicsContext3D(), | 2876 GetURLForGraphicsContext3D(), |
| 2872 gpu_channel_host.get(), | 2877 gpu_channel_host.get(), |
| 2873 attributes, | 2878 attributes, |
| 2874 false /* bind generates resources */, | 2879 false /* bind generates resources */, |
| 2875 limits)); | 2880 limits)); |
| 2876 return context.Pass(); | 2881 return context.Pass(); |
| 2877 } | 2882 } |
| 2878 | 2883 |
| 2879 } // namespace content | 2884 } // namespace content |
| OLD | NEW |