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/browser/frame_host/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 IPC_MESSAGE_HANDLER(FrameHostMsg_FrameFocused, OnFrameFocused) | 339 IPC_MESSAGE_HANDLER(FrameHostMsg_FrameFocused, OnFrameFocused) |
340 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStartProvisionalLoadForFrame, | 340 IPC_MESSAGE_HANDLER(FrameHostMsg_DidStartProvisionalLoadForFrame, |
341 OnDidStartProvisionalLoadForFrame) | 341 OnDidStartProvisionalLoadForFrame) |
342 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailProvisionalLoadWithError, | 342 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailProvisionalLoadWithError, |
343 OnDidFailProvisionalLoadWithError) | 343 OnDidFailProvisionalLoadWithError) |
344 IPC_MESSAGE_HANDLER(FrameHostMsg_DidRedirectProvisionalLoad, | 344 IPC_MESSAGE_HANDLER(FrameHostMsg_DidRedirectProvisionalLoad, |
345 OnDidRedirectProvisionalLoad) | 345 OnDidRedirectProvisionalLoad) |
346 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailLoadWithError, | 346 IPC_MESSAGE_HANDLER(FrameHostMsg_DidFailLoadWithError, |
347 OnDidFailLoadWithError) | 347 OnDidFailLoadWithError) |
348 IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad, | 348 IPC_MESSAGE_HANDLER_GENERIC(FrameHostMsg_DidCommitProvisionalLoad, |
349 OnNavigate(msg)) | 349 OnDidCommitProvisionalLoad(msg)) |
350 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL) | 350 IPC_MESSAGE_HANDLER(FrameHostMsg_OpenURL, OnOpenURL) |
351 IPC_MESSAGE_HANDLER(FrameHostMsg_DocumentOnLoadCompleted, | 351 IPC_MESSAGE_HANDLER(FrameHostMsg_DocumentOnLoadCompleted, |
352 OnDocumentOnLoadCompleted) | 352 OnDocumentOnLoadCompleted) |
353 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnload_ACK, OnBeforeUnloadACK) | 353 IPC_MESSAGE_HANDLER(FrameHostMsg_BeforeUnload_ACK, OnBeforeUnloadACK) |
354 IPC_MESSAGE_HANDLER(FrameHostMsg_SwapOut_ACK, OnSwapOutACK) | 354 IPC_MESSAGE_HANDLER(FrameHostMsg_SwapOut_ACK, OnSwapOutACK) |
355 IPC_MESSAGE_HANDLER(FrameHostMsg_ContextMenu, OnContextMenu) | 355 IPC_MESSAGE_HANDLER(FrameHostMsg_ContextMenu, OnContextMenu) |
356 IPC_MESSAGE_HANDLER(FrameHostMsg_JavaScriptExecuteResponse, | 356 IPC_MESSAGE_HANDLER(FrameHostMsg_JavaScriptExecuteResponse, |
357 OnJavaScriptExecuteResponse) | 357 OnJavaScriptExecuteResponse) |
358 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunJavaScriptMessage, | 358 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunJavaScriptMessage, |
359 OnRunJavaScriptMessage) | 359 OnRunJavaScriptMessage) |
360 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunBeforeUnloadConfirm, | 360 IPC_MESSAGE_HANDLER_DELAY_REPLY(FrameHostMsg_RunBeforeUnloadConfirm, |
361 OnRunBeforeUnloadConfirm) | 361 OnRunBeforeUnloadConfirm) |
362 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAccessInitialDocument, | 362 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAccessInitialDocument, |
363 OnDidAccessInitialDocument) | 363 OnDidAccessInitialDocument) |
364 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisownOpener, OnDidDisownOpener) | 364 IPC_MESSAGE_HANDLER(FrameHostMsg_DidDisownOpener, OnDidDisownOpener) |
| 365 IPC_MESSAGE_HANDLER(FrameHostMsg_DidAssignPageId, OnDidAssignPageId) |
365 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateTitle, OnUpdateTitle) | 366 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateTitle, OnUpdateTitle) |
366 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateEncoding, OnUpdateEncoding) | 367 IPC_MESSAGE_HANDLER(FrameHostMsg_UpdateEncoding, OnUpdateEncoding) |
367 IPC_MESSAGE_HANDLER(FrameHostMsg_BeginNavigation, | 368 IPC_MESSAGE_HANDLER(FrameHostMsg_BeginNavigation, |
368 OnBeginNavigation) | 369 OnBeginNavigation) |
369 IPC_MESSAGE_HANDLER(PlatformNotificationHostMsg_RequestPermission, | 370 IPC_MESSAGE_HANDLER(PlatformNotificationHostMsg_RequestPermission, |
370 OnRequestPlatformNotificationPermission) | 371 OnRequestPlatformNotificationPermission) |
371 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show, | 372 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Show, |
372 OnShowDesktopNotification) | 373 OnShowDesktopNotification) |
373 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel, | 374 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel, |
374 OnCancelDesktopNotification) | 375 OnCancelDesktopNotification) |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 } | 582 } |
582 | 583 |
583 // Called when the renderer navigates. For every frame loaded, we'll get this | 584 // Called when the renderer navigates. For every frame loaded, we'll get this |
584 // notification containing parameters identifying the navigation. | 585 // notification containing parameters identifying the navigation. |
585 // | 586 // |
586 // Subframes are identified by the page transition type. For subframes loaded | 587 // Subframes are identified by the page transition type. For subframes loaded |
587 // as part of a wider page load, the page_id will be the same as for the top | 588 // as part of a wider page load, the page_id will be the same as for the top |
588 // level frame. If the user explicitly requests a subframe navigation, we will | 589 // level frame. If the user explicitly requests a subframe navigation, we will |
589 // get a new page_id because we need to create a new navigation entry for that | 590 // get a new page_id because we need to create a new navigation entry for that |
590 // action. | 591 // action. |
591 void RenderFrameHostImpl::OnNavigate(const IPC::Message& msg) { | 592 void RenderFrameHostImpl::OnDidCommitProvisionalLoad(const IPC::Message& msg) { |
592 // Read the parameters out of the IPC message directly to avoid making another | 593 // Read the parameters out of the IPC message directly to avoid making another |
593 // copy when we filter the URLs. | 594 // copy when we filter the URLs. |
594 PickleIterator iter(msg); | 595 PickleIterator iter(msg); |
595 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params; | 596 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params; |
596 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>:: | 597 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>:: |
597 Read(&msg, &iter, &validated_params)) | 598 Read(&msg, &iter, &validated_params)) |
598 return; | 599 return; |
599 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OnNavigate", | 600 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OnDidCommitProvisionalLoad", |
600 "url", validated_params.url.possibly_invalid_spec()); | 601 "url", validated_params.url.possibly_invalid_spec()); |
601 | 602 |
602 // If we're waiting for a cross-site beforeunload ack from this renderer and | 603 // If we're waiting for a cross-site beforeunload ack from this renderer and |
603 // we receive a Navigate message from the main frame, then the renderer was | 604 // we receive a Navigate message from the main frame, then the renderer was |
604 // navigating already and sent it before hearing the FrameMsg_Stop message. | 605 // navigating already and sent it before hearing the FrameMsg_Stop message. |
605 // We do not want to cancel the pending navigation in this case, since the | 606 // We do not want to cancel the pending navigation in this case, since the |
606 // old page will soon be stopped. Instead, treat this as a beforeunload ack | 607 // old page will soon be stopped. Instead, treat this as a beforeunload ack |
607 // to allow the pending navigation to continue. | 608 // to allow the pending navigation to continue. |
608 if (render_view_host_->is_waiting_for_beforeunload_ack_ && | 609 if (render_view_host_->is_waiting_for_beforeunload_ack_ && |
609 render_view_host_->unload_ack_is_for_cross_site_transition_ && | 610 render_view_host_->unload_ack_is_for_cross_site_transition_ && |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
738 render_view_host_->is_waiting_for_beforeunload_ack_ = false; | 739 render_view_host_->is_waiting_for_beforeunload_ack_ = false; |
739 frame_tree_node_->render_manager()->OnBeforeUnloadACK( | 740 frame_tree_node_->render_manager()->OnBeforeUnloadACK( |
740 render_view_host_->unload_ack_is_for_cross_site_transition_, proceed, | 741 render_view_host_->unload_ack_is_for_cross_site_transition_, proceed, |
741 renderer_before_unload_end_time); | 742 renderer_before_unload_end_time); |
742 return; | 743 return; |
743 } | 744 } |
744 | 745 |
745 render_view_host_->decrement_in_flight_event_count(); | 746 render_view_host_->decrement_in_flight_event_count(); |
746 render_view_host_->StopHangMonitorTimeout(); | 747 render_view_host_->StopHangMonitorTimeout(); |
747 // If this renderer navigated while the beforeunload request was in flight, we | 748 // If this renderer navigated while the beforeunload request was in flight, we |
748 // may have cleared this state in OnNavigate, in which case we can ignore | 749 // may have cleared this state in OnDidCommitProvisionalLoad, in which case we |
749 // this message. | 750 // can ignore this message. |
750 // However renderer might also be swapped out but we still want to proceed | 751 // However renderer might also be swapped out but we still want to proceed |
751 // with navigation, otherwise it would block future navigations. This can | 752 // with navigation, otherwise it would block future navigations. This can |
752 // happen when pending cross-site navigation is canceled by a second one just | 753 // happen when pending cross-site navigation is canceled by a second one just |
753 // before OnNavigate while current RVH is waiting for commit but second | 754 // before OnDidCommitProvisionalLoad while current RVH is waiting for commit |
754 // navigation is started from the beginning. | 755 // but second navigation is started from the beginning. |
755 if (!render_view_host_->is_waiting_for_beforeunload_ack_) { | 756 if (!render_view_host_->is_waiting_for_beforeunload_ack_) { |
756 return; | 757 return; |
757 } | 758 } |
758 | 759 |
759 render_view_host_->is_waiting_for_beforeunload_ack_ = false; | 760 render_view_host_->is_waiting_for_beforeunload_ack_ = false; |
760 | 761 |
761 base::TimeTicks before_unload_end_time; | 762 base::TimeTicks before_unload_end_time; |
762 if (!send_before_unload_start_time_.is_null() && | 763 if (!send_before_unload_start_time_.is_null() && |
763 !renderer_before_unload_start_time.is_null() && | 764 !renderer_before_unload_start_time.is_null() && |
764 !renderer_before_unload_end_time.is_null()) { | 765 !renderer_before_unload_end_time.is_null()) { |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
921 void RenderFrameHostImpl::OnDidAccessInitialDocument() { | 922 void RenderFrameHostImpl::OnDidAccessInitialDocument() { |
922 delegate_->DidAccessInitialDocument(); | 923 delegate_->DidAccessInitialDocument(); |
923 } | 924 } |
924 | 925 |
925 void RenderFrameHostImpl::OnDidDisownOpener() { | 926 void RenderFrameHostImpl::OnDidDisownOpener() { |
926 // This message is only sent for top-level frames. TODO(avi): when frame tree | 927 // This message is only sent for top-level frames. TODO(avi): when frame tree |
927 // mirroring works correctly, add a check here to enforce it. | 928 // mirroring works correctly, add a check here to enforce it. |
928 delegate_->DidDisownOpener(this); | 929 delegate_->DidDisownOpener(this); |
929 } | 930 } |
930 | 931 |
| 932 void RenderFrameHostImpl::OnDidAssignPageId(int32 page_id) { |
| 933 // Update the RVH's current page ID so that future IPCs from the renderer |
| 934 // correspond to the new page. |
| 935 render_view_host_->page_id_ = page_id; |
| 936 } |
| 937 |
931 void RenderFrameHostImpl::OnUpdateTitle( | 938 void RenderFrameHostImpl::OnUpdateTitle( |
932 int32 page_id, | 939 int32 page_id, |
933 const base::string16& title, | 940 const base::string16& title, |
934 blink::WebTextDirection title_direction) { | 941 blink::WebTextDirection title_direction) { |
935 // This message is only sent for top-level frames. TODO(avi): when frame tree | 942 // This message is only sent for top-level frames. TODO(avi): when frame tree |
936 // mirroring works correctly, add a check here to enforce it. | 943 // mirroring works correctly, add a check here to enforce it. |
937 if (title.length() > kMaxTitleChars) { | 944 if (title.length() > kMaxTitleChars) { |
938 NOTREACHED() << "Renderer sent too many characters in title."; | 945 NOTREACHED() << "Renderer sent too many characters in title."; |
939 return; | 946 return; |
940 } | 947 } |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 // Clear any state if a pending navigation is canceled or preempted. | 1343 // Clear any state if a pending navigation is canceled or preempted. |
1337 if (suspended_nav_params_) | 1344 if (suspended_nav_params_) |
1338 suspended_nav_params_.reset(); | 1345 suspended_nav_params_.reset(); |
1339 | 1346 |
1340 TRACE_EVENT_ASYNC_END0("navigation", | 1347 TRACE_EVENT_ASYNC_END0("navigation", |
1341 "RenderFrameHostImpl navigation suspended", this); | 1348 "RenderFrameHostImpl navigation suspended", this); |
1342 navigations_suspended_ = false; | 1349 navigations_suspended_ = false; |
1343 } | 1350 } |
1344 | 1351 |
1345 } // namespace content | 1352 } // namespace content |
OLD | NEW |