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 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
784 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); | 784 base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); |
785 bool proceed = render_view_->webview()->dispatchBeforeUnloadEvent(); | 785 bool proceed = render_view_->webview()->dispatchBeforeUnloadEvent(); |
786 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); | 786 base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); |
787 Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed, | 787 Send(new FrameHostMsg_BeforeUnload_ACK(routing_id_, proceed, |
788 before_unload_start_time, | 788 before_unload_start_time, |
789 before_unload_end_time)); | 789 before_unload_end_time)); |
790 } | 790 } |
791 | 791 |
792 void RenderFrameImpl::OnSwapOut() { | 792 void RenderFrameImpl::OnSwapOut() { |
793 // Only run unload if we're not swapped out yet, but send the ack either way. | 793 // Only run unload if we're not swapped out yet, but send the ack either way. |
794 if (!is_swapped_out_) { | 794 if (!is_swapped_out_ || !render_view_->is_swapped_out_) { |
795 // Swap this RenderView out so the tab can navigate to a page rendered by a | 795 // Swap this RenderFrame out so the frame can navigate to a page rendered by |
796 // different process. This involves running the unload handler and clearing | 796 // a different process. This involves running the unload handler and |
797 // the page. Once WasSwappedOut is called, we also allow this process to | 797 // clearing the page. Once WasSwappedOut is called, we also allow this |
798 // exit if there are no other active RenderViews in it. | 798 // process to exit if there are no other active RenderFrames in it. |
799 | 799 |
800 // Send an UpdateState message before we get swapped out. | 800 // Send an UpdateState message before we get swapped out. |
801 render_view_->SyncNavigationState(); | 801 render_view_->SyncNavigationState(); |
802 | 802 |
803 // Synchronously run the unload handler before sending the ACK. | 803 // Synchronously run the unload handler before sending the ACK. |
804 // TODO(creis): Add a WebFrame::dispatchUnloadEvent and call it here. | 804 // TODO(creis): Add a WebFrame::dispatchUnloadEvent and call it here to |
805 // support unload on subframes as well. | |
nasko
2014/03/25 18:15:18
nit: The comment seems to imply that we will be ad
Charlie Reis
2014/03/28 15:55:18
Yes, that's more accurate. Done.
| |
806 if (!frame_->parent()) | |
807 render_view_->webview()->dispatchUnloadEvent(); | |
805 | 808 |
806 // Swap out and stop sending any IPC messages that are not ACKs. | 809 // Swap out and stop sending any IPC messages that are not ACKs. |
810 if (!frame_->parent()) | |
811 render_view_->SetSwappedOut(true); | |
807 is_swapped_out_ = true; | 812 is_swapped_out_ = true; |
808 | 813 |
809 // Now that we're swapped out and filtering IPC messages, stop loading to | 814 // Now that we're swapped out and filtering IPC messages, stop loading to |
810 // ensure that no other in-progress navigation continues. We do this here | 815 // ensure that no other in-progress navigation continues. We do this here |
811 // to avoid sending a DidStopLoading message to the browser process. | 816 // to avoid sending a DidStopLoading message to the browser process. |
812 // TODO(creis): Should we be stopping all frames here and using | 817 // TODO(creis): Should we be stopping all frames here and using |
813 // StopAltErrorPageFetcher with RenderView::OnStop, or just stopping this | 818 // StopAltErrorPageFetcher with RenderView::OnStop, or just stopping this |
814 // frame? | 819 // frame? |
815 frame_->stopLoading(); | 820 if (!frame_->parent()) |
821 render_view_->OnStop(); | |
822 else | |
823 frame_->stopLoading(); | |
816 | 824 |
817 frame_->setIsRemote(true); | 825 // Let subframes know that the frame is now rendered remotely, for the |
826 // purposes of compositing and input events. | |
827 if (frame_->parent()) | |
828 frame_->setIsRemote(true); | |
818 | 829 |
819 // Replace the page with a blank dummy URL. The unload handler will not be | 830 // Replace the page with a blank dummy URL. The unload handler will not be |
820 // run a second time, thanks to a check in FrameLoader::stopLoading. | 831 // run a second time, thanks to a check in FrameLoader::stopLoading. |
821 // TODO(creis): Need to add a better way to do this that avoids running the | 832 // TODO(creis): Need to add a better way to do this that avoids running the |
822 // beforeunload handler. For now, we just run it a second time silently. | 833 // beforeunload handler. For now, we just run it a second time silently. |
823 render_view_->NavigateToSwappedOutURL(frame_); | 834 render_view_->NavigateToSwappedOutURL(frame_); |
824 | 835 |
825 render_view_->RegisterSwappedOutChildFrame(this); | 836 if (frame_->parent()) |
837 render_view_->RegisterSwappedOutChildFrame(this); | |
838 | |
839 // Let WebKit know that this view is hidden so it can drop resources and | |
840 // stop compositing. | |
841 // TODO(creis): Support this for subframes as well. | |
842 if (!frame_->parent()) { | |
843 render_view_->webview()->setVisibilityState( | |
844 blink::WebPageVisibilityStateHidden, false); | |
845 } | |
826 } | 846 } |
827 | 847 |
848 // It is now safe to show modal dialogs again. | |
849 // TODO(creis): Deal with modal dialogs from subframes. | |
850 if (!frame_->parent()) | |
851 render_view_->suppress_dialogs_until_swap_out_ = false; | |
852 | |
828 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); | 853 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); |
829 } | 854 } |
830 | 855 |
831 void RenderFrameImpl::OnBuffersSwapped( | 856 void RenderFrameImpl::OnBuffersSwapped( |
832 const FrameMsg_BuffersSwapped_Params& params) { | 857 const FrameMsg_BuffersSwapped_Params& params) { |
833 if (!compositing_helper_.get()) { | 858 if (!compositing_helper_.get()) { |
834 compositing_helper_ = | 859 compositing_helper_ = |
835 ChildFrameCompositingHelper::CreateCompositingHelperForRenderFrame( | 860 ChildFrameCompositingHelper::CreateCompositingHelperForRenderFrame( |
836 frame_, this, routing_id_); | 861 frame_, this, routing_id_); |
837 compositing_helper_->EnableCompositing(true); | 862 compositing_helper_->EnableCompositing(true); |
(...skipping 2069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2907 selection_text_offset_ = offset; | 2932 selection_text_offset_ = offset; |
2908 selection_range_ = range; | 2933 selection_range_ = range; |
2909 // This IPC is dispatched by RenderWidetHost, so use its routing ID. | 2934 // This IPC is dispatched by RenderWidetHost, so use its routing ID. |
2910 Send(new ViewHostMsg_SelectionChanged( | 2935 Send(new ViewHostMsg_SelectionChanged( |
2911 GetRenderWidget()->routing_id(), text, offset, range)); | 2936 GetRenderWidget()->routing_id(), text, offset, range)); |
2912 } | 2937 } |
2913 GetRenderWidget()->UpdateSelectionBounds(); | 2938 GetRenderWidget()->UpdateSelectionBounds(); |
2914 } | 2939 } |
2915 | 2940 |
2916 } // namespace content | 2941 } // namespace content |
OLD | NEW |