Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(476)

Side by Side Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 2345053006: Remove IsSynchronous API from NavigationHandle. (Closed)
Patch Set: Rebase. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 process->FilterURL(true, &validated_params.searchable_form_url); 1167 process->FilterURL(true, &validated_params.searchable_form_url);
1168 1168
1169 // Without this check, the renderer can trick the browser into using 1169 // Without this check, the renderer can trick the browser into using
1170 // filenames it can't access in a future session restore. 1170 // filenames it can't access in a future session restore.
1171 if (!CanAccessFilesOfPageState(validated_params.page_state)) { 1171 if (!CanAccessFilesOfPageState(validated_params.page_state)) {
1172 bad_message::ReceivedBadMessage( 1172 bad_message::ReceivedBadMessage(
1173 GetProcess(), bad_message::RFH_CAN_ACCESS_FILES_OF_PAGE_STATE); 1173 GetProcess(), bad_message::RFH_CAN_ACCESS_FILES_OF_PAGE_STATE);
1174 return; 1174 return;
1175 } 1175 }
1176 1176
1177 // If the URL does not match what the NavigationHandle expects, treat the 1177 // If the URL or |was_within_same_page| does not match what the
1178 // commit as a new navigation. This can happen if an ongoing slow 1178 // NavigationHandle expects, treat the commit as a new navigation. This can
1179 // same-process navigation is interrupted by a synchronous renderer-initiated 1179 // happen if an ongoing slow same-process navigation is interwoven by a
Charlie Reis 2016/09/20 23:35:24 nit: interwoven with
nasko 2016/10/27 17:26:59 Done.
1180 // navigation. 1180 // synchronous renderer-initiated navigation.
1181 // TODO(csharrison): Data navigations loaded with LoadDataWithBaseURL get 1181 // TODO(csharrison): Data navigations loaded with LoadDataWithBaseURL get
1182 // reset here, because the NavigationHandle tracks the URL but the 1182 // reset here, because the NavigationHandle tracks the URL but the
1183 // validated_params.url tracks the data. The trick of saving the old entry ids 1183 // validated_params.url tracks the data. The trick of saving the old entry ids
1184 // for these navigations should go away when this is properly handled. See 1184 // for these navigations should go away when this is properly handled. See
1185 // crbug.com/588317. 1185 // crbug.com/588317.
1186 int entry_id_for_data_nav = 0; 1186 int entry_id_for_data_nav = 0;
1187 bool is_renderer_initiated = true; 1187 bool is_renderer_initiated = true;
1188 if (navigation_handle_ && 1188 if (navigation_handle_ &&
1189 (navigation_handle_->GetURL() != validated_params.url)) { 1189 ((navigation_handle_->GetURL() != validated_params.url) ||
1190 navigation_handle_->IsSamePage() !=
1191 validated_params.was_within_same_page)) {
1190 // Make sure that the pending entry was really loaded via 1192 // Make sure that the pending entry was really loaded via
1191 // LoadDataWithBaseURL and that it matches this handle. 1193 // LoadDataWithBaseURL and that it matches this handle.
1192 NavigationEntryImpl* pending_entry = 1194 NavigationEntryImpl* pending_entry =
1193 NavigationEntryImpl::FromNavigationEntry( 1195 NavigationEntryImpl::FromNavigationEntry(
1194 frame_tree_node()->navigator()->GetController()->GetPendingEntry()); 1196 frame_tree_node()->navigator()->GetController()->GetPendingEntry());
1195 bool pending_entry_matches_handle = 1197 bool pending_entry_matches_handle =
1196 pending_entry && 1198 pending_entry &&
1197 pending_entry->GetUniqueID() == 1199 pending_entry->GetUniqueID() ==
1198 navigation_handle_->pending_nav_entry_id(); 1200 navigation_handle_->pending_nav_entry_id();
1199 // TODO(csharrison): The pending entry's base url should equal 1201 // TODO(csharrison): The pending entry's base url should equal
1200 // |validated_params.base_url|. This is not the case for loads with invalid 1202 // |validated_params.base_url|. This is not the case for loads with invalid
1201 // base urls. 1203 // base urls.
1202 if (navigation_handle_->GetURL() == validated_params.base_url && 1204 if (navigation_handle_->GetURL() == validated_params.base_url &&
1203 pending_entry_matches_handle && 1205 pending_entry_matches_handle &&
1204 !pending_entry->GetBaseURLForDataURL().is_empty()) { 1206 !pending_entry->GetBaseURLForDataURL().is_empty()) {
1205 entry_id_for_data_nav = navigation_handle_->pending_nav_entry_id(); 1207 entry_id_for_data_nav = navigation_handle_->pending_nav_entry_id();
1206 is_renderer_initiated = pending_entry->is_renderer_initiated(); 1208 is_renderer_initiated = pending_entry->is_renderer_initiated();
1207 } 1209 }
1208 navigation_handle_.reset(); 1210 navigation_handle_.reset();
1209 } 1211 }
1210 1212
1211 // Synchronous renderer-initiated navigations will send a 1213 // Synchronous renderer-initiated navigations will send a
1212 // DidCommitProvisionalLoad IPC without a prior DidStartProvisionalLoad 1214 // DidCommitProvisionalLoad IPC without a prior DidStartProvisionalLoad
1213 // message. 1215 // message. Or in addition, the if block above can reset the NavigationHandle
1216 // in cases it doesn't match the expected commit.
1214 if (!navigation_handle_) { 1217 if (!navigation_handle_) {
1215 // There is no pending NavigationEntry in these cases, so pass 0 as the 1218 // There is no pending NavigationEntry in these cases, so pass 0 as the
1216 // nav_id. If the previous handle was a prematurely aborted navigation 1219 // nav_id. If the previous handle was a prematurely aborted navigation
1217 // loaded via LoadDataWithBaseURL, propogate the entry id. 1220 // loaded via LoadDataWithBaseURL, propogate the entry id.
1218 navigation_handle_ = NavigationHandleImpl::Create( 1221 navigation_handle_ = NavigationHandleImpl::Create(
1219 validated_params.url, frame_tree_node_, 1222 validated_params.url, frame_tree_node_, is_renderer_initiated,
1220 is_renderer_initiated, 1223 validated_params.was_within_same_page, validated_params.is_srcdoc,
Charlie Reis 2016/09/20 23:35:24 I agree with clamy@ that this can technically not
nasko 2016/10/27 17:26:59 Acknowledged.
1221 true, // is_synchronous 1224 base::TimeTicks::Now(), entry_id_for_data_nav);
1222 validated_params.is_srcdoc, base::TimeTicks::Now(),
1223 entry_id_for_data_nav);
1224 // PlzNavigate 1225 // PlzNavigate
1225 if (IsBrowserSideNavigationEnabled()) { 1226 if (IsBrowserSideNavigationEnabled()) {
1226 // PlzNavigate: synchronous loads happen in the renderer, and the browser 1227 // PlzNavigate: synchronous loads happen in the renderer, and the browser
1227 // has not been notified about the start of the load yet. Do it now. 1228 // has not been notified about the start of the load yet. Do it now.
1228 if (!is_loading()) { 1229 if (!is_loading()) {
1229 bool was_loading = frame_tree_node()->frame_tree()->IsLoading(); 1230 bool was_loading = frame_tree_node()->frame_tree()->IsLoading();
1230 is_loading_ = true; 1231 is_loading_ = true;
1231 frame_tree_node()->DidStartLoading(true, was_loading); 1232 frame_tree_node()->DidStartLoading(true, was_loading);
1232 } 1233 }
1233 pending_commit_ = false; 1234 pending_commit_ = false;
(...skipping 1866 matching lines...) Expand 10 before | Expand all | Expand 10 after
3100 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind( 3101 web_bluetooth_service_->SetClientConnectionErrorHandler(base::Bind(
3101 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this))); 3102 &RenderFrameHostImpl::DeleteWebBluetoothService, base::Unretained(this)));
3102 return web_bluetooth_service_.get(); 3103 return web_bluetooth_service_.get();
3103 } 3104 }
3104 3105
3105 void RenderFrameHostImpl::DeleteWebBluetoothService() { 3106 void RenderFrameHostImpl::DeleteWebBluetoothService() {
3106 web_bluetooth_service_.reset(); 3107 web_bluetooth_service_.reset();
3107 } 3108 }
3108 3109
3109 } // namespace content 3110 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698