| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/tab_contents/render_view_host_manager.h" | 5 #include "content/browser/tab_contents/render_view_host_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
| (...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 web_ui_.reset(); | 684 web_ui_.reset(); |
| 685 | 685 |
| 686 // Hide the current view and prepare to destroy it. | 686 // Hide the current view and prepare to destroy it. |
| 687 if (render_view_host_->view()) | 687 if (render_view_host_->view()) |
| 688 render_view_host_->view()->Hide(); | 688 render_view_host_->view()->Hide(); |
| 689 RenderViewHost* old_render_view_host = render_view_host_; | 689 RenderViewHost* old_render_view_host = render_view_host_; |
| 690 | 690 |
| 691 // Swap in the new view and make it active. | 691 // Swap in the new view and make it active. |
| 692 render_view_host_ = rvh; | 692 render_view_host_ = rvh; |
| 693 render_view_host_->set_delegate(render_view_delegate_); | 693 render_view_host_->set_delegate(render_view_delegate_); |
| 694 // Remove old RenderWidgetHostView with mocked out methods so it can be |
| 695 // replaced with a new one that's a child of |delegate_|'s view. |
| 696 scoped_ptr<RenderWidgetHostView> old_view(render_view_host_->view()); |
| 697 render_view_host_->set_view(NULL); |
| 694 delegate_->CreateViewAndSetSizeForRVH(render_view_host_); | 698 delegate_->CreateViewAndSetSizeForRVH(render_view_host_); |
| 695 render_view_host_->ActivateDeferredPluginHandles(); | 699 render_view_host_->ActivateDeferredPluginHandles(); |
| 696 // If the view is gone, then this RenderViewHost died while it was hidden. | 700 // If the view is gone, then this RenderViewHost died while it was hidden. |
| 697 // We ignored the RenderViewGone call at the time, so we should send it now | 701 // We ignored the RenderViewGone call at the time, so we should send it now |
| 698 // to make sure the sad tab shows up, etc. | 702 // to make sure the sad tab shows up, etc. |
| 699 if (render_view_host_->view()) { | 703 if (render_view_host_->view()) { |
| 700 // TODO(tburkard,cbentzel): Figure out why this hack is needed and/or | 704 // The Hide() is needed to sync the state of |render_view_host_|, which is |
| 701 // if it can be removed. On Windows, prerendering will not work without | 705 // hidden, with the newly created view, which does not know the |
| 702 // doing a Hide before the Show. | 706 // RenderViewHost is hidden. |
| 707 // TODO(tburkard,cbentzel): Figure out if this hack can be removed |
| 708 // (http://crbug.com/79891). |
| 703 render_view_host_->view()->Hide(); | 709 render_view_host_->view()->Hide(); |
| 704 render_view_host_->view()->Show(); | 710 render_view_host_->view()->Show(); |
| 705 } | 711 } |
| 706 | 712 |
| 707 delegate_->UpdateRenderViewSizeForRenderManager(); | 713 delegate_->UpdateRenderViewSizeForRenderManager(); |
| 708 | 714 |
| 709 RenderViewHostSwitchedDetails details; | 715 RenderViewHostSwitchedDetails details; |
| 710 details.new_host = render_view_host_; | 716 details.new_host = render_view_host_; |
| 711 details.old_host = old_render_view_host; | 717 details.old_host = old_render_view_host; |
| 712 NotificationService::current()->Notify( | 718 NotificationService::current()->Notify( |
| 713 NotificationType::RENDER_VIEW_HOST_CHANGED, | 719 NotificationType::RENDER_VIEW_HOST_CHANGED, |
| 714 Source<NavigationController>(&delegate_->GetControllerForRenderManager()), | 720 Source<NavigationController>(&delegate_->GetControllerForRenderManager()), |
| 715 Details<RenderViewHostSwitchedDetails>(&details)); | 721 Details<RenderViewHostSwitchedDetails>(&details)); |
| 716 | 722 |
| 717 // This will cause the old RenderViewHost to delete itself. | 723 // This will cause the old RenderViewHost to delete itself. |
| 718 old_render_view_host->Shutdown(); | 724 old_render_view_host->Shutdown(); |
| 719 | 725 |
| 720 // Let the task manager know that we've swapped RenderViewHosts, since it | 726 // Let the task manager know that we've swapped RenderViewHosts, since it |
| 721 // might need to update its process groupings. | 727 // might need to update its process groupings. |
| 722 delegate_->NotifySwappedFromRenderManager(); | 728 delegate_->NotifySwappedFromRenderManager(); |
| 723 } | 729 } |
| OLD | NEW |