| 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 "content/browser/content_browser_client.h" | 9 #include "content/browser/content_browser_client.h" |
| 10 #include "content/browser/renderer_host/render_view_host.h" | 10 #include "content/browser/renderer_host/render_view_host.h" |
| 11 #include "content/browser/renderer_host/render_view_host_delegate.h" | 11 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 12 #include "content/browser/renderer_host/render_view_host_factory.h" | 12 #include "content/browser/renderer_host/render_view_host_factory.h" |
| 13 #include "content/browser/renderer_host/render_widget_host_view.h" | 13 #include "content/browser/renderer_host/render_widget_host_view.h" |
| 14 #include "content/browser/site_instance.h" | 14 #include "content/browser/site_instance.h" |
| 15 #include "content/browser/tab_contents/navigation_controller.h" | 15 #include "content/browser/tab_contents/navigation_controller.h" |
| 16 #include "content/browser/tab_contents/navigation_entry.h" | 16 #include "content/browser/tab_contents/navigation_entry.h" |
| 17 #include "content/browser/tab_contents/tab_contents_view.h" | 17 #include "content/browser/tab_contents/tab_contents_view.h" |
| 18 #include "content/browser/webui/web_ui.h" | 18 #include "content/browser/webui/web_ui.h" |
| 19 #include "content/browser/webui/web_ui_factory.h" | 19 #include "content/browser/webui/web_ui_factory.h" |
| 20 #include "content/common/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
| 21 #include "content/common/view_messages.h" | 21 #include "content/common/view_messages.h" |
| 22 #include "content/public/browser/notification_types.h" | 22 #include "content/public/browser/notification_types.h" |
| 23 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
| 24 #include "content/public/common/url_constants.h" | 24 #include "content/public/common/url_constants.h" |
| 25 | 25 |
| 26 namespace base { | 26 namespace base { |
| 27 class WaitableEvent; | 27 class WaitableEvent; |
| 28 } | 28 } |
| 29 | 29 |
| 30 RenderViewHostManager::RenderViewHostManager( | 30 RenderViewHostManager::RenderViewHostManager( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // immediately give this SiteInstance to a RenderViewHost so that it is | 62 // immediately give this SiteInstance to a RenderViewHost so that it is |
| 63 // ref counted. | 63 // ref counted. |
| 64 if (!site_instance) | 64 if (!site_instance) |
| 65 site_instance = SiteInstance::CreateSiteInstance(browser_context); | 65 site_instance = SiteInstance::CreateSiteInstance(browser_context); |
| 66 render_view_host_ = RenderViewHostFactory::Create( | 66 render_view_host_ = RenderViewHostFactory::Create( |
| 67 site_instance, render_view_delegate_, routing_id, delegate_-> | 67 site_instance, render_view_delegate_, routing_id, delegate_-> |
| 68 GetControllerForRenderManager().session_storage_namespace()); | 68 GetControllerForRenderManager().session_storage_namespace()); |
| 69 | 69 |
| 70 // Keep track of renderer processes as they start to shut down. | 70 // Keep track of renderer processes as they start to shut down. |
| 71 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSING, | 71 registrar_.Add(this, content::NOTIFICATION_RENDERER_PROCESS_CLOSING, |
| 72 NotificationService::AllSources()); | 72 content::NotificationService::AllSources()); |
| 73 } | 73 } |
| 74 | 74 |
| 75 RenderWidgetHostView* RenderViewHostManager::GetRenderWidgetHostView() const { | 75 RenderWidgetHostView* RenderViewHostManager::GetRenderWidgetHostView() const { |
| 76 if (!render_view_host_) | 76 if (!render_view_host_) |
| 77 return NULL; | 77 return NULL; |
| 78 return render_view_host_->view(); | 78 return render_view_host_->view(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 RenderViewHost* RenderViewHostManager::Navigate(const NavigationEntry& entry) { | 81 RenderViewHost* RenderViewHostManager::Navigate(const NavigationEntry& entry) { |
| 82 // Create a pending RenderViewHost. It will give us the one we should use | 82 // Create a pending RenderViewHost. It will give us the one we should use |
| (...skipping 22 matching lines...) Expand all Loading... |
| 105 // on it later. | 105 // on it later. |
| 106 if (dest_render_view_host != render_view_host_ && | 106 if (dest_render_view_host != render_view_host_ && |
| 107 dest_render_view_host->view()) { | 107 dest_render_view_host->view()) { |
| 108 dest_render_view_host->view()->Hide(); | 108 dest_render_view_host->view()->Hide(); |
| 109 } else { | 109 } else { |
| 110 // This is our primary renderer, notify here as we won't be calling | 110 // This is our primary renderer, notify here as we won't be calling |
| 111 // CommitPending (which does the notify). | 111 // CommitPending (which does the notify). |
| 112 RenderViewHostSwitchedDetails details; | 112 RenderViewHostSwitchedDetails details; |
| 113 details.new_host = render_view_host_; | 113 details.new_host = render_view_host_; |
| 114 details.old_host = NULL; | 114 details.old_host = NULL; |
| 115 NotificationService::current()->Notify( | 115 content::NotificationService::current()->Notify( |
| 116 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, | 116 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
| 117 content::Source<NavigationController>( | 117 content::Source<NavigationController>( |
| 118 &delegate_->GetControllerForRenderManager()), | 118 &delegate_->GetControllerForRenderManager()), |
| 119 content::Details<RenderViewHostSwitchedDetails>(&details)); | 119 content::Details<RenderViewHostSwitchedDetails>(&details)); |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 | 122 |
| 123 return dest_render_view_host; | 123 return dest_render_view_host; |
| 124 } | 124 } |
| 125 | 125 |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 606 delegate_->UpdateRenderViewSizeForRenderManager(); | 606 delegate_->UpdateRenderViewSizeForRenderManager(); |
| 607 | 607 |
| 608 if (will_focus_location_bar) | 608 if (will_focus_location_bar) |
| 609 delegate_->SetFocusToLocationBar(false); | 609 delegate_->SetFocusToLocationBar(false); |
| 610 else if (focus_render_view && render_view_host_->view()) | 610 else if (focus_render_view && render_view_host_->view()) |
| 611 render_view_host_->view()->Focus(); | 611 render_view_host_->view()->Focus(); |
| 612 | 612 |
| 613 RenderViewHostSwitchedDetails details; | 613 RenderViewHostSwitchedDetails details; |
| 614 details.new_host = render_view_host_; | 614 details.new_host = render_view_host_; |
| 615 details.old_host = old_render_view_host; | 615 details.old_host = old_render_view_host; |
| 616 NotificationService::current()->Notify( | 616 content::NotificationService::current()->Notify( |
| 617 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, | 617 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
| 618 content::Source<NavigationController>( | 618 content::Source<NavigationController>( |
| 619 &delegate_->GetControllerForRenderManager()), | 619 &delegate_->GetControllerForRenderManager()), |
| 620 content::Details<RenderViewHostSwitchedDetails>(&details)); | 620 content::Details<RenderViewHostSwitchedDetails>(&details)); |
| 621 | 621 |
| 622 // If the pending view was on the swapped out list, we can remove it. | 622 // If the pending view was on the swapped out list, we can remove it. |
| 623 swapped_out_hosts_.erase(render_view_host_->site_instance()->id()); | 623 swapped_out_hosts_.erase(render_view_host_->site_instance()->id()); |
| 624 | 624 |
| 625 // If the old RVH is live, we are swapping it out and should keep track of it | 625 // If the old RVH is live, we are swapping it out and should keep track of it |
| 626 // in case we navigate back to it. | 626 // in case we navigate back to it. |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 } | 802 } |
| 803 } | 803 } |
| 804 | 804 |
| 805 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { | 805 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { |
| 806 if (!rvh->site_instance()) | 806 if (!rvh->site_instance()) |
| 807 return false; | 807 return false; |
| 808 | 808 |
| 809 return swapped_out_hosts_.find(rvh->site_instance()->id()) != | 809 return swapped_out_hosts_.find(rvh->site_instance()->id()) != |
| 810 swapped_out_hosts_.end(); | 810 swapped_out_hosts_.end(); |
| 811 } | 811 } |
| OLD | NEW |