| 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 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 GetProcess()->FilterURL(false, &validated_url); | 562 GetProcess()->FilterURL(false, &validated_url); |
| 563 | 563 |
| 564 frame_tree_node_->navigator()->DidFailLoadWithError( | 564 frame_tree_node_->navigator()->DidFailLoadWithError( |
| 565 this, validated_url, error_code, error_description); | 565 this, validated_url, error_code, error_description); |
| 566 } | 566 } |
| 567 | 567 |
| 568 void RenderFrameHostImpl::OnDidRedirectProvisionalLoad( | 568 void RenderFrameHostImpl::OnDidRedirectProvisionalLoad( |
| 569 int32 page_id, | 569 int32 page_id, |
| 570 const GURL& source_url, | 570 const GURL& source_url, |
| 571 const GURL& target_url) { | 571 const GURL& target_url) { |
| 572 CHECK_EQ(render_view_host_->page_id_, page_id); |
| 572 frame_tree_node_->navigator()->DidRedirectProvisionalLoad( | 573 frame_tree_node_->navigator()->DidRedirectProvisionalLoad( |
| 573 this, page_id, source_url, target_url); | 574 this, render_view_host_->page_id_, source_url, target_url); |
| 574 } | 575 } |
| 575 | 576 |
| 576 // Called when the renderer navigates. For every frame loaded, we'll get this | 577 // Called when the renderer navigates. For every frame loaded, we'll get this |
| 577 // notification containing parameters identifying the navigation. | 578 // notification containing parameters identifying the navigation. |
| 578 // | 579 // |
| 579 // Subframes are identified by the page transition type. For subframes loaded | 580 // Subframes are identified by the page transition type. For subframes loaded |
| 580 // as part of a wider page load, the page_id will be the same as for the top | 581 // as part of a wider page load, the page_id will be the same as for the top |
| 581 // level frame. If the user explicitly requests a subframe navigation, we will | 582 // level frame. If the user explicitly requests a subframe navigation, we will |
| 582 // get a new page_id because we need to create a new navigation entry for that | 583 // get a new page_id because we need to create a new navigation entry for that |
| 583 // action. | 584 // action. |
| 584 void RenderFrameHostImpl::OnNavigate(const IPC::Message& msg) { | 585 void RenderFrameHostImpl::OnNavigate(const IPC::Message& msg) { |
| 585 // Read the parameters out of the IPC message directly to avoid making another | 586 // Read the parameters out of the IPC message directly to avoid making another |
| 586 // copy when we filter the URLs. | 587 // copy when we filter the URLs. |
| 587 PickleIterator iter(msg); | 588 PickleIterator iter(msg); |
| 588 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params; | 589 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params; |
| 589 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>:: | 590 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>:: |
| 590 Read(&msg, &iter, &validated_params)) | 591 Read(&msg, &iter, &validated_params)) |
| 591 return; | 592 return; |
| 592 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OnNavigate", | 593 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OnNavigate", |
| 593 "url", validated_params.url.possibly_invalid_spec()); | 594 "url", validated_params.url.possibly_invalid_spec()); |
| 594 | 595 |
| 596 // Update the RVH's current page ID so that future IPCs from the renderer |
| 597 // correspond to the new page. |
| 598 render_view_host_->page_id_ = validated_params.page_id; |
| 599 |
| 595 // If we're waiting for a cross-site beforeunload ack from this renderer and | 600 // If we're waiting for a cross-site beforeunload ack from this renderer and |
| 596 // we receive a Navigate message from the main frame, then the renderer was | 601 // we receive a Navigate message from the main frame, then the renderer was |
| 597 // navigating already and sent it before hearing the FrameMsg_Stop message. | 602 // navigating already and sent it before hearing the FrameMsg_Stop message. |
| 598 // We do not want to cancel the pending navigation in this case, since the | 603 // We do not want to cancel the pending navigation in this case, since the |
| 599 // old page will soon be stopped. Instead, treat this as a beforeunload ack | 604 // old page will soon be stopped. Instead, treat this as a beforeunload ack |
| 600 // to allow the pending navigation to continue. | 605 // to allow the pending navigation to continue. |
| 601 if (render_view_host_->is_waiting_for_beforeunload_ack_ && | 606 if (render_view_host_->is_waiting_for_beforeunload_ack_ && |
| 602 render_view_host_->unload_ack_is_for_cross_site_transition_ && | 607 render_view_host_->unload_ack_is_for_cross_site_transition_ && |
| 603 PageTransitionIsMainFrame(validated_params.transition)) { | 608 PageTransitionIsMainFrame(validated_params.transition)) { |
| 604 OnBeforeUnloadACK(true, send_before_unload_start_time_, | 609 OnBeforeUnloadACK(true, send_before_unload_start_time_, |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 void RenderFrameHostImpl::OnDidDisownOpener() { | 923 void RenderFrameHostImpl::OnDidDisownOpener() { |
| 919 // This message is only sent for top-level frames. TODO(avi): when frame tree | 924 // This message is only sent for top-level frames. TODO(avi): when frame tree |
| 920 // mirroring works correctly, add a check here to enforce it. | 925 // mirroring works correctly, add a check here to enforce it. |
| 921 delegate_->DidDisownOpener(this); | 926 delegate_->DidDisownOpener(this); |
| 922 } | 927 } |
| 923 | 928 |
| 924 void RenderFrameHostImpl::OnUpdateTitle( | 929 void RenderFrameHostImpl::OnUpdateTitle( |
| 925 int32 page_id, | 930 int32 page_id, |
| 926 const base::string16& title, | 931 const base::string16& title, |
| 927 blink::WebTextDirection title_direction) { | 932 blink::WebTextDirection title_direction) { |
| 933 CHECK_EQ(render_view_host_->page_id_, page_id); |
| 928 // This message is only sent for top-level frames. TODO(avi): when frame tree | 934 // This message is only sent for top-level frames. TODO(avi): when frame tree |
| 929 // mirroring works correctly, add a check here to enforce it. | 935 // mirroring works correctly, add a check here to enforce it. |
| 930 if (title.length() > kMaxTitleChars) { | 936 if (title.length() > kMaxTitleChars) { |
| 931 NOTREACHED() << "Renderer sent too many characters in title."; | 937 NOTREACHED() << "Renderer sent too many characters in title."; |
| 932 return; | 938 return; |
| 933 } | 939 } |
| 934 | 940 |
| 935 delegate_->UpdateTitle(this, page_id, title, | 941 delegate_->UpdateTitle(this, render_view_host_->page_id_, title, |
| 936 WebTextDirectionToChromeTextDirection( | 942 WebTextDirectionToChromeTextDirection( |
| 937 title_direction)); | 943 title_direction)); |
| 938 } | 944 } |
| 939 | 945 |
| 940 void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) { | 946 void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) { |
| 941 // This message is only sent for top-level frames. TODO(avi): when frame tree | 947 // This message is only sent for top-level frames. TODO(avi): when frame tree |
| 942 // mirroring works correctly, add a check here to enforce it. | 948 // mirroring works correctly, add a check here to enforce it. |
| 943 delegate_->UpdateEncoding(this, encoding_name); | 949 delegate_->UpdateEncoding(this, encoding_name); |
| 944 } | 950 } |
| 945 | 951 |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1329 // Clear any state if a pending navigation is canceled or preempted. | 1335 // Clear any state if a pending navigation is canceled or preempted. |
| 1330 if (suspended_nav_params_) | 1336 if (suspended_nav_params_) |
| 1331 suspended_nav_params_.reset(); | 1337 suspended_nav_params_.reset(); |
| 1332 | 1338 |
| 1333 TRACE_EVENT_ASYNC_END0("navigation", | 1339 TRACE_EVENT_ASYNC_END0("navigation", |
| 1334 "RenderFrameHostImpl navigation suspended", this); | 1340 "RenderFrameHostImpl navigation suspended", this); |
| 1335 navigations_suspended_ = false; | 1341 navigations_suspended_ = false; |
| 1336 } | 1342 } |
| 1337 | 1343 |
| 1338 } // namespace content | 1344 } // namespace content |
| OLD | NEW |