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/browser/web_contents/render_view_host_manager.h" | 5 #include "content/browser/web_contents/render_view_host_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 int routing_id, | 77 int routing_id, |
78 int main_frame_routing_id) { | 78 int main_frame_routing_id) { |
79 // Create a RenderViewHost, once we have an instance. It is important to | 79 // Create a RenderViewHost, once we have an instance. It is important to |
80 // immediately give this SiteInstance to a RenderViewHost so that it is | 80 // immediately give this SiteInstance to a RenderViewHost so that it is |
81 // ref counted. | 81 // ref counted. |
82 if (!site_instance) | 82 if (!site_instance) |
83 site_instance = SiteInstance::Create(browser_context); | 83 site_instance = SiteInstance::Create(browser_context); |
84 render_view_host_ = static_cast<RenderViewHostImpl*>( | 84 render_view_host_ = static_cast<RenderViewHostImpl*>( |
85 RenderViewHostFactory::Create( | 85 RenderViewHostFactory::Create( |
86 site_instance, render_view_delegate_, render_widget_delegate_, | 86 site_instance, render_view_delegate_, render_widget_delegate_, |
87 routing_id, main_frame_routing_id, false, delegate_->IsHidden())); | 87 routing_id, main_frame_routing_id, false, |
| 88 delegate_->IsHidden())); |
| 89 render_view_host_->AttachToFrameTree(); |
88 | 90 |
89 // Keep track of renderer processes as they start to shut down or are | 91 // Keep track of renderer processes as they start to shut down or are |
90 // crashed/killed. | 92 // crashed/killed. |
91 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSED, | 93 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSED, |
92 NotificationService::AllSources()); | 94 NotificationService::AllSources()); |
93 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSING, | 95 registrar_.Add(this, NOTIFICATION_RENDERER_PROCESS_CLOSING, |
94 NotificationService::AllSources()); | 96 NotificationService::AllSources()); |
95 } | 97 } |
96 | 98 |
97 RenderViewHostImpl* RenderViewHostManager::current_host() const { | 99 RenderViewHostImpl* RenderViewHostManager::current_host() const { |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 if (will_focus_location_bar) | 732 if (will_focus_location_bar) |
731 delegate_->SetFocusToLocationBar(false); | 733 delegate_->SetFocusToLocationBar(false); |
732 return; | 734 return; |
733 } | 735 } |
734 | 736 |
735 // Remember if the page was focused so we can focus the new renderer in | 737 // Remember if the page was focused so we can focus the new renderer in |
736 // that case. | 738 // that case. |
737 bool focus_render_view = !will_focus_location_bar && | 739 bool focus_render_view = !will_focus_location_bar && |
738 render_view_host_->GetView() && render_view_host_->GetView()->HasFocus(); | 740 render_view_host_->GetView() && render_view_host_->GetView()->HasFocus(); |
739 | 741 |
740 // Swap in the pending view and make it active. | 742 // Swap in the pending view and make it active. Also ensure the FrameTree |
| 743 // stays in sync. |
741 RenderViewHostImpl* old_render_view_host = render_view_host_; | 744 RenderViewHostImpl* old_render_view_host = render_view_host_; |
742 render_view_host_ = pending_render_view_host_; | 745 render_view_host_ = pending_render_view_host_; |
743 pending_render_view_host_ = NULL; | 746 pending_render_view_host_ = NULL; |
| 747 render_view_host_->AttachToFrameTree(); |
744 | 748 |
745 // The process will no longer try to exit, so we can decrement the count. | 749 // The process will no longer try to exit, so we can decrement the count. |
746 render_view_host_->GetProcess()->RemovePendingView(); | 750 render_view_host_->GetProcess()->RemovePendingView(); |
747 | 751 |
748 // If the view is gone, then this RenderViewHost died while it was hidden. | 752 // If the view is gone, then this RenderViewHost died while it was hidden. |
749 // We ignored the RenderProcessGone call at the time, so we should send it now | 753 // We ignored the RenderProcessGone call at the time, so we should send it now |
750 // to make sure the sad tab shows up, etc. | 754 // to make sure the sad tab shows up, etc. |
751 if (!render_view_host_->GetView()) | 755 if (!render_view_host_->GetView()) |
752 delegate_->RenderProcessGoneFromRenderManager(render_view_host_); | 756 delegate_->RenderProcessGoneFromRenderManager(render_view_host_); |
753 else if (!delegate_->IsHidden()) | 757 else if (!delegate_->IsHidden()) |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1045 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( | 1049 RenderViewHostImpl* RenderViewHostManager::GetSwappedOutRenderViewHost( |
1046 SiteInstance* instance) { | 1050 SiteInstance* instance) { |
1047 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); | 1051 RenderViewHostMap::iterator iter = swapped_out_hosts_.find(instance->GetId()); |
1048 if (iter != swapped_out_hosts_.end()) | 1052 if (iter != swapped_out_hosts_.end()) |
1049 return iter->second; | 1053 return iter->second; |
1050 | 1054 |
1051 return NULL; | 1055 return NULL; |
1052 } | 1056 } |
1053 | 1057 |
1054 } // namespace content | 1058 } // namespace content |
OLD | NEW |