| 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/debugger/devtools_manager_impl.h" | 9 #include "content/browser/debugger/devtools_manager_impl.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_impl.h" | 15 #include "content/browser/tab_contents/navigation_controller_impl.h" |
| 16 #include "content/browser/tab_contents/navigation_entry_impl.h" | 16 #include "content/browser/tab_contents/navigation_entry_impl.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/public/browser/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/content_browser_client.h" | 22 #include "content/public/browser/content_browser_client.h" |
| 23 #include "content/public/browser/notification_types.h" | 23 #include "content/public/browser/notification_types.h" |
| 24 #include "content/public/common/content_switches.h" | 24 #include "content/public/common/content_switches.h" |
| 25 #include "content/public/common/url_constants.h" | 25 #include "content/public/common/url_constants.h" |
| 26 | 26 |
| 27 using content::NavigationController; |
| 27 using content::NavigationEntry; | 28 using content::NavigationEntry; |
| 28 using content::NavigationEntryImpl; | 29 using content::NavigationEntryImpl; |
| 29 | 30 |
| 30 RenderViewHostManager::RenderViewHostManager( | 31 RenderViewHostManager::RenderViewHostManager( |
| 31 RenderViewHostDelegate* render_view_delegate, | 32 RenderViewHostDelegate* render_view_delegate, |
| 32 Delegate* delegate) | 33 Delegate* delegate) |
| 33 : delegate_(delegate), | 34 : delegate_(delegate), |
| 34 cross_navigation_pending_(false), | 35 cross_navigation_pending_(false), |
| 35 render_view_delegate_(render_view_delegate), | 36 render_view_delegate_(render_view_delegate), |
| 36 render_view_host_(NULL), | 37 render_view_host_(NULL), |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 dest_render_view_host->view()) { | 109 dest_render_view_host->view()) { |
| 109 dest_render_view_host->view()->Hide(); | 110 dest_render_view_host->view()->Hide(); |
| 110 } else { | 111 } else { |
| 111 // This is our primary renderer, notify here as we won't be calling | 112 // This is our primary renderer, notify here as we won't be calling |
| 112 // CommitPending (which does the notify). | 113 // CommitPending (which does the notify). |
| 113 RenderViewHostSwitchedDetails details; | 114 RenderViewHostSwitchedDetails details; |
| 114 details.new_host = render_view_host_; | 115 details.new_host = render_view_host_; |
| 115 details.old_host = NULL; | 116 details.old_host = NULL; |
| 116 content::NotificationService::current()->Notify( | 117 content::NotificationService::current()->Notify( |
| 117 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, | 118 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
| 118 content::Source<content::NavigationController>( | 119 content::Source<NavigationController>( |
| 119 &delegate_->GetControllerForRenderManager()), | 120 &delegate_->GetControllerForRenderManager()), |
| 120 content::Details<RenderViewHostSwitchedDetails>(&details)); | 121 content::Details<RenderViewHostSwitchedDetails>(&details)); |
| 121 } | 122 } |
| 122 } | 123 } |
| 123 | 124 |
| 124 return dest_render_view_host; | 125 return dest_render_view_host; |
| 125 } | 126 } |
| 126 | 127 |
| 127 void RenderViewHostManager::Stop() { | 128 void RenderViewHostManager::Stop() { |
| 128 render_view_host_->Stop(); | 129 render_view_host_->Stop(); |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 if (will_focus_location_bar) | 597 if (will_focus_location_bar) |
| 597 delegate_->SetFocusToLocationBar(false); | 598 delegate_->SetFocusToLocationBar(false); |
| 598 else if (focus_render_view && render_view_host_->view()) | 599 else if (focus_render_view && render_view_host_->view()) |
| 599 render_view_host_->view()->Focus(); | 600 render_view_host_->view()->Focus(); |
| 600 | 601 |
| 601 RenderViewHostSwitchedDetails details; | 602 RenderViewHostSwitchedDetails details; |
| 602 details.new_host = render_view_host_; | 603 details.new_host = render_view_host_; |
| 603 details.old_host = old_render_view_host; | 604 details.old_host = old_render_view_host; |
| 604 content::NotificationService::current()->Notify( | 605 content::NotificationService::current()->Notify( |
| 605 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, | 606 content::NOTIFICATION_RENDER_VIEW_HOST_CHANGED, |
| 606 content::Source<content::NavigationController>( | 607 content::Source<NavigationController>( |
| 607 &delegate_->GetControllerForRenderManager()), | 608 &delegate_->GetControllerForRenderManager()), |
| 608 content::Details<RenderViewHostSwitchedDetails>(&details)); | 609 content::Details<RenderViewHostSwitchedDetails>(&details)); |
| 609 | 610 |
| 610 // If the pending view was on the swapped out list, we can remove it. | 611 // If the pending view was on the swapped out list, we can remove it. |
| 611 swapped_out_hosts_.erase(render_view_host_->site_instance()->id()); | 612 swapped_out_hosts_.erase(render_view_host_->site_instance()->id()); |
| 612 | 613 |
| 613 // If the old RVH is live, we are swapping it out and should keep track of it | 614 // If the old RVH is live, we are swapping it out and should keep track of it |
| 614 // in case we navigate back to it. | 615 // in case we navigate back to it. |
| 615 if (old_render_view_host->IsRenderViewLive()) { | 616 if (old_render_view_host->IsRenderViewLive()) { |
| 616 DCHECK(old_render_view_host->is_swapped_out()); | 617 DCHECK(old_render_view_host->is_swapped_out()); |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 } | 807 } |
| 807 } | 808 } |
| 808 | 809 |
| 809 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { | 810 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { |
| 810 if (!rvh->site_instance()) | 811 if (!rvh->site_instance()) |
| 811 return false; | 812 return false; |
| 812 | 813 |
| 813 return swapped_out_hosts_.find(rvh->site_instance()->id()) != | 814 return swapped_out_hosts_.find(rvh->site_instance()->id()) != |
| 814 swapped_out_hosts_.end(); | 815 swapped_out_hosts_.end(); |
| 815 } | 816 } |
| OLD | NEW |