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/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 3780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3791 WebString::fromUTF8(kDefaultAcceptHeader)); | 3791 WebString::fromUTF8(kDefaultAcceptHeader)); |
3792 } | 3792 } |
3793 | 3793 |
3794 // Add an empty HTTP origin header for non GET methods if none is currently | 3794 // Add an empty HTTP origin header for non GET methods if none is currently |
3795 // present. | 3795 // present. |
3796 request.addHTTPOriginIfNeeded(WebString()); | 3796 request.addHTTPOriginIfNeeded(WebString()); |
3797 | 3797 |
3798 // Attach |should_replace_current_entry| state to requests so that, should | 3798 // Attach |should_replace_current_entry| state to requests so that, should |
3799 // this navigation later require a request transfer, all state is preserved | 3799 // this navigation later require a request transfer, all state is preserved |
3800 // when it is re-created in the new process. | 3800 // when it is re-created in the new process. |
3801 bool should_replace_current_entry = false; | 3801 bool should_replace_current_entry = data_source->replacesCurrentHistoryItem(); |
3802 if (navigation_state->IsContentInitiated()) { | |
3803 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); | |
3804 } else { | |
3805 // If the navigation is browser-initiated, the NavigationState contains the | |
3806 // correct value instead of the WebDataSource. | |
3807 // | |
3808 // TODO(davidben): Avoid this awkward duplication of state. See comment on | |
3809 // NavigationState::should_replace_current_entry(). | |
3810 should_replace_current_entry = | |
3811 navigation_state->common_params().should_replace_current_entry; | |
3812 } | |
3813 | 3802 |
3814 int provider_id = kInvalidServiceWorkerProviderId; | 3803 int provider_id = kInvalidServiceWorkerProviderId; |
3815 if (request.getFrameType() == blink::WebURLRequest::FrameTypeTopLevel || | 3804 if (request.getFrameType() == blink::WebURLRequest::FrameTypeTopLevel || |
3816 request.getFrameType() == blink::WebURLRequest::FrameTypeNested) { | 3805 request.getFrameType() == blink::WebURLRequest::FrameTypeNested) { |
3817 // |provisionalDataSource| may be null in some content::ResourceFetcher | 3806 // |provisionalDataSource| may be null in some content::ResourceFetcher |
3818 // use cases, we don't hook those requests. | 3807 // use cases, we don't hook those requests. |
3819 if (frame->provisionalDataSource()) { | 3808 if (frame->provisionalDataSource()) { |
3820 ServiceWorkerNetworkProvider* provider = | 3809 ServiceWorkerNetworkProvider* provider = |
3821 ServiceWorkerNetworkProvider::FromDocumentState( | 3810 ServiceWorkerNetworkProvider::FromDocumentState( |
3822 DocumentState::FromDataSource(frame->provisionalDataSource())); | 3811 DocumentState::FromDataSource(frame->provisionalDataSource())); |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4443 InternalDocumentStateData* internal_data = | 4432 InternalDocumentStateData* internal_data = |
4444 InternalDocumentStateData::FromDocumentState(document_state); | 4433 InternalDocumentStateData::FromDocumentState(document_state); |
4445 | 4434 |
4446 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 4435 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
4447 params.http_status_code = response.httpStatusCode(); | 4436 params.http_status_code = response.httpStatusCode(); |
4448 params.url_is_unreachable = ds->hasUnreachableURL(); | 4437 params.url_is_unreachable = ds->hasUnreachableURL(); |
4449 params.is_post = false; | 4438 params.is_post = false; |
4450 params.intended_as_new_entry = | 4439 params.intended_as_new_entry = |
4451 navigation_state->request_params().intended_as_new_entry; | 4440 navigation_state->request_params().intended_as_new_entry; |
4452 params.did_create_new_entry = commit_type == blink::WebStandardCommit; | 4441 params.did_create_new_entry = commit_type == blink::WebStandardCommit; |
| 4442 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); |
4453 params.post_id = -1; | 4443 params.post_id = -1; |
4454 params.page_id = render_view_->page_id_; | 4444 params.page_id = render_view_->page_id_; |
4455 params.nav_entry_id = navigation_state->request_params().nav_entry_id; | 4445 params.nav_entry_id = navigation_state->request_params().nav_entry_id; |
4456 // We need to track the RenderViewHost routing_id because of downstream | 4446 // We need to track the RenderViewHost routing_id because of downstream |
4457 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, | 4447 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, |
4458 // ResourceDispatcherHostImpl, MediaStreamUIProxy, | 4448 // ResourceDispatcherHostImpl, MediaStreamUIProxy, |
4459 // SpeechRecognitionDispatcherHost and possibly others). They look up the view | 4449 // SpeechRecognitionDispatcherHost and possibly others). They look up the view |
4460 // based on the ID stored in the resource requests. Once those dependencies | 4450 // based on the ID stored in the resource requests. Once those dependencies |
4461 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the | 4451 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the |
4462 // client to be based on the routing_id of the RenderFrameHost. | 4452 // client to be based on the routing_id of the RenderFrameHost. |
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5272 bool should_replace_current_entry, | 5262 bool should_replace_current_entry, |
5273 bool is_history_navigation_in_new_child) { | 5263 bool is_history_navigation_in_new_child) { |
5274 FrameHostMsg_OpenURL_Params params; | 5264 FrameHostMsg_OpenURL_Params params; |
5275 params.url = url; | 5265 params.url = url; |
5276 params.referrer = referrer; | 5266 params.referrer = referrer; |
5277 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); | 5267 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); |
5278 | 5268 |
5279 if (IsBrowserInitiated(pending_navigation_params_.get())) { | 5269 if (IsBrowserInitiated(pending_navigation_params_.get())) { |
5280 // This is necessary to preserve the should_replace_current_entry value on | 5270 // This is necessary to preserve the should_replace_current_entry value on |
5281 // cross-process redirects, in the event it was set by a previous process. | 5271 // cross-process redirects, in the event it was set by a previous process. |
5282 // | 5272 WebDataSource* ds = frame_->provisionalDataSource(); |
5283 // TODO(davidben): Avoid this awkward duplication of state. See comment on | 5273 DCHECK(ds); |
5284 // NavigationState::should_replace_current_entry(). | 5274 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); |
5285 params.should_replace_current_entry = | |
5286 pending_navigation_params_->common_params.should_replace_current_entry; | |
5287 } else { | 5275 } else { |
5288 params.should_replace_current_entry = | 5276 params.should_replace_current_entry = |
5289 should_replace_current_entry && render_view_->history_list_length_; | 5277 should_replace_current_entry && render_view_->history_list_length_; |
5290 } | 5278 } |
5291 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); | 5279 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); |
5292 if (GetContentClient()->renderer()->AllowPopup()) | 5280 if (GetContentClient()->renderer()->AllowPopup()) |
5293 params.user_gesture = true; | 5281 params.user_gesture = true; |
5294 | 5282 |
5295 if (policy == blink::WebNavigationPolicyNewBackgroundTab || | 5283 if (policy == blink::WebNavigationPolicyNewBackgroundTab || |
5296 policy == blink::WebNavigationPolicyNewForegroundTab || | 5284 policy == blink::WebNavigationPolicyNewForegroundTab || |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5353 new NavigationParams(common_params, start_params, request_params)); | 5341 new NavigationParams(common_params, start_params, request_params)); |
5354 | 5342 |
5355 // Unless the load is a WebFrameLoadType::Standard, this should remain | 5343 // Unless the load is a WebFrameLoadType::Standard, this should remain |
5356 // uninitialized. It will be updated when the load type is determined to be | 5344 // uninitialized. It will be updated when the load type is determined to be |
5357 // Standard, or after the previous document's unload handler has been | 5345 // Standard, or after the previous document's unload handler has been |
5358 // triggered. This occurs in UpdateNavigationState. | 5346 // triggered. This occurs in UpdateNavigationState. |
5359 // TODO(csharrison) See if we can always use the browser timestamp. | 5347 // TODO(csharrison) See if we can always use the browser timestamp. |
5360 pending_navigation_params_->common_params.navigation_start = | 5348 pending_navigation_params_->common_params.navigation_start = |
5361 base::TimeTicks(); | 5349 base::TimeTicks(); |
5362 | 5350 |
5363 // Create parameters for a standard navigation. | 5351 // Create parameters for a standard navigation, indicating whether it should |
5364 blink::WebFrameLoadType load_type = blink::WebFrameLoadType::Standard; | 5352 // replace the current NavigationEntry. |
| 5353 blink::WebFrameLoadType load_type = |
| 5354 common_params.should_replace_current_entry |
| 5355 ? blink::WebFrameLoadType::ReplaceCurrentItem |
| 5356 : blink::WebFrameLoadType::Standard; |
5365 blink::WebHistoryLoadType history_load_type = | 5357 blink::WebHistoryLoadType history_load_type = |
5366 blink::WebHistoryDifferentDocumentLoad; | 5358 blink::WebHistoryDifferentDocumentLoad; |
5367 bool should_load_request = false; | 5359 bool should_load_request = false; |
5368 WebHistoryItem item_for_history_navigation; | 5360 WebHistoryItem item_for_history_navigation; |
5369 WebURLRequest request = | 5361 WebURLRequest request = |
5370 CreateURLRequestForNavigation(common_params, std::move(stream_params), | 5362 CreateURLRequestForNavigation(common_params, std::move(stream_params), |
5371 frame_->isViewSourceModeEnabled()); | 5363 frame_->isViewSourceModeEnabled()); |
5372 | 5364 |
5373 // Used to determine whether this frame is actually loading a request as part | 5365 // Used to determine whether this frame is actually loading a request as part |
5374 // of a history navigation. | 5366 // of a history navigation. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5485 | 5477 |
5486 should_load_request = true; | 5478 should_load_request = true; |
5487 } | 5479 } |
5488 | 5480 |
5489 if (should_load_request) { | 5481 if (should_load_request) { |
5490 // Sanitize navigation start now that we know the load_type. | 5482 // Sanitize navigation start now that we know the load_type. |
5491 pending_navigation_params_->common_params.navigation_start = | 5483 pending_navigation_params_->common_params.navigation_start = |
5492 SanitizeNavigationTiming(load_type, common_params.navigation_start, | 5484 SanitizeNavigationTiming(load_type, common_params.navigation_start, |
5493 renderer_navigation_start); | 5485 renderer_navigation_start); |
5494 | 5486 |
5495 // PlzNavigate: Check if the load should replace the current item. | |
5496 // TODO(clamy): Remove this when | |
5497 // https://codereview.chromium.org/1250163002/ lands and makes it default | |
5498 // for the current architecture. | |
5499 if (browser_side_navigation && common_params.should_replace_current_entry) { | |
5500 DCHECK(load_type == blink::WebFrameLoadType::Standard); | |
5501 load_type = blink::WebFrameLoadType::ReplaceCurrentItem; | |
5502 } | |
5503 | |
5504 // PlzNavigate: check if the navigation being committed originated as a | 5487 // PlzNavigate: check if the navigation being committed originated as a |
5505 // client redirect. | 5488 // client redirect. |
5506 bool is_client_redirect = | 5489 bool is_client_redirect = |
5507 browser_side_navigation | 5490 browser_side_navigation |
5508 ? !!(common_params.transition & ui::PAGE_TRANSITION_CLIENT_REDIRECT) | 5491 ? !!(common_params.transition & ui::PAGE_TRANSITION_CLIENT_REDIRECT) |
5509 : false; | 5492 : false; |
5510 | 5493 |
5511 // Perform a navigation to a data url if needed. | 5494 // Perform a navigation to a data url if needed. |
5512 // Note: the base URL might be invalid, so also check the data URL string. | 5495 // Note: the base URL might be invalid, so also check the data URL string. |
5513 if (!common_params.base_url_for_data_url.is_empty() || | 5496 if (!common_params.base_url_for_data_url.is_empty() || |
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6133 int match_count, | 6116 int match_count, |
6134 int ordinal, | 6117 int ordinal, |
6135 const WebRect& selection_rect, | 6118 const WebRect& selection_rect, |
6136 bool final_status_update) { | 6119 bool final_status_update) { |
6137 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, | 6120 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, |
6138 selection_rect, ordinal, | 6121 selection_rect, ordinal, |
6139 final_status_update)); | 6122 final_status_update)); |
6140 } | 6123 } |
6141 | 6124 |
6142 } // namespace content | 6125 } // namespace content |
OLD | NEW |