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 1158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 process->FilterURL(true, &validated_params.searchable_form_url); | 1169 process->FilterURL(true, &validated_params.searchable_form_url); |
1170 | 1170 |
1171 // Without this check, the renderer can trick the browser into using | 1171 // Without this check, the renderer can trick the browser into using |
1172 // filenames it can't access in a future session restore. | 1172 // filenames it can't access in a future session restore. |
1173 if (!CanAccessFilesOfPageState(validated_params.page_state)) { | 1173 if (!CanAccessFilesOfPageState(validated_params.page_state)) { |
1174 bad_message::ReceivedBadMessage( | 1174 bad_message::ReceivedBadMessage( |
1175 GetProcess(), bad_message::RFH_CAN_ACCESS_FILES_OF_PAGE_STATE); | 1175 GetProcess(), bad_message::RFH_CAN_ACCESS_FILES_OF_PAGE_STATE); |
1176 return; | 1176 return; |
1177 } | 1177 } |
1178 | 1178 |
1179 // If the URL does not match what the NavigationHandle expects, treat the | 1179 // If the URL or |was_within_same_page| does not match what the |
1180 // commit as a new navigation. This can happen if an ongoing slow | 1180 // NavigationHandle expects, treat the commit as a new navigation. This can |
1181 // same-process navigation is interrupted by a synchronous renderer-initiated | 1181 // happen if an ongoing slow same-process navigation is interwoven with a |
1182 // navigation. | 1182 // synchronous renderer-initiated navigation. |
1183 // TODO(csharrison): Data navigations loaded with LoadDataWithBaseURL get | 1183 // TODO(csharrison): Data navigations loaded with LoadDataWithBaseURL get |
1184 // reset here, because the NavigationHandle tracks the URL but the | 1184 // reset here, because the NavigationHandle tracks the URL but the |
1185 // validated_params.url tracks the data. The trick of saving the old entry ids | 1185 // validated_params.url tracks the data. The trick of saving the old entry ids |
1186 // for these navigations should go away when this is properly handled. See | 1186 // for these navigations should go away when this is properly handled. See |
1187 // crbug.com/588317. | 1187 // crbug.com/588317. |
1188 int entry_id_for_data_nav = 0; | 1188 int entry_id_for_data_nav = 0; |
1189 bool is_renderer_initiated = true; | 1189 bool is_renderer_initiated = true; |
1190 if (navigation_handle_ && | 1190 if (navigation_handle_ && |
1191 (navigation_handle_->GetURL() != validated_params.url)) { | 1191 ((navigation_handle_->GetURL() != validated_params.url) || |
| 1192 navigation_handle_->IsSamePage() != |
| 1193 validated_params.was_within_same_page)) { |
1192 // Make sure that the pending entry was really loaded via | 1194 // Make sure that the pending entry was really loaded via |
1193 // LoadDataWithBaseURL and that it matches this handle. | 1195 // LoadDataWithBaseURL and that it matches this handle. |
1194 NavigationEntryImpl* pending_entry = | 1196 NavigationEntryImpl* pending_entry = |
1195 NavigationEntryImpl::FromNavigationEntry( | 1197 NavigationEntryImpl::FromNavigationEntry( |
1196 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); | 1198 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); |
1197 bool pending_entry_matches_handle = | 1199 bool pending_entry_matches_handle = |
1198 pending_entry && | 1200 pending_entry && |
1199 pending_entry->GetUniqueID() == | 1201 pending_entry->GetUniqueID() == |
1200 navigation_handle_->pending_nav_entry_id(); | 1202 navigation_handle_->pending_nav_entry_id(); |
1201 // TODO(csharrison): The pending entry's base url should equal | 1203 // TODO(csharrison): The pending entry's base url should equal |
1202 // |validated_params.base_url|. This is not the case for loads with invalid | 1204 // |validated_params.base_url|. This is not the case for loads with invalid |
1203 // base urls. | 1205 // base urls. |
1204 if (navigation_handle_->GetURL() == validated_params.base_url && | 1206 if (navigation_handle_->GetURL() == validated_params.base_url && |
1205 pending_entry_matches_handle && | 1207 pending_entry_matches_handle && |
1206 !pending_entry->GetBaseURLForDataURL().is_empty()) { | 1208 !pending_entry->GetBaseURLForDataURL().is_empty()) { |
1207 entry_id_for_data_nav = navigation_handle_->pending_nav_entry_id(); | 1209 entry_id_for_data_nav = navigation_handle_->pending_nav_entry_id(); |
1208 is_renderer_initiated = pending_entry->is_renderer_initiated(); | 1210 is_renderer_initiated = pending_entry->is_renderer_initiated(); |
1209 } | 1211 } |
1210 navigation_handle_.reset(); | 1212 navigation_handle_.reset(); |
1211 } | 1213 } |
1212 | 1214 |
1213 // Synchronous renderer-initiated navigations will send a | 1215 // Synchronous renderer-initiated navigations will send a |
1214 // DidCommitProvisionalLoad IPC without a prior DidStartProvisionalLoad | 1216 // DidCommitProvisionalLoad IPC without a prior DidStartProvisionalLoad |
1215 // message. | 1217 // message. Or in addition, the if block above can reset the NavigationHandle |
| 1218 // in cases it doesn't match the expected commit. |
1216 if (!navigation_handle_) { | 1219 if (!navigation_handle_) { |
1217 // There is no pending NavigationEntry in these cases, so pass 0 as the | 1220 // There is no pending NavigationEntry in these cases, so pass 0 as the |
1218 // nav_id. If the previous handle was a prematurely aborted navigation | 1221 // nav_id. If the previous handle was a prematurely aborted navigation |
1219 // loaded via LoadDataWithBaseURL, propogate the entry id. | 1222 // loaded via LoadDataWithBaseURL, propogate the entry id. |
1220 navigation_handle_ = NavigationHandleImpl::Create( | 1223 navigation_handle_ = NavigationHandleImpl::Create( |
1221 validated_params.url, frame_tree_node_, is_renderer_initiated, | 1224 validated_params.url, frame_tree_node_, is_renderer_initiated, |
1222 true, // is_synchronous | 1225 validated_params.was_within_same_page, validated_params.is_srcdoc, |
1223 validated_params.is_srcdoc, base::TimeTicks::Now(), | 1226 base::TimeTicks::Now(), entry_id_for_data_nav, |
1224 entry_id_for_data_nav, | |
1225 false); // started_from_context_menu | 1227 false); // started_from_context_menu |
1226 // PlzNavigate | 1228 // PlzNavigate |
1227 if (IsBrowserSideNavigationEnabled()) { | 1229 if (IsBrowserSideNavigationEnabled()) { |
1228 // PlzNavigate: synchronous loads happen in the renderer, and the browser | 1230 // PlzNavigate: synchronous loads happen in the renderer, and the browser |
1229 // has not been notified about the start of the load yet. Do it now. | 1231 // has not been notified about the start of the load yet. Do it now. |
1230 if (!is_loading()) { | 1232 if (!is_loading()) { |
1231 bool was_loading = frame_tree_node()->frame_tree()->IsLoading(); | 1233 bool was_loading = frame_tree_node()->frame_tree()->IsLoading(); |
1232 is_loading_ = true; | 1234 is_loading_ = true; |
1233 frame_tree_node()->DidStartLoading(true, was_loading); | 1235 frame_tree_node()->DidStartLoading(true, was_loading); |
1234 } | 1236 } |
(...skipping 1914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3149 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind( | 3151 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind( |
3150 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this))); | 3152 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this))); |
3151 return web_bluetooth_service_.get(); | 3153 return web_bluetooth_service_.get(); |
3152 } | 3154 } |
3153 | 3155 |
3154 void RenderFrameHostImpl::DeleteWebBluetoothService() { | 3156 void RenderFrameHostImpl::DeleteWebBluetoothService() { |
3155 web_bluetooth_service_.reset(); | 3157 web_bluetooth_service_.reset(); |
3156 } | 3158 } |
3157 | 3159 |
3158 } // namespace content | 3160 } // namespace content |
OLD | NEW |