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 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
457 gfx::NativeViewAccessible | 457 gfx::NativeViewAccessible |
458 RenderFrameHostImpl::AccessibilityGetNativeViewAccessible() { | 458 RenderFrameHostImpl::AccessibilityGetNativeViewAccessible() { |
459 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( | 459 RenderWidgetHostViewBase* view = static_cast<RenderWidgetHostViewBase*>( |
460 render_view_host_->GetView()); | 460 render_view_host_->GetView()); |
461 if (view) | 461 if (view) |
462 return view->AccessibilityGetNativeViewAccessible(); | 462 return view->AccessibilityGetNativeViewAccessible(); |
463 return NULL; | 463 return NULL; |
464 } | 464 } |
465 | 465 |
466 bool RenderFrameHostImpl::CreateRenderFrame(int parent_routing_id) { | 466 bool RenderFrameHostImpl::CreateRenderFrame(int parent_routing_id) { |
467 TRACE_EVENT0("frame_host", "RenderFrameHostImpl::CreateRenderFrame"); | 467 TRACE_EVENT0("navigation", "RenderFrameHostImpl::CreateRenderFrame"); |
468 DCHECK(!IsRenderFrameLive()) << "Creating frame twice"; | 468 DCHECK(!IsRenderFrameLive()) << "Creating frame twice"; |
469 | 469 |
470 // The process may (if we're sharing a process with another host that already | 470 // The process may (if we're sharing a process with another host that already |
471 // initialized it) or may not (we have our own process or the old process | 471 // initialized it) or may not (we have our own process or the old process |
472 // crashed) have been initialized. Calling Init multiple times will be | 472 // crashed) have been initialized. Calling Init multiple times will be |
473 // ignored, so this is safe. | 473 // ignored, so this is safe. |
474 if (!GetProcess()->Init()) | 474 if (!GetProcess()->Init()) |
475 return false; | 475 return false; |
476 | 476 |
477 DCHECK(GetProcess()->HasConnection()); | 477 DCHECK(GetProcess()->HasConnection()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
522 | 522 |
523 void RenderFrameHostImpl::OnFrameFocused() { | 523 void RenderFrameHostImpl::OnFrameFocused() { |
524 frame_tree_->SetFocusedFrame(frame_tree_node_); | 524 frame_tree_->SetFocusedFrame(frame_tree_node_); |
525 } | 525 } |
526 | 526 |
527 void RenderFrameHostImpl::OnOpenURL( | 527 void RenderFrameHostImpl::OnOpenURL( |
528 const FrameHostMsg_OpenURL_Params& params) { | 528 const FrameHostMsg_OpenURL_Params& params) { |
529 GURL validated_url(params.url); | 529 GURL validated_url(params.url); |
530 GetProcess()->FilterURL(false, &validated_url); | 530 GetProcess()->FilterURL(false, &validated_url); |
531 | 531 |
532 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OnOpenURL", | |
533 "url", validated_url.possibly_invalid_spec()); | |
532 frame_tree_node_->navigator()->RequestOpenURL( | 534 frame_tree_node_->navigator()->RequestOpenURL( |
533 this, validated_url, params.referrer, params.disposition, | 535 this, validated_url, params.referrer, params.disposition, |
534 params.should_replace_current_entry, params.user_gesture); | 536 params.should_replace_current_entry, params.user_gesture); |
535 } | 537 } |
536 | 538 |
537 void RenderFrameHostImpl::OnDocumentOnLoadCompleted() { | 539 void RenderFrameHostImpl::OnDocumentOnLoadCompleted() { |
538 // This message is only sent for top-level frames. TODO(avi): when frame tree | 540 // This message is only sent for top-level frames. TODO(avi): when frame tree |
539 // mirroring works correctly, add a check here to enforce it. | 541 // mirroring works correctly, add a check here to enforce it. |
540 delegate_->DocumentOnLoadCompleted(this); | 542 delegate_->DocumentOnLoadCompleted(this); |
541 } | 543 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
580 // get a new page_id because we need to create a new navigation entry for that | 582 // get a new page_id because we need to create a new navigation entry for that |
581 // action. | 583 // action. |
582 void RenderFrameHostImpl::OnNavigate(const IPC::Message& msg) { | 584 void RenderFrameHostImpl::OnNavigate(const IPC::Message& msg) { |
583 // Read the parameters out of the IPC message directly to avoid making another | 585 // Read the parameters out of the IPC message directly to avoid making another |
584 // copy when we filter the URLs. | 586 // copy when we filter the URLs. |
585 PickleIterator iter(msg); | 587 PickleIterator iter(msg); |
586 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params; | 588 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params; |
587 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>:: | 589 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>:: |
588 Read(&msg, &iter, &validated_params)) | 590 Read(&msg, &iter, &validated_params)) |
589 return; | 591 return; |
592 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OnNavigate", | |
593 "url", validated_params.url.possibly_invalid_spec()); | |
590 | 594 |
591 // If we're waiting for a cross-site beforeunload ack from this renderer and | 595 // If we're waiting for a cross-site beforeunload ack from this renderer and |
592 // we receive a Navigate message from the main frame, then the renderer was | 596 // we receive a Navigate message from the main frame, then the renderer was |
593 // navigating already and sent it before hearing the FrameMsg_Stop message. | 597 // navigating already and sent it before hearing the FrameMsg_Stop message. |
594 // We do not want to cancel the pending navigation in this case, since the | 598 // We do not want to cancel the pending navigation in this case, since the |
595 // old page will soon be stopped. Instead, treat this as a beforeunload ack | 599 // old page will soon be stopped. Instead, treat this as a beforeunload ack |
596 // to allow the pending navigation to continue. | 600 // to allow the pending navigation to continue. |
597 if (render_view_host_->is_waiting_for_beforeunload_ack_ && | 601 if (render_view_host_->is_waiting_for_beforeunload_ack_ && |
598 render_view_host_->unload_ack_is_for_cross_site_transition_ && | 602 render_view_host_->unload_ack_is_for_cross_site_transition_ && |
599 PageTransitionIsMainFrame(validated_params.transition)) { | 603 PageTransitionIsMainFrame(validated_params.transition)) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
676 frame_tree_node_->render_manager()->OnDeferredAfterResponseStarted( | 680 frame_tree_node_->render_manager()->OnDeferredAfterResponseStarted( |
677 global_request_id, this); | 681 global_request_id, this); |
678 | 682 |
679 if (GetParent() || !delegate_->WillHandleDeferAfterResponseStarted()) | 683 if (GetParent() || !delegate_->WillHandleDeferAfterResponseStarted()) |
680 frame_tree_node_->render_manager()->ResumeResponseDeferredAtStart(); | 684 frame_tree_node_->render_manager()->ResumeResponseDeferredAtStart(); |
681 else | 685 else |
682 delegate_->DidDeferAfterResponseStarted(transition_data); | 686 delegate_->DidDeferAfterResponseStarted(transition_data); |
683 } | 687 } |
684 | 688 |
685 void RenderFrameHostImpl::SwapOut(RenderFrameProxyHost* proxy) { | 689 void RenderFrameHostImpl::SwapOut(RenderFrameProxyHost* proxy) { |
690 // The end of the trace event is in OnSwapOutACK for when the RenderFrame | |
Charlie Reis
2014/08/27 22:05:12
nit: The end of this
nit: for when -> when
nasko
2014/08/27 23:30:01
Done.
| |
691 // has completed the operation and sends back an IPC message. | |
692 // In the case of timeout on running the unload handler | |
Charlie Reis
2014/08/27 22:05:12
This gets pretty confusing and hard to follow (e.g
nasko
2014/08/27 23:30:01
Sure! Thanks for rewriting it more concisely.
| |
693 // RenderViewHostImpl::OnSwapOut is called. In this case it doesn't know | |
694 // which frame initiated the swap out and if it is for subframe, it won't | |
695 // balance out (this will happen only with --site-per-process). | |
696 // This problem will disappear once swap out state is moved out of | |
697 // RenderViewHost. | |
698 TRACE_EVENT_ASYNC_BEGIN0("navigation", "RenderFrameHostImpl::SwapOut", this); | |
699 | |
686 // TODO(creis): Move swapped out state to RFH. Until then, only update it | 700 // TODO(creis): Move swapped out state to RFH. Until then, only update it |
687 // when swapping out the main frame. | 701 // when swapping out the main frame. |
688 if (!GetParent()) { | 702 if (!GetParent()) { |
689 // If this RenderViewHost is not in the default state, it must have already | 703 // If this RenderViewHost is not in the default state, it must have already |
690 // gone through this, therefore just return. | 704 // gone through this, therefore just return. |
691 if (render_view_host_->rvh_state_ != RenderViewHostImpl::STATE_DEFAULT) | 705 if (render_view_host_->rvh_state_ != RenderViewHostImpl::STATE_DEFAULT) |
692 return; | 706 return; |
693 | 707 |
694 render_view_host_->SetState( | 708 render_view_host_->SetState( |
695 RenderViewHostImpl::STATE_PENDING_SWAP_OUT); | 709 RenderViewHostImpl::STATE_PENDING_SWAP_OUT); |
(...skipping 10 matching lines...) Expand all Loading... | |
706 if (!GetParent()) | 720 if (!GetParent()) |
707 delegate_->SwappedOut(this); | 721 delegate_->SwappedOut(this); |
708 else | 722 else |
709 set_swapped_out(true); | 723 set_swapped_out(true); |
710 } | 724 } |
711 | 725 |
712 void RenderFrameHostImpl::OnBeforeUnloadACK( | 726 void RenderFrameHostImpl::OnBeforeUnloadACK( |
713 bool proceed, | 727 bool proceed, |
714 const base::TimeTicks& renderer_before_unload_start_time, | 728 const base::TimeTicks& renderer_before_unload_start_time, |
715 const base::TimeTicks& renderer_before_unload_end_time) { | 729 const base::TimeTicks& renderer_before_unload_end_time) { |
730 TRACE_EVENT_ASYNC_END0( | |
731 "navigation", "RenderFrameHostImpl::BeforeUnload", this); | |
716 // TODO(creis): Support properly beforeunload on subframes. For now just | 732 // TODO(creis): Support properly beforeunload on subframes. For now just |
717 // pretend that the handler ran and allowed the navigation to proceed. | 733 // pretend that the handler ran and allowed the navigation to proceed. |
718 if (GetParent()) { | 734 if (GetParent()) { |
719 render_view_host_->is_waiting_for_beforeunload_ack_ = false; | 735 render_view_host_->is_waiting_for_beforeunload_ack_ = false; |
720 frame_tree_node_->render_manager()->OnBeforeUnloadACK( | 736 frame_tree_node_->render_manager()->OnBeforeUnloadACK( |
721 render_view_host_->unload_ack_is_for_cross_site_transition_, proceed, | 737 render_view_host_->unload_ack_is_for_cross_site_transition_, proceed, |
722 renderer_before_unload_end_time); | 738 renderer_before_unload_end_time); |
723 return; | 739 return; |
724 } | 740 } |
725 | 741 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
778 render_view_host_->unload_ack_is_for_cross_site_transition_, proceed, | 794 render_view_host_->unload_ack_is_for_cross_site_transition_, proceed, |
779 before_unload_end_time); | 795 before_unload_end_time); |
780 | 796 |
781 // If canceled, notify the delegate to cancel its pending navigation entry. | 797 // If canceled, notify the delegate to cancel its pending navigation entry. |
782 if (!proceed) | 798 if (!proceed) |
783 render_view_host_->GetDelegate()->DidCancelLoading(); | 799 render_view_host_->GetDelegate()->DidCancelLoading(); |
784 } | 800 } |
785 | 801 |
786 void RenderFrameHostImpl::OnSwapOutACK() { | 802 void RenderFrameHostImpl::OnSwapOutACK() { |
787 OnSwappedOut(false); | 803 OnSwappedOut(false); |
804 TRACE_EVENT_ASYNC_END0("navigation", "RenderFrameHostImpl::SwapOut", this); | |
Charlie Reis
2014/08/27 22:05:13
Actually, if we put this in RFHI::OnSwappedOut bel
nasko
2014/08/27 23:30:01
It calls RVH directly: https://code.google.com/p/c
Charlie Reis
2014/08/28 16:20:09
Acknowledged.
| |
788 } | 805 } |
789 | 806 |
790 void RenderFrameHostImpl::OnSwappedOut(bool timed_out) { | 807 void RenderFrameHostImpl::OnSwappedOut(bool timed_out) { |
791 // For now, we only need to update the RVH state machine for top-level swaps. | 808 // For now, we only need to update the RVH state machine for top-level swaps. |
792 if (!GetParent()) | 809 if (!GetParent()) |
793 render_view_host_->OnSwappedOut(timed_out); | 810 render_view_host_->OnSwappedOut(timed_out); |
794 } | 811 } |
795 | 812 |
796 void RenderFrameHostImpl::OnContextMenu(const ContextMenuParams& params) { | 813 void RenderFrameHostImpl::OnContextMenu(const ContextMenuParams& params) { |
797 // Validate the URLs in |params|. If the renderer can't request the URLs | 814 // Validate the URLs in |params|. If the renderer can't request the URLs |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1040 bool RenderFrameHostImpl::CanCommitURL(const GURL& url) { | 1057 bool RenderFrameHostImpl::CanCommitURL(const GURL& url) { |
1041 // TODO(creis): We should also check for WebUI pages here. Also, when the | 1058 // TODO(creis): We should also check for WebUI pages here. Also, when the |
1042 // out-of-process iframes implementation is ready, we should check for | 1059 // out-of-process iframes implementation is ready, we should check for |
1043 // cross-site URLs that are not allowed to commit in this process. | 1060 // cross-site URLs that are not allowed to commit in this process. |
1044 | 1061 |
1045 // Give the client a chance to disallow URLs from committing. | 1062 // Give the client a chance to disallow URLs from committing. |
1046 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url); | 1063 return GetContentClient()->browser()->CanCommitURL(GetProcess(), url); |
1047 } | 1064 } |
1048 | 1065 |
1049 void RenderFrameHostImpl::Navigate(const FrameMsg_Navigate_Params& params) { | 1066 void RenderFrameHostImpl::Navigate(const FrameMsg_Navigate_Params& params) { |
1050 TRACE_EVENT0("frame_host", "RenderFrameHostImpl::Navigate"); | 1067 TRACE_EVENT0("navigation", "RenderFrameHostImpl::Navigate"); |
Charlie Reis
2014/08/27 22:05:12
This one's subtle. In many cross-process navigati
nasko
2014/08/27 23:30:01
I've added a trace event for the duration of navig
| |
1051 // Browser plugin guests are not allowed to navigate outside web-safe schemes, | 1068 // Browser plugin guests are not allowed to navigate outside web-safe schemes, |
1052 // so do not grant them the ability to request additional URLs. | 1069 // so do not grant them the ability to request additional URLs. |
1053 if (!GetProcess()->IsIsolatedGuest()) { | 1070 if (!GetProcess()->IsIsolatedGuest()) { |
1054 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( | 1071 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( |
1055 GetProcess()->GetID(), params.url); | 1072 GetProcess()->GetID(), params.url); |
1056 if (params.url.SchemeIs(url::kDataScheme) && | 1073 if (params.url.SchemeIs(url::kDataScheme) && |
1057 params.base_url_for_data_url.SchemeIs(url::kFileScheme)) { | 1074 params.base_url_for_data_url.SchemeIs(url::kFileScheme)) { |
1058 // If 'data:' is used, and we have a 'file:' base url, grant access to | 1075 // If 'data:' is used, and we have a 'file:' base url, grant access to |
1059 // local files. | 1076 // local files. |
1060 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( | 1077 ChildProcessSecurityPolicyImpl::GetInstance()->GrantRequestURL( |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1105 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 1122 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
1106 params.browser_navigation_start = base::TimeTicks::Now(); | 1123 params.browser_navigation_start = base::TimeTicks::Now(); |
1107 Navigate(params); | 1124 Navigate(params); |
1108 } | 1125 } |
1109 | 1126 |
1110 void RenderFrameHostImpl::Stop() { | 1127 void RenderFrameHostImpl::Stop() { |
1111 Send(new FrameMsg_Stop(routing_id_)); | 1128 Send(new FrameMsg_Stop(routing_id_)); |
1112 } | 1129 } |
1113 | 1130 |
1114 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_cross_site_transition) { | 1131 void RenderFrameHostImpl::DispatchBeforeUnload(bool for_cross_site_transition) { |
1132 TRACE_EVENT_ASYNC_BEGIN0( | |
1133 "navigation", "RenderFrameHostImpl::BeforeUnload", this); | |
1115 // TODO(creis): Support subframes. | 1134 // TODO(creis): Support subframes. |
1116 if (!render_view_host_->IsRenderViewLive() || GetParent()) { | 1135 if (!render_view_host_->IsRenderViewLive() || GetParent()) { |
1117 // We don't have a live renderer, so just skip running beforeunload. | 1136 // We don't have a live renderer, so just skip running beforeunload. |
1118 render_view_host_->is_waiting_for_beforeunload_ack_ = true; | 1137 render_view_host_->is_waiting_for_beforeunload_ack_ = true; |
1119 render_view_host_->unload_ack_is_for_cross_site_transition_ = | 1138 render_view_host_->unload_ack_is_for_cross_site_transition_ = |
1120 for_cross_site_transition; | 1139 for_cross_site_transition; |
1121 base::TimeTicks now = base::TimeTicks::Now(); | 1140 base::TimeTicks now = base::TimeTicks::Now(); |
1122 OnBeforeUnloadACK(true, now, now); | 1141 OnBeforeUnloadACK(true, now, now); |
1123 return; | 1142 return; |
1124 } | 1143 } |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1303 } | 1322 } |
1304 | 1323 |
1305 void RenderFrameHostImpl::CancelSuspendedNavigations() { | 1324 void RenderFrameHostImpl::CancelSuspendedNavigations() { |
1306 // Clear any state if a pending navigation is canceled or preempted. | 1325 // Clear any state if a pending navigation is canceled or preempted. |
1307 if (suspended_nav_params_) | 1326 if (suspended_nav_params_) |
1308 suspended_nav_params_.reset(); | 1327 suspended_nav_params_.reset(); |
1309 navigations_suspended_ = false; | 1328 navigations_suspended_ = false; |
1310 } | 1329 } |
1311 | 1330 |
1312 } // namespace content | 1331 } // namespace content |
OLD | NEW |