Chromium Code Reviews| 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.h" | 9 #include "content/browser/debugger/devtools_manager.h" |
| 10 #include "content/browser/renderer_host/render_view_host.h" | 10 #include "content/browser/renderer_host/render_view_host.h" |
| (...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 693 // handlers if the current RVH isn't live.) | 693 // handlers if the current RVH isn't live.) |
| 694 CommitPending(); | 694 CommitPending(); |
| 695 return render_view_host_; | 695 return render_view_host_; |
| 696 } else { | 696 } else { |
| 697 NOTREACHED(); | 697 NOTREACHED(); |
| 698 return render_view_host_; | 698 return render_view_host_; |
| 699 } | 699 } |
| 700 } | 700 } |
| 701 // Otherwise, it's safe to treat this as a pending cross-site transition. | 701 // Otherwise, it's safe to treat this as a pending cross-site transition. |
| 702 | 702 |
| 703 // Make sure the old render view stops, in case a load is in progress. | |
| 704 render_view_host_->Send(new ViewMsg_Stop(render_view_host_->routing_id())); | |
| 705 | 703 |
| 706 // Suspend the new render view (i.e., don't let it send the cross-site | 704 if (!render_view_host_->is_swapped_out()) { |
|
Charlie Reis
2011/11/18 18:00:13
I'm torn between this approach and having RenderVi
battre
2011/11/21 17:11:57
I did not quite understand whether you prefer shor
| |
| 707 // Navigate message) until we hear back from the old renderer's | 705 // Make sure the old render view stops, in case a load is in progress. |
| 708 // onbeforeunload handler. If the handler returns false, we'll have to | 706 render_view_host_->Send( |
| 709 // cancel the request. | 707 new ViewMsg_Stop(render_view_host_->routing_id())); |
| 710 DCHECK(!pending_render_view_host_->are_navigations_suspended()); | |
| 711 pending_render_view_host_->SetNavigationsSuspended(true); | |
| 712 | 708 |
| 713 // Tell the CrossSiteRequestManager that this RVH has a pending cross-site | 709 // Suspend the new render view (i.e., don't let it send the cross-site |
| 714 // request, so that ResourceDispatcherHost will know to tell us to run the | 710 // Navigate message) until we hear back from the old renderer's |
| 715 // old page's onunload handler before it sends the response. | 711 // onbeforeunload handler. If the handler returns false, we'll have to |
| 716 pending_render_view_host_->SetHasPendingCrossSiteRequest(true, -1); | 712 // cancel the request. |
| 713 DCHECK(!pending_render_view_host_->are_navigations_suspended()); | |
| 714 pending_render_view_host_->SetNavigationsSuspended(true); | |
| 717 | 715 |
| 718 // We now have a pending RVH. | 716 // Tell the CrossSiteRequestManager that this RVH has a pending cross-site |
| 719 DCHECK(!cross_navigation_pending_); | 717 // request, so that ResourceDispatcherHost will know to tell us to run the |
| 720 cross_navigation_pending_ = true; | 718 // old page's onunload handler before it sends the response. |
| 719 pending_render_view_host_->SetHasPendingCrossSiteRequest(true, -1); | |
| 721 | 720 |
| 722 // Tell the old render view to run its onbeforeunload handler, since it | 721 // We now have a pending RVH. |
| 723 // doesn't otherwise know that the cross-site request is happening. This | 722 DCHECK(!cross_navigation_pending_); |
| 724 // will trigger a call to ShouldClosePage with the reply. | 723 cross_navigation_pending_ = true; |
| 725 render_view_host_->FirePageBeforeUnload(true); | 724 |
| 725 // Tell the old render view to run its onbeforeunload handler, since it | |
| 726 // doesn't otherwise know that the cross-site request is happening. This | |
| 727 // will trigger a call to ShouldClosePage with the reply. | |
| 728 render_view_host_->FirePageBeforeUnload(true); | |
| 729 } else { | |
| 730 // We now have a pending RVH. | |
| 731 DCHECK(!cross_navigation_pending_); | |
| 732 cross_navigation_pending_ = true; | |
| 733 } | |
| 726 | 734 |
| 727 return pending_render_view_host_; | 735 return pending_render_view_host_; |
| 728 } else { | 736 } else { |
| 729 if (pending_web_ui_.get() && render_view_host_->IsRenderViewLive()) | 737 if (pending_web_ui_.get() && render_view_host_->IsRenderViewLive()) |
| 730 pending_web_ui_->RenderViewReused(render_view_host_); | 738 pending_web_ui_->RenderViewReused(render_view_host_); |
| 731 | 739 |
| 732 // The renderer can exit view source mode when any error or cancellation | 740 // The renderer can exit view source mode when any error or cancellation |
| 733 // happen. We must overwrite to recover the mode. | 741 // happen. We must overwrite to recover the mode. |
| 734 if (entry.IsViewSourceMode()) { | 742 if (entry.IsViewSourceMode()) { |
| 735 render_view_host_->Send( | 743 render_view_host_->Send( |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 803 } | 811 } |
| 804 } | 812 } |
| 805 | 813 |
| 806 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { | 814 bool RenderViewHostManager::IsSwappedOut(RenderViewHost* rvh) { |
| 807 if (!rvh->site_instance()) | 815 if (!rvh->site_instance()) |
| 808 return false; | 816 return false; |
| 809 | 817 |
| 810 return swapped_out_hosts_.find(rvh->site_instance()->id()) != | 818 return swapped_out_hosts_.find(rvh->site_instance()->id()) != |
| 811 swapped_out_hosts_.end(); | 819 swapped_out_hosts_.end(); |
| 812 } | 820 } |
| OLD | NEW |