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/containers/hash_tables.h" | 8 #include "base/containers/hash_tables.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/metrics/user_metrics_action.h" | 10 #include "base/metrics/user_metrics_action.h" |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 GetProcess()->FilterURL(false, &validated_url); | 545 GetProcess()->FilterURL(false, &validated_url); |
546 | 546 |
547 frame_tree_node_->navigator()->DidFailLoadWithError( | 547 frame_tree_node_->navigator()->DidFailLoadWithError( |
548 this, validated_url, error_code, error_description); | 548 this, validated_url, error_code, error_description); |
549 } | 549 } |
550 | 550 |
551 void RenderFrameHostImpl::OnDidRedirectProvisionalLoad( | 551 void RenderFrameHostImpl::OnDidRedirectProvisionalLoad( |
552 int32 page_id, | 552 int32 page_id, |
553 const GURL& source_url, | 553 const GURL& source_url, |
554 const GURL& target_url) { | 554 const GURL& target_url) { |
555 CHECK_EQ(render_view_host_->page_id_, page_id); | |
556 frame_tree_node_->navigator()->DidRedirectProvisionalLoad( | 555 frame_tree_node_->navigator()->DidRedirectProvisionalLoad( |
557 this, render_view_host_->page_id_, source_url, target_url); | 556 this, page_id, source_url, target_url); |
558 } | 557 } |
559 | 558 |
560 // Called when the renderer navigates. For every frame loaded, we'll get this | 559 // Called when the renderer navigates. For every frame loaded, we'll get this |
561 // notification containing parameters identifying the navigation. | 560 // notification containing parameters identifying the navigation. |
562 // | 561 // |
563 // Subframes are identified by the page transition type. For subframes loaded | 562 // Subframes are identified by the page transition type. For subframes loaded |
564 // as part of a wider page load, the page_id will be the same as for the top | 563 // as part of a wider page load, the page_id will be the same as for the top |
565 // level frame. If the user explicitly requests a subframe navigation, we will | 564 // level frame. If the user explicitly requests a subframe navigation, we will |
566 // get a new page_id because we need to create a new navigation entry for that | 565 // get a new page_id because we need to create a new navigation entry for that |
567 // action. | 566 // action. |
568 void RenderFrameHostImpl::OnNavigate(const IPC::Message& msg) { | 567 void RenderFrameHostImpl::OnNavigate(const IPC::Message& msg) { |
569 // Read the parameters out of the IPC message directly to avoid making another | 568 // Read the parameters out of the IPC message directly to avoid making another |
570 // copy when we filter the URLs. | 569 // copy when we filter the URLs. |
571 PickleIterator iter(msg); | 570 PickleIterator iter(msg); |
572 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params; | 571 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params; |
573 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>:: | 572 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>:: |
574 Read(&msg, &iter, &validated_params)) | 573 Read(&msg, &iter, &validated_params)) |
575 return; | 574 return; |
576 | 575 |
577 // Update the RVH's current page ID so that future IPCs from the renderer | |
578 // correspond to the new page. | |
579 render_view_host_->page_id_ = validated_params.page_id; | |
580 | |
581 // If we're waiting for a cross-site beforeunload ack from this renderer and | 576 // If we're waiting for a cross-site beforeunload ack from this renderer and |
582 // we receive a Navigate message from the main frame, then the renderer was | 577 // we receive a Navigate message from the main frame, then the renderer was |
583 // navigating already and sent it before hearing the ViewMsg_Stop message. | 578 // navigating already and sent it before hearing the ViewMsg_Stop message. |
584 // We do not want to cancel the pending navigation in this case, since the | 579 // We do not want to cancel the pending navigation in this case, since the |
585 // old page will soon be stopped. Instead, treat this as a beforeunload ack | 580 // old page will soon be stopped. Instead, treat this as a beforeunload ack |
586 // to allow the pending navigation to continue. | 581 // to allow the pending navigation to continue. |
587 if (render_view_host_->is_waiting_for_beforeunload_ack_ && | 582 if (render_view_host_->is_waiting_for_beforeunload_ack_ && |
588 render_view_host_->unload_ack_is_for_cross_site_transition_ && | 583 render_view_host_->unload_ack_is_for_cross_site_transition_ && |
589 PageTransitionIsMainFrame(validated_params.transition)) { | 584 PageTransitionIsMainFrame(validated_params.transition)) { |
590 OnBeforeUnloadACK(true, send_before_unload_start_time_, | 585 OnBeforeUnloadACK(true, send_before_unload_start_time_, |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 void RenderFrameHostImpl::OnDidDisownOpener() { | 878 void RenderFrameHostImpl::OnDidDisownOpener() { |
884 // This message is only sent for top-level frames. TODO(avi): when frame tree | 879 // This message is only sent for top-level frames. TODO(avi): when frame tree |
885 // mirroring works correctly, add a check here to enforce it. | 880 // mirroring works correctly, add a check here to enforce it. |
886 delegate_->DidDisownOpener(this); | 881 delegate_->DidDisownOpener(this); |
887 } | 882 } |
888 | 883 |
889 void RenderFrameHostImpl::OnUpdateTitle( | 884 void RenderFrameHostImpl::OnUpdateTitle( |
890 int32 page_id, | 885 int32 page_id, |
891 const base::string16& title, | 886 const base::string16& title, |
892 blink::WebTextDirection title_direction) { | 887 blink::WebTextDirection title_direction) { |
893 CHECK_EQ(render_view_host_->page_id_, page_id); | |
894 // This message is only sent for top-level frames. TODO(avi): when frame tree | 888 // This message is only sent for top-level frames. TODO(avi): when frame tree |
895 // mirroring works correctly, add a check here to enforce it. | 889 // mirroring works correctly, add a check here to enforce it. |
896 if (title.length() > kMaxTitleChars) { | 890 if (title.length() > kMaxTitleChars) { |
897 NOTREACHED() << "Renderer sent too many characters in title."; | 891 NOTREACHED() << "Renderer sent too many characters in title."; |
898 return; | 892 return; |
899 } | 893 } |
900 | 894 |
901 delegate_->UpdateTitle(this, render_view_host_->page_id_, title, | 895 delegate_->UpdateTitle(this, page_id, title, |
902 WebTextDirectionToChromeTextDirection( | 896 WebTextDirectionToChromeTextDirection( |
903 title_direction)); | 897 title_direction)); |
904 } | 898 } |
905 | 899 |
906 void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) { | 900 void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) { |
907 // This message is only sent for top-level frames. TODO(avi): when frame tree | 901 // This message is only sent for top-level frames. TODO(avi): when frame tree |
908 // mirroring works correctly, add a check here to enforce it. | 902 // mirroring works correctly, add a check here to enforce it. |
909 delegate_->UpdateEncoding(this, encoding_name); | 903 delegate_->UpdateEncoding(this, encoding_name); |
910 } | 904 } |
911 | 905 |
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1201 FROM_HERE, | 1195 FROM_HERE, |
1202 base::Bind( | 1196 base::Bind( |
1203 &TransitionRequestManager::SetHasPendingTransitionRequest, | 1197 &TransitionRequestManager::SetHasPendingTransitionRequest, |
1204 base::Unretained(TransitionRequestManager::GetInstance()), | 1198 base::Unretained(TransitionRequestManager::GetInstance()), |
1205 GetProcess()->GetID(), | 1199 GetProcess()->GetID(), |
1206 routing_id_, | 1200 routing_id_, |
1207 has_pending_request)); | 1201 has_pending_request)); |
1208 } | 1202 } |
1209 | 1203 |
1210 } // namespace content | 1204 } // namespace content |
OLD | NEW |