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

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

Issue 1679383002: Revert of Don't rely on the pending NavigationEntry for location.replace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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 3798 matching lines...) Expand 10 before | Expand all | Expand 10 after
3809 // Attach |should_replace_current_entry| state to requests so that, should 3809 // Attach |should_replace_current_entry| state to requests so that, should
3810 // this navigation later require a request transfer, all state is preserved 3810 // this navigation later require a request transfer, all state is preserved
3811 // when it is re-created in the new process. 3811 // when it is re-created in the new process.
3812 bool should_replace_current_entry = false; 3812 bool should_replace_current_entry = false;
3813 if (navigation_state->IsContentInitiated()) { 3813 if (navigation_state->IsContentInitiated()) {
3814 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); 3814 should_replace_current_entry = data_source->replacesCurrentHistoryItem();
3815 } else { 3815 } else {
3816 // If the navigation is browser-initiated, the NavigationState contains the 3816 // If the navigation is browser-initiated, the NavigationState contains the
3817 // correct value instead of the WebDataSource. 3817 // correct value instead of the WebDataSource.
3818 // 3818 //
3819 // TODO(creis): Remove should_replace_current_entry from NavigationState 3819 // TODO(davidben): Avoid this awkward duplication of state. See comment on
3820 // once we verify this is a safe change. 3820 // NavigationState::should_replace_current_entry().
3821 CHECK(!navigation_state->common_params().should_replace_current_entry || 3821 should_replace_current_entry =
3822 data_source->replacesCurrentHistoryItem()); 3822 navigation_state->common_params().should_replace_current_entry;
3823 should_replace_current_entry = data_source->replacesCurrentHistoryItem();
3824 } 3823 }
3825 3824
3826 int provider_id = kInvalidServiceWorkerProviderId; 3825 int provider_id = kInvalidServiceWorkerProviderId;
3827 if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel || 3826 if (request.frameType() == blink::WebURLRequest::FrameTypeTopLevel ||
3828 request.frameType() == blink::WebURLRequest::FrameTypeNested) { 3827 request.frameType() == blink::WebURLRequest::FrameTypeNested) {
3829 // |provisionalDataSource| may be null in some content::ResourceFetcher 3828 // |provisionalDataSource| may be null in some content::ResourceFetcher
3830 // use cases, we don't hook those requests. 3829 // use cases, we don't hook those requests.
3831 if (frame->provisionalDataSource()) { 3830 if (frame->provisionalDataSource()) {
3832 ServiceWorkerNetworkProvider* provider = 3831 ServiceWorkerNetworkProvider* provider =
3833 ServiceWorkerNetworkProvider::FromDocumentState( 3832 ServiceWorkerNetworkProvider::FromDocumentState(
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
4471 InternalDocumentStateData* internal_data = 4470 InternalDocumentStateData* internal_data =
4472 InternalDocumentStateData::FromDocumentState(document_state); 4471 InternalDocumentStateData::FromDocumentState(document_state);
4473 4472
4474 FrameHostMsg_DidCommitProvisionalLoad_Params params; 4473 FrameHostMsg_DidCommitProvisionalLoad_Params params;
4475 params.http_status_code = response.httpStatusCode(); 4474 params.http_status_code = response.httpStatusCode();
4476 params.url_is_unreachable = ds->hasUnreachableURL(); 4475 params.url_is_unreachable = ds->hasUnreachableURL();
4477 params.is_post = false; 4476 params.is_post = false;
4478 params.intended_as_new_entry = 4477 params.intended_as_new_entry =
4479 navigation_state->request_params().intended_as_new_entry; 4478 navigation_state->request_params().intended_as_new_entry;
4480 params.did_create_new_entry = commit_type == blink::WebStandardCommit; 4479 params.did_create_new_entry = commit_type == blink::WebStandardCommit;
4481 params.should_replace_current_entry = ds->replacesCurrentHistoryItem();
4482 params.post_id = -1; 4480 params.post_id = -1;
4483 params.page_id = render_view_->page_id_; 4481 params.page_id = render_view_->page_id_;
4484 params.nav_entry_id = navigation_state->request_params().nav_entry_id; 4482 params.nav_entry_id = navigation_state->request_params().nav_entry_id;
4485 // We need to track the RenderViewHost routing_id because of downstream 4483 // We need to track the RenderViewHost routing_id because of downstream
4486 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, 4484 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager,
4487 // ResourceDispatcherHostImpl, MediaStreamUIProxy, 4485 // ResourceDispatcherHostImpl, MediaStreamUIProxy,
4488 // SpeechRecognitionDispatcherHost and possibly others). They look up the view 4486 // SpeechRecognitionDispatcherHost and possibly others). They look up the view
4489 // based on the ID stored in the resource requests. Once those dependencies 4487 // based on the ID stored in the resource requests. Once those dependencies
4490 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the 4488 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the
4491 // client to be based on the routing_id of the RenderFrameHost. 4489 // client to be based on the routing_id of the RenderFrameHost.
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
5286 bool is_history_navigation_in_new_child) { 5284 bool is_history_navigation_in_new_child) {
5287 FrameHostMsg_OpenURL_Params params; 5285 FrameHostMsg_OpenURL_Params params;
5288 params.url = url; 5286 params.url = url;
5289 params.referrer = referrer; 5287 params.referrer = referrer;
5290 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); 5288 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy);
5291 5289
5292 if (IsBrowserInitiated(pending_navigation_params_.get())) { 5290 if (IsBrowserInitiated(pending_navigation_params_.get())) {
5293 // This is necessary to preserve the should_replace_current_entry value on 5291 // This is necessary to preserve the should_replace_current_entry value on
5294 // cross-process redirects, in the event it was set by a previous process. 5292 // cross-process redirects, in the event it was set by a previous process.
5295 // 5293 //
5296 // TODO(creis): Remove should_replace_current_entry from NavigationState 5294 // TODO(davidben): Avoid this awkward duplication of state. See comment on
5297 // once we verify this is correct, since the WebDataSource should now be 5295 // NavigationState::should_replace_current_entry().
5298 // correct. 5296 params.should_replace_current_entry =
5299 WebDataSource* ds = frame_->provisionalDataSource(); 5297 pending_navigation_params_->common_params.should_replace_current_entry;
5300 CHECK(ds);
5301 DocumentState* document_state = DocumentState::FromDataSource(ds);
5302 NavigationStateImpl* navigation_state =
5303 static_cast<NavigationStateImpl*>(document_state->navigation_state());
5304 CHECK_EQ(navigation_state->common_params().should_replace_current_entry,
5305 ds->replacesCurrentHistoryItem());
5306 params.should_replace_current_entry = ds->replacesCurrentHistoryItem();
5307 } else { 5298 } else {
5308 params.should_replace_current_entry = 5299 params.should_replace_current_entry =
5309 should_replace_current_entry && render_view_->history_list_length_; 5300 should_replace_current_entry && render_view_->history_list_length_;
5310 } 5301 }
5311 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); 5302 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture();
5312 if (GetContentClient()->renderer()->AllowPopup()) 5303 if (GetContentClient()->renderer()->AllowPopup())
5313 params.user_gesture = true; 5304 params.user_gesture = true;
5314 5305
5315 if (policy == blink::WebNavigationPolicyNewBackgroundTab || 5306 if (policy == blink::WebNavigationPolicyNewBackgroundTab ||
5316 policy == blink::WebNavigationPolicyNewForegroundTab || 5307 policy == blink::WebNavigationPolicyNewForegroundTab ||
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
5373 new NavigationParams(common_params, start_params, request_params)); 5364 new NavigationParams(common_params, start_params, request_params));
5374 5365
5375 // Unless the load is a WebFrameLoadType::Standard, this should remain 5366 // Unless the load is a WebFrameLoadType::Standard, this should remain
5376 // uninitialized. It will be updated when the load type is determined to be 5367 // uninitialized. It will be updated when the load type is determined to be
5377 // Standard, or after the previous document's unload handler has been 5368 // Standard, or after the previous document's unload handler has been
5378 // triggered. This occurs in UpdateNavigationState. 5369 // triggered. This occurs in UpdateNavigationState.
5379 // TODO(csharrison) See if we can always use the browser timestamp. 5370 // TODO(csharrison) See if we can always use the browser timestamp.
5380 pending_navigation_params_->common_params.navigation_start = 5371 pending_navigation_params_->common_params.navigation_start =
5381 base::TimeTicks(); 5372 base::TimeTicks();
5382 5373
5383 // Create parameters for a standard navigation, indicating whether it should 5374 // Create parameters for a standard navigation.
5384 // replace the current NavigationEntry. 5375 blink::WebFrameLoadType load_type = blink::WebFrameLoadType::Standard;
5385 blink::WebFrameLoadType load_type =
5386 common_params.should_replace_current_entry
5387 ? blink::WebFrameLoadType::ReplaceCurrentItem
5388 : blink::WebFrameLoadType::Standard;
5389 blink::WebHistoryLoadType history_load_type = 5376 blink::WebHistoryLoadType history_load_type =
5390 blink::WebHistoryDifferentDocumentLoad; 5377 blink::WebHistoryDifferentDocumentLoad;
5391 bool should_load_request = false; 5378 bool should_load_request = false;
5392 WebHistoryItem item_for_history_navigation; 5379 WebHistoryItem item_for_history_navigation;
5393 WebURLRequest request = 5380 WebURLRequest request =
5394 CreateURLRequestForNavigation(common_params, std::move(stream_params), 5381 CreateURLRequestForNavigation(common_params, std::move(stream_params),
5395 frame_->isViewSourceModeEnabled()); 5382 frame_->isViewSourceModeEnabled());
5396 #if defined(OS_ANDROID) 5383 #if defined(OS_ANDROID)
5397 request.setHasUserGesture(start_params.has_user_gesture); 5384 request.setHasUserGesture(start_params.has_user_gesture);
5398 #endif 5385 #endif
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
5505 5492
5506 should_load_request = true; 5493 should_load_request = true;
5507 } 5494 }
5508 5495
5509 if (should_load_request) { 5496 if (should_load_request) {
5510 // Sanitize navigation start now that we know the load_type. 5497 // Sanitize navigation start now that we know the load_type.
5511 pending_navigation_params_->common_params.navigation_start = 5498 pending_navigation_params_->common_params.navigation_start =
5512 SanitizeNavigationTiming(load_type, common_params.navigation_start, 5499 SanitizeNavigationTiming(load_type, common_params.navigation_start,
5513 renderer_navigation_start); 5500 renderer_navigation_start);
5514 5501
5502 // PlzNavigate: Check if the load should replace the current item.
5503 // TODO(clamy): Remove this when
5504 // https://codereview.chromium.org/1250163002/ lands and makes it default
5505 // for the current architecture.
5506 if (browser_side_navigation && common_params.should_replace_current_entry) {
5507 DCHECK(load_type == blink::WebFrameLoadType::Standard);
5508 load_type = blink::WebFrameLoadType::ReplaceCurrentItem;
5509 }
5510
5515 // Perform a navigation to a data url if needed. 5511 // Perform a navigation to a data url if needed.
5516 if (!common_params.base_url_for_data_url.is_empty() || 5512 if (!common_params.base_url_for_data_url.is_empty() ||
5517 (browser_side_navigation && 5513 (browser_side_navigation &&
5518 common_params.url.SchemeIs(url::kDataScheme))) { 5514 common_params.url.SchemeIs(url::kDataScheme))) {
5519 LoadDataURL(common_params, request_params, frame_, load_type); 5515 LoadDataURL(common_params, request_params, frame_, load_type);
5520 } else { 5516 } else {
5521 // PlzNavigate: check if the navigation being committed originated as a 5517 // PlzNavigate: check if the navigation being committed originated as a
5522 // client redirect. 5518 // client redirect.
5523 bool is_client_redirect = browser_side_navigation 5519 bool is_client_redirect = browser_side_navigation
5524 ? !!(common_params.transition & 5520 ? !!(common_params.transition &
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
6129 int match_count, 6125 int match_count,
6130 int ordinal, 6126 int ordinal,
6131 const WebRect& selection_rect, 6127 const WebRect& selection_rect,
6132 bool final_status_update) { 6128 bool final_status_update) {
6133 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, 6129 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count,
6134 selection_rect, ordinal, 6130 selection_rect, ordinal,
6135 final_status_update)); 6131 final_status_update));
6136 } 6132 }
6137 6133
6138 } // namespace content 6134 } // 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