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

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 1672373002: Don't rely on the pending NavigationEntry for location.replace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix bug numbers Created 4 years, 10 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
« no previous file with comments | « content/common/frame_messages.h ('k') | content/test/test_render_frame_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/renderer/render_frame_impl.h" 5 #include "content/renderer/render_frame_impl.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 3773 matching lines...) Expand 10 before | Expand all | Expand 10 after
3784 // Attach |should_replace_current_entry| state to requests so that, should 3784 // Attach |should_replace_current_entry| state to requests so that, should
3785 // this navigation later require a request transfer, all state is preserved 3785 // this navigation later require a request transfer, all state is preserved
3786 // when it is re-created in the new process. 3786 // when it is re-created in the new process.
3787 bool should_replace_current_entry = false; 3787 bool should_replace_current_entry = false;
3788 if (navigation_state->IsContentInitiated()) { 3788 if (navigation_state->IsContentInitiated()) {
3789 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); 3789 should_replace_current_entry = data_source->replacesCurrentHistoryItem();
3790 } else { 3790 } else {
3791 // If the navigation is browser-initiated, the NavigationState contains the 3791 // If the navigation is browser-initiated, the NavigationState contains the
3792 // correct value instead of the WebDataSource. 3792 // correct value instead of the WebDataSource.
3793 // 3793 //
3794 // TODO(davidben): Avoid this awkward duplication of state. See comment on 3794 // TODO(creis): Remove should_replace_current_entry from NavigationState
3795 // NavigationState::should_replace_current_entry(). 3795 // once we verify this is a safe change.
3796 should_replace_current_entry = 3796 CHECK(!navigation_state->common_params().should_replace_current_entry ||
3797 navigation_state->common_params().should_replace_current_entry; 3797 data_source->replacesCurrentHistoryItem());
3798 should_replace_current_entry = data_source->replacesCurrentHistoryItem();
3798 } 3799 }
3799 3800
3800 int provider_id = kInvalidServiceWorkerProviderId; 3801 int provider_id = kInvalidServiceWorkerProviderId;
3801 if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel || 3802 if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel ||
3802 request.frameType() == blink::WebURLRequest::FrameTypeNested) { 3803 request.frameType() == blink::WebURLRequest::FrameTypeNested) {
3803 // |provisionalDataSource| may be null in some content::ResourceFetcher 3804 // |provisionalDataSource| may be null in some content::ResourceFetcher
3804 // use cases, we don't hook those requests. 3805 // use cases, we don't hook those requests.
3805 if (frame->provisionalDataSource()) { 3806 if (frame->provisionalDataSource()) {
3806 ServiceWorkerNetworkProvider* provider = 3807 ServiceWorkerNetworkProvider* provider =
3807 ServiceWorkerNetworkProvider::FromDocumentState( 3808 ServiceWorkerNetworkProvider::FromDocumentState(
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
4445 InternalDocumentStateData* internal_data = 4446 InternalDocumentStateData* internal_data =
4446 InternalDocumentStateData::FromDocumentState(document_state); 4447 InternalDocumentStateData::FromDocumentState(document_state);
4447 4448
4448 FrameHostMsg_DidCommitProvisionalLoad_Params params; 4449 FrameHostMsg_DidCommitProvisionalLoad_Params params;
4449 params.http_status_code = response.httpStatusCode(); 4450 params.http_status_code = response.httpStatusCode();
4450 params.url_is_unreachable = ds->hasUnreachableURL(); 4451 params.url_is_unreachable = ds->hasUnreachableURL();
4451 params.is_post = false; 4452 params.is_post = false;
4452 params.intended_as_new_entry = 4453 params.intended_as_new_entry =
4453 navigation_state->request_params().intended_as_new_entry; 4454 navigation_state->request_params().intended_as_new_entry;
4454 params.did_create_new_entry = commit_type == blink::WebStandardCommit; 4455 params.did_create_new_entry = commit_type == blink::WebStandardCommit;
4456 params.should_replace_current_entry = ds->replacesCurrentHistoryItem();
4455 params.post_id = -1; 4457 params.post_id = -1;
4456 params.page_id = render_view_->page_id_; 4458 params.page_id = render_view_->page_id_;
4457 params.nav_entry_id = navigation_state->request_params().nav_entry_id; 4459 params.nav_entry_id = navigation_state->request_params().nav_entry_id;
4458 // We need to track the RenderViewHost routing_id because of downstream 4460 // We need to track the RenderViewHost routing_id because of downstream
4459 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, 4461 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager,
4460 // ResourceDispatcherHostImpl, MediaStreamUIProxy, 4462 // ResourceDispatcherHostImpl, MediaStreamUIProxy,
4461 // SpeechRecognitionDispatcherHost and possibly others). They look up the view 4463 // SpeechRecognitionDispatcherHost and possibly others). They look up the view
4462 // based on the ID stored in the resource requests. Once those dependencies 4464 // based on the ID stored in the resource requests. Once those dependencies
4463 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the 4465 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the
4464 // client to be based on the routing_id of the RenderFrameHost. 4466 // client to be based on the routing_id of the RenderFrameHost.
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
5259 bool is_history_navigation_in_new_child) { 5261 bool is_history_navigation_in_new_child) {
5260 FrameHostMsg_OpenURL_Params params; 5262 FrameHostMsg_OpenURL_Params params;
5261 params.url = url; 5263 params.url = url;
5262 params.referrer = referrer; 5264 params.referrer = referrer;
5263 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); 5265 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy);
5264 5266
5265 if (IsBrowserInitiated(pending_navigation_params_.get())) { 5267 if (IsBrowserInitiated(pending_navigation_params_.get())) {
5266 // This is necessary to preserve the should_replace_current_entry value on 5268 // This is necessary to preserve the should_replace_current_entry value on
5267 // cross-process redirects, in the event it was set by a previous process. 5269 // cross-process redirects, in the event it was set by a previous process.
5268 // 5270 //
5269 // TODO(davidben): Avoid this awkward duplication of state. See comment on 5271 // TODO(creis): Remove should_replace_current_entry from NavigationState
5270 // NavigationState::should_replace_current_entry(). 5272 // once we verify this is correct, since the WebDataSource should now be
5271 params.should_replace_current_entry = 5273 // correct.
5272 pending_navigation_params_->common_params.should_replace_current_entry; 5274 WebDataSource* ds = frame_->provisionalDataSource();
5275 CHECK(ds);
5276 DocumentState* document_state = DocumentState::FromDataSource(ds);
5277 NavigationStateImpl* navigation_state =
5278 static_cast<NavigationStateImpl*>(document_state->navigation_state());
5279 CHECK_EQ(navigation_state->common_params().should_replace_current_entry,
5280 ds->replacesCurrentHistoryItem());
5281 params.should_replace_current_entry = ds->replacesCurrentHistoryItem();
5273 } else { 5282 } else {
5274 params.should_replace_current_entry = 5283 params.should_replace_current_entry =
5275 should_replace_current_entry && render_view_->history_list_length_; 5284 should_replace_current_entry && render_view_->history_list_length_;
5276 } 5285 }
5277 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); 5286 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture();
5278 if (GetContentClient()->renderer()->AllowPopup()) 5287 if (GetContentClient()->renderer()->AllowPopup())
5279 params.user_gesture = true; 5288 params.user_gesture = true;
5280 5289
5281 if (policy == blink::WebNavigationPolicyNewBackgroundTab || 5290 if (policy == blink::WebNavigationPolicyNewBackgroundTab ||
5282 policy == blink::WebNavigationPolicyNewForegroundTab || 5291 policy == blink::WebNavigationPolicyNewForegroundTab ||
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
5339 new NavigationParams(common_params, start_params, request_params)); 5348 new NavigationParams(common_params, start_params, request_params));
5340 5349
5341 // Unless the load is a WebFrameLoadType::Standard, this should remain 5350 // Unless the load is a WebFrameLoadType::Standard, this should remain
5342 // uninitialized. It will be updated when the load type is determined to be 5351 // uninitialized. It will be updated when the load type is determined to be
5343 // Standard, or after the previous document's unload handler has been 5352 // Standard, or after the previous document's unload handler has been
5344 // triggered. This occurs in UpdateNavigationState. 5353 // triggered. This occurs in UpdateNavigationState.
5345 // TODO(csharrison) See if we can always use the browser timestamp. 5354 // TODO(csharrison) See if we can always use the browser timestamp.
5346 pending_navigation_params_->common_params.navigation_start = 5355 pending_navigation_params_->common_params.navigation_start =
5347 base::TimeTicks(); 5356 base::TimeTicks();
5348 5357
5349 // Create parameters for a standard navigation. 5358 // Create parameters for a standard navigation, indicating whether it should
5350 blink::WebFrameLoadType load_type = blink::WebFrameLoadType::Standard; 5359 // replace the current NavigationEntry.
5360 blink::WebFrameLoadType load_type =
5361 common_params.should_replace_current_entry
5362 ? blink::WebFrameLoadType::ReplaceCurrentItem
5363 : blink::WebFrameLoadType::Standard;
5351 blink::WebHistoryLoadType history_load_type = 5364 blink::WebHistoryLoadType history_load_type =
5352 blink::WebHistoryDifferentDocumentLoad; 5365 blink::WebHistoryDifferentDocumentLoad;
5353 bool should_load_request = false; 5366 bool should_load_request = false;
5354 WebHistoryItem item_for_history_navigation; 5367 WebHistoryItem item_for_history_navigation;
5355 WebURLRequest request = 5368 WebURLRequest request =
5356 CreateURLRequestForNavigation(common_params, std::move(stream_params), 5369 CreateURLRequestForNavigation(common_params, std::move(stream_params),
5357 frame_->isViewSourceModeEnabled()); 5370 frame_->isViewSourceModeEnabled());
5358 #if defined(OS_ANDROID) 5371 #if defined(OS_ANDROID)
5359 request.setHasUserGesture(start_params.has_user_gesture); 5372 request.setHasUserGesture(start_params.has_user_gesture);
5360 #endif 5373 #endif
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
5467 5480
5468 should_load_request = true; 5481 should_load_request = true;
5469 } 5482 }
5470 5483
5471 if (should_load_request) { 5484 if (should_load_request) {
5472 // Sanitize navigation start now that we know the load_type. 5485 // Sanitize navigation start now that we know the load_type.
5473 pending_navigation_params_->common_params.navigation_start = 5486 pending_navigation_params_->common_params.navigation_start =
5474 SanitizeNavigationTiming(load_type, common_params.navigation_start, 5487 SanitizeNavigationTiming(load_type, common_params.navigation_start,
5475 renderer_navigation_start); 5488 renderer_navigation_start);
5476 5489
5477 // PlzNavigate: Check if the load should replace the current item.
5478 // TODO(clamy): Remove this when
5479 // https://codereview.chromium.org/1250163002/ lands and makes it default
5480 // for the current architecture.
5481 if (browser_side_navigation && common_params.should_replace_current_entry) {
5482 DCHECK(load_type == blink::WebFrameLoadType::Standard);
5483 load_type = blink::WebFrameLoadType::ReplaceCurrentItem;
5484 }
5485
5486 // Perform a navigation to a data url if needed. 5490 // Perform a navigation to a data url if needed.
5487 if (!common_params.base_url_for_data_url.is_empty() || 5491 if (!common_params.base_url_for_data_url.is_empty() ||
5488 (browser_side_navigation && 5492 (browser_side_navigation &&
5489 common_params.url.SchemeIs(url::kDataScheme))) { 5493 common_params.url.SchemeIs(url::kDataScheme))) {
5490 LoadDataURL(common_params, request_params, frame_, load_type); 5494 LoadDataURL(common_params, request_params, frame_, load_type);
5491 } else { 5495 } else {
5492 // PlzNavigate: check if the navigation being committed originated as a 5496 // PlzNavigate: check if the navigation being committed originated as a
5493 // client redirect. 5497 // client redirect.
5494 bool is_client_redirect = browser_side_navigation 5498 bool is_client_redirect = browser_side_navigation
5495 ? !!(common_params.transition & 5499 ? !!(common_params.transition &
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
6108 int match_count, 6112 int match_count,
6109 int ordinal, 6113 int ordinal,
6110 const WebRect& selection_rect, 6114 const WebRect& selection_rect,
6111 bool final_status_update) { 6115 bool final_status_update) {
6112 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, 6116 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count,
6113 selection_rect, ordinal, 6117 selection_rect, ordinal,
6114 final_status_update)); 6118 final_status_update));
6115 } 6119 }
6116 6120
6117 } // namespace content 6121 } // namespace content
OLDNEW
« no previous file with comments | « content/common/frame_messages.h ('k') | content/test/test_render_frame_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698