| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 // as part of a wider page load, the page_id will be the same as for the top | 949 // as part of a wider page load, the page_id will be the same as for the top |
| 950 // level frame. If the user explicitly requests a subframe navigation, we will | 950 // level frame. If the user explicitly requests a subframe navigation, we will |
| 951 // get a new page_id because we need to create a new navigation entry for that | 951 // get a new page_id because we need to create a new navigation entry for that |
| 952 // action. | 952 // action. |
| 953 void RenderFrameHostImpl::OnDidCommitProvisionalLoad(const IPC::Message& msg) { | 953 void RenderFrameHostImpl::OnDidCommitProvisionalLoad(const IPC::Message& msg) { |
| 954 RenderProcessHost* process = GetProcess(); | 954 RenderProcessHost* process = GetProcess(); |
| 955 | 955 |
| 956 // Read the parameters out of the IPC message directly to avoid making another | 956 // Read the parameters out of the IPC message directly to avoid making another |
| 957 // copy when we filter the URLs. | 957 // copy when we filter the URLs. |
| 958 base::PickleIterator iter(msg); | 958 base::PickleIterator iter(msg); |
| 959 FrameHostMsg_DidCommitProvisionalLoad_Params validated_params; | 959 base::Tuple<FrameHostMsg_DidCommitProvisionalLoad_Params, |
| 960 if (!IPC::ParamTraits<FrameHostMsg_DidCommitProvisionalLoad_Params>:: | 960 scoped_refptr<ResourceRequestBody>> |
| 961 Read(&msg, &iter, &validated_params)) { | 961 params; |
| 962 if (!FrameHostMsg_DidCommitProvisionalLoad::Read(&msg, ¶ms)) { |
| 962 bad_message::ReceivedBadMessage( | 963 bad_message::ReceivedBadMessage( |
| 963 process, bad_message::RFH_COMMIT_DESERIALIZATION_FAILED); | 964 process, bad_message::RFH_COMMIT_DESERIALIZATION_FAILED); |
| 964 return; | 965 return; |
| 965 } | 966 } |
| 967 FrameHostMsg_DidCommitProvisionalLoad_Params& validated_params = |
| 968 base::get<0>(params); |
| 969 scoped_refptr<ResourceRequestBody> post_data = base::get<1>(params); |
| 966 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OnDidCommitProvisionalLoad", | 970 TRACE_EVENT1("navigation", "RenderFrameHostImpl::OnDidCommitProvisionalLoad", |
| 967 "url", validated_params.url.possibly_invalid_spec()); | 971 "url", validated_params.url.possibly_invalid_spec()); |
| 968 | 972 |
| 969 // Sanity-check the page transition for frame type. | 973 // Sanity-check the page transition for frame type. |
| 970 DCHECK_EQ(ui::PageTransitionIsMainFrame(validated_params.transition), | 974 DCHECK_EQ(ui::PageTransitionIsMainFrame(validated_params.transition), |
| 971 !GetParent()); | 975 !GetParent()); |
| 972 | 976 |
| 973 // If we're waiting for a cross-site beforeunload ack from this renderer and | 977 // If we're waiting for a cross-site beforeunload ack from this renderer and |
| 974 // we receive a Navigate message from the main frame, then the renderer was | 978 // we receive a Navigate message from the main frame, then the renderer was |
| 975 // navigating already and sent it before hearing the FrameMsg_Stop message. | 979 // navigating already and sent it before hearing the FrameMsg_Stop message. |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 if (!is_loading()) { | 1104 if (!is_loading()) { |
| 1101 bool was_loading = frame_tree_node()->frame_tree()->IsLoading(); | 1105 bool was_loading = frame_tree_node()->frame_tree()->IsLoading(); |
| 1102 is_loading_ = true; | 1106 is_loading_ = true; |
| 1103 frame_tree_node()->DidStartLoading(true, was_loading); | 1107 frame_tree_node()->DidStartLoading(true, was_loading); |
| 1104 } | 1108 } |
| 1105 pending_commit_ = false; | 1109 pending_commit_ = false; |
| 1106 } | 1110 } |
| 1107 } | 1111 } |
| 1108 | 1112 |
| 1109 accessibility_reset_count_ = 0; | 1113 accessibility_reset_count_ = 0; |
| 1110 frame_tree_node()->navigator()->DidNavigate(this, validated_params); | 1114 frame_tree_node()->navigator()->DidNavigate(this, validated_params, |
| 1115 post_data); |
| 1111 | 1116 |
| 1112 // For a top-level frame, there are potential security concerns associated | 1117 // For a top-level frame, there are potential security concerns associated |
| 1113 // with displaying graphics from a previously loaded page after the URL in | 1118 // with displaying graphics from a previously loaded page after the URL in |
| 1114 // the omnibar has been changed. It is unappealing to clear the page | 1119 // the omnibar has been changed. It is unappealing to clear the page |
| 1115 // immediately, but if the renderer is taking a long time to issue any | 1120 // immediately, but if the renderer is taking a long time to issue any |
| 1116 // compositor output (possibly because of script deliberately creating this | 1121 // compositor output (possibly because of script deliberately creating this |
| 1117 // situation) then we clear it after a while anyway. | 1122 // situation) then we clear it after a while anyway. |
| 1118 // See https://crbug.com/497588. | 1123 // See https://crbug.com/497588. |
| 1119 if (frame_tree_node_->IsMainFrame() && GetView() && | 1124 if (frame_tree_node_->IsMainFrame() && GetView() && |
| 1120 !validated_params.was_within_same_page) { | 1125 !validated_params.was_within_same_page) { |
| (...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2062 | 2067 |
| 2063 void RenderFrameHostImpl::NavigateToInterstitialURL(const GURL& data_url) { | 2068 void RenderFrameHostImpl::NavigateToInterstitialURL(const GURL& data_url) { |
| 2064 DCHECK(data_url.SchemeIs(url::kDataScheme)); | 2069 DCHECK(data_url.SchemeIs(url::kDataScheme)); |
| 2065 CommonNavigationParams common_params( | 2070 CommonNavigationParams common_params( |
| 2066 data_url, Referrer(), ui::PAGE_TRANSITION_LINK, | 2071 data_url, Referrer(), ui::PAGE_TRANSITION_LINK, |
| 2067 FrameMsg_Navigate_Type::NORMAL, false, false, base::TimeTicks::Now(), | 2072 FrameMsg_Navigate_Type::NORMAL, false, false, base::TimeTicks::Now(), |
| 2068 FrameMsg_UILoadMetricsReportType::NO_REPORT, GURL(), GURL(), LOFI_OFF, | 2073 FrameMsg_UILoadMetricsReportType::NO_REPORT, GURL(), GURL(), LOFI_OFF, |
| 2069 base::TimeTicks::Now(), "GET"); | 2074 base::TimeTicks::Now(), "GET"); |
| 2070 if (IsBrowserSideNavigationEnabled()) { | 2075 if (IsBrowserSideNavigationEnabled()) { |
| 2071 CommitNavigation(nullptr, nullptr, common_params, RequestNavigationParams(), | 2076 CommitNavigation(nullptr, nullptr, common_params, RequestNavigationParams(), |
| 2072 false); | 2077 false, nullptr); |
| 2073 } else { | 2078 } else { |
| 2074 Navigate(common_params, StartNavigationParams(), RequestNavigationParams()); | 2079 Navigate(common_params, StartNavigationParams(), RequestNavigationParams()); |
| 2075 } | 2080 } |
| 2076 } | 2081 } |
| 2077 | 2082 |
| 2078 void RenderFrameHostImpl::OpenURL(const FrameHostMsg_OpenURL_Params& params, | 2083 void RenderFrameHostImpl::OpenURL(const FrameHostMsg_OpenURL_Params& params, |
| 2079 SiteInstance* source_site_instance) { | 2084 SiteInstance* source_site_instance) { |
| 2080 GURL validated_url(params.url); | 2085 GURL validated_url(params.url); |
| 2081 GetProcess()->FilterURL(false, &validated_url); | 2086 GetProcess()->FilterURL(false, &validated_url); |
| 2082 | 2087 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2193 render_view_host_->GetWidget()); | 2198 render_view_host_->GetWidget()); |
| 2194 } | 2199 } |
| 2195 } | 2200 } |
| 2196 | 2201 |
| 2197 // PlzNavigate | 2202 // PlzNavigate |
| 2198 void RenderFrameHostImpl::CommitNavigation( | 2203 void RenderFrameHostImpl::CommitNavigation( |
| 2199 ResourceResponse* response, | 2204 ResourceResponse* response, |
| 2200 std::unique_ptr<StreamHandle> body, | 2205 std::unique_ptr<StreamHandle> body, |
| 2201 const CommonNavigationParams& common_params, | 2206 const CommonNavigationParams& common_params, |
| 2202 const RequestNavigationParams& request_params, | 2207 const RequestNavigationParams& request_params, |
| 2203 bool is_view_source) { | 2208 bool is_view_source, |
| 2209 scoped_refptr<ResourceRequestBody> post_data) { |
| 2204 DCHECK((response && body.get()) || | 2210 DCHECK((response && body.get()) || |
| 2205 !ShouldMakeNetworkRequestForURL(common_params.url)); | 2211 !ShouldMakeNetworkRequestForURL(common_params.url)); |
| 2206 UpdatePermissionsForNavigation(common_params, request_params); | 2212 UpdatePermissionsForNavigation(common_params, request_params); |
| 2207 | 2213 |
| 2208 // Get back to a clean state, in case we start a new navigation without | 2214 // Get back to a clean state, in case we start a new navigation without |
| 2209 // completing an unload handler. | 2215 // completing an unload handler. |
| 2210 ResetWaitingState(); | 2216 ResetWaitingState(); |
| 2211 | 2217 |
| 2212 // The renderer can exit view source mode when any error or cancellation | 2218 // The renderer can exit view source mode when any error or cancellation |
| 2213 // happen. When reusing the same renderer, overwrite to recover the mode. | 2219 // happen. When reusing the same renderer, overwrite to recover the mode. |
| 2214 if (is_view_source && | 2220 if (is_view_source && |
| 2215 this == frame_tree_node_->render_manager()->current_frame_host()) { | 2221 this == frame_tree_node_->render_manager()->current_frame_host()) { |
| 2216 DCHECK(!GetParent()); | 2222 DCHECK(!GetParent()); |
| 2217 render_view_host()->Send(new FrameMsg_EnableViewSourceMode(routing_id_)); | 2223 render_view_host()->Send(new FrameMsg_EnableViewSourceMode(routing_id_)); |
| 2218 } | 2224 } |
| 2219 | 2225 |
| 2220 const GURL body_url = body.get() ? body->GetURL() : GURL(); | 2226 const GURL body_url = body.get() ? body->GetURL() : GURL(); |
| 2221 const ResourceResponseHead head = response ? | 2227 const ResourceResponseHead head = response ? |
| 2222 response->head : ResourceResponseHead(); | 2228 response->head : ResourceResponseHead(); |
| 2223 Send(new FrameMsg_CommitNavigation(routing_id_, head, body_url, common_params, | 2229 Send(new FrameMsg_CommitNavigation(routing_id_, head, body_url, common_params, |
| 2224 request_params)); | 2230 request_params, post_data)); |
| 2225 | 2231 |
| 2226 // If a network request was made, update the LoFi state. | 2232 // If a network request was made, update the LoFi state. |
| 2227 if (ShouldMakeNetworkRequestForURL(common_params.url)) | 2233 if (ShouldMakeNetworkRequestForURL(common_params.url)) |
| 2228 last_navigation_lofi_state_ = common_params.lofi_state; | 2234 last_navigation_lofi_state_ = common_params.lofi_state; |
| 2229 | 2235 |
| 2230 // TODO(clamy): Release the stream handle once the renderer has finished | 2236 // TODO(clamy): Release the stream handle once the renderer has finished |
| 2231 // reading it. | 2237 // reading it. |
| 2232 stream_handle_ = std::move(body); | 2238 stream_handle_ = std::move(body); |
| 2233 | 2239 |
| 2234 // When navigating to a Javascript url, no commit is expected from the | 2240 // When navigating to a Javascript url, no commit is expected from the |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2771 // handler after it's destroyed so it can't run after the RFHI is destroyed. | 2777 // handler after it's destroyed so it can't run after the RFHI is destroyed. |
| 2772 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind( | 2778 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind( |
| 2773 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this))); | 2779 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this))); |
| 2774 } | 2780 } |
| 2775 | 2781 |
| 2776 void RenderFrameHostImpl::DeleteWebBluetoothService() { | 2782 void RenderFrameHostImpl::DeleteWebBluetoothService() { |
| 2777 web_bluetooth_service_.reset(); | 2783 web_bluetooth_service_.reset(); |
| 2778 } | 2784 } |
| 2779 | 2785 |
| 2780 } // namespace content | 2786 } // namespace content |
| OLD | NEW |