| 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/debug/crash_logging.h" | |
| 11 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 12 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 13 #include "base/metrics/user_metrics_action.h" | 12 #include "base/metrics/user_metrics_action.h" |
| 14 #include "base/strings/string_number_conversions.h" | |
| 15 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 16 #include "content/browser/accessibility/accessibility_mode_helper.h" | 14 #include "content/browser/accessibility/accessibility_mode_helper.h" |
| 17 #include "content/browser/accessibility/browser_accessibility_manager.h" | 15 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 18 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 16 #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
| 19 #include "content/browser/child_process_security_policy_impl.h" | 17 #include "content/browser/child_process_security_policy_impl.h" |
| 20 #include "content/browser/frame_host/cross_process_frame_connector.h" | 18 #include "content/browser/frame_host/cross_process_frame_connector.h" |
| 21 #include "content/browser/frame_host/cross_site_transferring_request.h" | 19 #include "content/browser/frame_host/cross_site_transferring_request.h" |
| 22 #include "content/browser/frame_host/frame_tree.h" | 20 #include "content/browser/frame_host/frame_tree.h" |
| 23 #include "content/browser/frame_host/frame_tree_node.h" | 21 #include "content/browser/frame_host/frame_tree_node.h" |
| 24 #include "content/browser/frame_host/navigator.h" | 22 #include "content/browser/frame_host/navigator.h" |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 GetProcess()->FilterURL(false, &validated_url); | 550 GetProcess()->FilterURL(false, &validated_url); |
| 553 | 551 |
| 554 frame_tree_node_->navigator()->DidFailLoadWithError( | 552 frame_tree_node_->navigator()->DidFailLoadWithError( |
| 555 this, validated_url, error_code, error_description); | 553 this, validated_url, error_code, error_description); |
| 556 } | 554 } |
| 557 | 555 |
| 558 void RenderFrameHostImpl::OnDidRedirectProvisionalLoad( | 556 void RenderFrameHostImpl::OnDidRedirectProvisionalLoad( |
| 559 int32 page_id, | 557 int32 page_id, |
| 560 const GURL& source_url, | 558 const GURL& source_url, |
| 561 const GURL& target_url) { | 559 const GURL& target_url) { |
| 562 if (render_view_host_->page_id_ != page_id) { | |
| 563 base::debug::SetCrashKeyValue("url1", | |
| 564 source_url.possibly_invalid_spec()); | |
| 565 base::debug::SetCrashKeyValue("url2", | |
| 566 target_url.possibly_invalid_spec()); | |
| 567 base::debug::SetCrashKeyValue( | |
| 568 "id1", base::IntToString(render_view_host_->page_id_)); | |
| 569 base::debug::SetCrashKeyValue("id2", | |
| 570 base::IntToString(page_id)); | |
| 571 CHECK(false); | |
| 572 } | |
| 573 frame_tree_node_->navigator()->DidRedirectProvisionalLoad( | 560 frame_tree_node_->navigator()->DidRedirectProvisionalLoad( |
| 574 this, render_view_host_->page_id_, source_url, target_url); | 561 this, page_id, source_url, target_url); |
| 575 } | 562 } |
| 576 | 563 |
| 577 // Called when the renderer navigates. For every frame loaded, we'll get this | 564 // Called when the renderer navigates. For every frame loaded, we'll get this |
| 578 // notification containing parameters identifying the navigation. | 565 // notification containing parameters identifying the navigation. |
| 579 // | 566 // |
| 580 // Subframes are identified by the page transition type. For subframes loaded | 567 // Subframes are identified by the page transition type. For subframes loaded |
| 581 // as part of a wider page load, the page_id will be the same as for the top | 568 // as part of a wider page load, the page_id will be the same as for the top |
| 582 // level frame. If the user explicitly requests a subframe navigation, we will | 569 // level frame. If the user explicitly requests a subframe navigation, we will |
| 583 // get a new page_id because we need to create a new navigation entry for that | 570 // get a new page_id because we need to create a new navigation entry for that |
| 584 // action. | 571 // action. |
| 585 void RenderFrameHostImpl::OnNavigate(const IPC::Message& msg) { | 572 void RenderFrameHostImpl::OnNavigate(const IPC::Message& msg) { |
| 586 // Read the parameters out of the IPC message directly to avoid making another | 573 // Read the parameters out of the IPC message directly to avoid making another |
| 587 // copy when we filter the URLs. | 574 // copy when we filter the URLs. |
| 588 PickleIterator iter(msg); | 575 PickleIterator iter(msg); |
| 589 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params; | 576 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params; |
| 590 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>:: | 577 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>:: |
| 591 Read(&msg, &iter, &validated_params)) | 578 Read(&msg, &iter, &validated_params)) |
| 592 return; | 579 return; |
| 593 | 580 |
| 594 // Update the RVH's current page ID so that future IPCs from the renderer | |
| 595 // correspond to the new page. | |
| 596 render_view_host_->page_id_ = validated_params.page_id; | |
| 597 | |
| 598 // If we're waiting for a cross-site beforeunload ack from this renderer and | 581 // If we're waiting for a cross-site beforeunload ack from this renderer and |
| 599 // we receive a Navigate message from the main frame, then the renderer was | 582 // we receive a Navigate message from the main frame, then the renderer was |
| 600 // navigating already and sent it before hearing the ViewMsg_Stop message. | 583 // navigating already and sent it before hearing the ViewMsg_Stop message. |
| 601 // We do not want to cancel the pending navigation in this case, since the | 584 // We do not want to cancel the pending navigation in this case, since the |
| 602 // old page will soon be stopped. Instead, treat this as a beforeunload ack | 585 // old page will soon be stopped. Instead, treat this as a beforeunload ack |
| 603 // to allow the pending navigation to continue. | 586 // to allow the pending navigation to continue. |
| 604 if (render_view_host_->is_waiting_for_beforeunload_ack_ && | 587 if (render_view_host_->is_waiting_for_beforeunload_ack_ && |
| 605 render_view_host_->unload_ack_is_for_cross_site_transition_ && | 588 render_view_host_->unload_ack_is_for_cross_site_transition_ && |
| 606 PageTransitionIsMainFrame(validated_params.transition)) { | 589 PageTransitionIsMainFrame(validated_params.transition)) { |
| 607 OnBeforeUnloadACK(true, send_before_unload_start_time_, | 590 OnBeforeUnloadACK(true, send_before_unload_start_time_, |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 void RenderFrameHostImpl::OnDidDisownOpener() { | 895 void RenderFrameHostImpl::OnDidDisownOpener() { |
| 913 // This message is only sent for top-level frames. TODO(avi): when frame tree | 896 // This message is only sent for top-level frames. TODO(avi): when frame tree |
| 914 // mirroring works correctly, add a check here to enforce it. | 897 // mirroring works correctly, add a check here to enforce it. |
| 915 delegate_->DidDisownOpener(this); | 898 delegate_->DidDisownOpener(this); |
| 916 } | 899 } |
| 917 | 900 |
| 918 void RenderFrameHostImpl::OnUpdateTitle( | 901 void RenderFrameHostImpl::OnUpdateTitle( |
| 919 int32 page_id, | 902 int32 page_id, |
| 920 const base::string16& title, | 903 const base::string16& title, |
| 921 blink::WebTextDirection title_direction) { | 904 blink::WebTextDirection title_direction) { |
| 922 if (render_view_host_->page_id_ != page_id) { | |
| 923 base::debug::SetCrashKeyValue( | |
| 924 "url1", GetLastCommittedURL().possibly_invalid_spec()); | |
| 925 base::debug::SetCrashKeyValue( | |
| 926 "id1", base::IntToString(render_view_host_->page_id_)); | |
| 927 base::debug::SetCrashKeyValue("id2", | |
| 928 base::IntToString(page_id)); | |
| 929 CHECK(false); | |
| 930 } | |
| 931 // This message is only sent for top-level frames. TODO(avi): when frame tree | 905 // This message is only sent for top-level frames. TODO(avi): when frame tree |
| 932 // mirroring works correctly, add a check here to enforce it. | 906 // mirroring works correctly, add a check here to enforce it. |
| 933 if (title.length() > kMaxTitleChars) { | 907 if (title.length() > kMaxTitleChars) { |
| 934 NOTREACHED() << "Renderer sent too many characters in title."; | 908 NOTREACHED() << "Renderer sent too many characters in title."; |
| 935 return; | 909 return; |
| 936 } | 910 } |
| 937 | 911 |
| 938 delegate_->UpdateTitle(this, render_view_host_->page_id_, title, | 912 delegate_->UpdateTitle(this, page_id, title, |
| 939 WebTextDirectionToChromeTextDirection( | 913 WebTextDirectionToChromeTextDirection( |
| 940 title_direction)); | 914 title_direction)); |
| 941 } | 915 } |
| 942 | 916 |
| 943 void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) { | 917 void RenderFrameHostImpl::OnUpdateEncoding(const std::string& encoding_name) { |
| 944 // This message is only sent for top-level frames. TODO(avi): when frame tree | 918 // This message is only sent for top-level frames. TODO(avi): when frame tree |
| 945 // mirroring works correctly, add a check here to enforce it. | 919 // mirroring works correctly, add a check here to enforce it. |
| 946 delegate_->UpdateEncoding(this, encoding_name); | 920 delegate_->UpdateEncoding(this, encoding_name); |
| 947 } | 921 } |
| 948 | 922 |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1262 } | 1236 } |
| 1263 | 1237 |
| 1264 void RenderFrameHostImpl::CancelSuspendedNavigations() { | 1238 void RenderFrameHostImpl::CancelSuspendedNavigations() { |
| 1265 // Clear any state if a pending navigation is canceled or preempted. | 1239 // Clear any state if a pending navigation is canceled or preempted. |
| 1266 if (suspended_nav_params_) | 1240 if (suspended_nav_params_) |
| 1267 suspended_nav_params_.reset(); | 1241 suspended_nav_params_.reset(); |
| 1268 navigations_suspended_ = false; | 1242 navigations_suspended_ = false; |
| 1269 } | 1243 } |
| 1270 | 1244 |
| 1271 } // namespace content | 1245 } // namespace content |
| OLD | NEW |