OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/renderer/render_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); | 762 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); |
763 bool proceed = render_view_->webview()->dispatchBeforeUnloadEvent(); | 763 bool proceed = render_view_->webview()->dispatchBeforeUnloadEvent(); |
764 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); | 764 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); |
765 Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed, | 765 Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed, |
766 before_unload_start_time, | 766 before_unload_start_time, |
767 before_unload_end_time)); | 767 before_unload_end_time)); |
768 } | 768 } |
769 | 769 |
770 void RenderFrameImpl::OnSwapOut() { | 770 void RenderFrameImpl::OnSwapOut() { |
771 // Only run unload if we're not swapped out yet, but send the ack either way. | 771 // Only run unload if we're not swapped out yet, but send the ack either way. |
772 if (!is_swapped_out_) { | 772 if (!is_swapped_out_ || !render_view_->is_swapped_out_) { |
773 // Swap this RenderView out so the tab can navigate to a page rendered by a | 773 // Swap this RenderFrame out so the frame can navigate to a page rendered by |
774 // different process. This involves running the unload handler and clearing | 774 // a different process. This involves running the unload handler and |
775 // the page. Once WasSwappedOut is called, we also allow this process to | 775 // clearing the page. Once WasSwappedOut is called, we also allow this |
776 // exit if there are no other active RenderViews in it. | 776 // process to exit if there are no other active RenderFrames in it. |
777 | 777 |
778 // Send an UpdateState message before we get swapped out. | 778 // Send an UpdateState message before we get swapped out. |
779 render_view_->SyncNavigationState(); | 779 render_view_->SyncNavigationState(); |
780 | 780 |
781 // Synchronously run the unload handler before sending the ACK. | 781 // Synchronously run the unload handler before sending the ACK. |
782 // TODO(creis): Add a WebFrame::dispatchUnloadEvent and call it here. | 782 // TODO(creis): Add a WebFrame::dispatchUnloadEvent and call it here to |
| 783 // support unload on subframes as well. |
| 784 if (!frame_->parent()) |
| 785 render_view_->webview()->dispatchUnloadEvent(); |
783 | 786 |
784 // Swap out and stop sending any IPC messages that are not ACKs. | 787 // Swap out and stop sending any IPC messages that are not ACKs. |
| 788 if (!frame_->parent()) |
| 789 render_view_->SetSwappedOut(true); |
785 is_swapped_out_ = true; | 790 is_swapped_out_ = true; |
786 | 791 |
787 // Now that we're swapped out and filtering IPC messages, stop loading to | 792 // Now that we're swapped out and filtering IPC messages, stop loading to |
788 // ensure that no other in-progress navigation continues. We do this here | 793 // ensure that no other in-progress navigation continues. We do this here |
789 // to avoid sending a DidStopLoading message to the browser process. | 794 // to avoid sending a DidStopLoading message to the browser process. |
790 // TODO(creis): Should we be stopping all frames here and using | 795 // TODO(creis): Should we be stopping all frames here and using |
791 // StopAltErrorPageFetcher with RenderView::OnStop, or just stopping this | 796 // StopAltErrorPageFetcher with RenderView::OnStop, or just stopping this |
792 // frame? | 797 // frame? |
793 frame_->stopLoading(); | 798 if (!frame_->parent()) |
| 799 render_view_->OnStop(); |
| 800 else |
| 801 frame_->stopLoading(); |
794 | 802 |
795 frame_->setIsRemote(true); | 803 // Let subframes know that the frame is now rendered remotely, for the |
| 804 // purposes of compositing and input events. |
| 805 if (frame_->parent()) |
| 806 frame_->setIsRemote(true); |
796 | 807 |
797 // Replace the page with a blank dummy URL. The unload handler will not be | 808 // Replace the page with a blank dummy URL. The unload handler will not be |
798 // run a second time, thanks to a check in FrameLoader::stopLoading. | 809 // run a second time, thanks to a check in FrameLoader::stopLoading. |
799 // TODO(creis): Need to add a better way to do this that avoids running the | 810 // TODO(creis): Need to add a better way to do this that avoids running the |
800 // beforeunload handler. For now, we just run it a second time silently. | 811 // beforeunload handler. For now, we just run it a second time silently. |
801 render_view_->NavigateToSwappedOutURL(frame_); | 812 render_view_->NavigateToSwappedOutURL(frame_); |
802 | 813 |
803 render_view_->RegisterSwappedOutChildFrame(this); | 814 if (frame_->parent()) |
| 815 render_view_->RegisterSwappedOutChildFrame(this); |
| 816 |
| 817 // Let WebKit know that this view is hidden so it can drop resources and |
| 818 // stop compositing. |
| 819 // TODO(creis): Support this for subframes as well. |
| 820 if (!frame_->parent()) { |
| 821 render_view_->webview()->setVisibilityState( |
| 822 blink::WebPageVisibilityStateHidden, false); |
| 823 } |
804 } | 824 } |
805 | 825 |
| 826 // It is now safe to show modal dialogs again. |
| 827 // TODO(creis): Deal with modal dialogs from subframes. |
| 828 if (!frame_->parent()) |
| 829 render_view_->suppress_dialogs_until_swap_out_ = false; |
| 830 |
806 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); | 831 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); |
807 } | 832 } |
808 | 833 |
809 void RenderFrameImpl::OnBuffersSwapped( | 834 void RenderFrameImpl::OnBuffersSwapped( |
810 const FrameMsg_BuffersSwapped_Params& params) { | 835 const FrameMsg_BuffersSwapped_Params& params) { |
811 if (!compositing_helper_.get()) { | 836 if (!compositing_helper_.get()) { |
812 compositing_helper_ = | 837 compositing_helper_ = |
813 ChildFrameCompositingHelper::CreateCompositingHelperForRenderFrame( | 838 ChildFrameCompositingHelper::CreateCompositingHelperForRenderFrame( |
814 frame_, this, routing_id_); | 839 frame_, this, routing_id_); |
815 compositing_helper_->EnableCompositing(true); | 840 compositing_helper_->EnableCompositing(true); |
(...skipping 1935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2751 } | 2776 } |
2752 | 2777 |
2753 Send(new FrameHostMsg_OpenURL(routing_id_, params)); | 2778 Send(new FrameHostMsg_OpenURL(routing_id_, params)); |
2754 } | 2779 } |
2755 | 2780 |
2756 void RenderFrameImpl::didChangeLoadProgress(double load_progress) { | 2781 void RenderFrameImpl::didChangeLoadProgress(double load_progress) { |
2757 render_view_->didChangeLoadProgress(frame_, load_progress); | 2782 render_view_->didChangeLoadProgress(frame_, load_progress); |
2758 } | 2783 } |
2759 | 2784 |
2760 } // namespace content | 2785 } // namespace content |
OLD | NEW |