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 3724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3735 WebString::fromUTF8(kDefaultAcceptHeader)); | 3735 WebString::fromUTF8(kDefaultAcceptHeader)); |
3736 } | 3736 } |
3737 | 3737 |
3738 // Add an empty HTTP origin header for non GET methods if none is currently | 3738 // Add an empty HTTP origin header for non GET methods if none is currently |
3739 // present. | 3739 // present. |
3740 request.addHTTPOriginIfNeeded(WebString()); | 3740 request.addHTTPOriginIfNeeded(WebString()); |
3741 | 3741 |
3742 // Attach |should_replace_current_entry| state to requests so that, should | 3742 // Attach |should_replace_current_entry| state to requests so that, should |
3743 // this navigation later require a request transfer, all state is preserved | 3743 // this navigation later require a request transfer, all state is preserved |
3744 // when it is re-created in the new process. | 3744 // when it is re-created in the new process. |
3745 bool should_replace_current_entry = false; | 3745 bool should_replace_current_entry = data_source->replacesCurrentHistoryItem(); |
3746 if (navigation_state->IsContentInitiated()) { | |
3747 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); | |
3748 } else { | |
3749 // If the navigation is browser-initiated, the NavigationState contains the | |
3750 // correct value instead of the WebDataSource. | |
3751 // | |
3752 // TODO(davidben): Avoid this awkward duplication of state. See comment on | |
3753 // NavigationState::should_replace_current_entry(). | |
3754 should_replace_current_entry = | |
3755 navigation_state->common_params().should_replace_current_entry; | |
3756 } | |
3757 | 3746 |
3758 int provider_id = kInvalidServiceWorkerProviderId; | 3747 int provider_id = kInvalidServiceWorkerProviderId; |
3759 if (request.getFrameType() == blink::WebURLRequest::FrameTypeTopLevel || | 3748 if (request.getFrameType() == blink::WebURLRequest::FrameTypeTopLevel || |
3760 request.getFrameType() == blink::WebURLRequest::FrameTypeNested) { | 3749 request.getFrameType() == blink::WebURLRequest::FrameTypeNested) { |
3761 // |provisionalDataSource| may be null in some content::ResourceFetcher | 3750 // |provisionalDataSource| may be null in some content::ResourceFetcher |
3762 // use cases, we don't hook those requests. | 3751 // use cases, we don't hook those requests. |
3763 if (frame->provisionalDataSource()) { | 3752 if (frame->provisionalDataSource()) { |
3764 ServiceWorkerNetworkProvider* provider = | 3753 ServiceWorkerNetworkProvider* provider = |
3765 ServiceWorkerNetworkProvider::FromDocumentState( | 3754 ServiceWorkerNetworkProvider::FromDocumentState( |
3766 DocumentState::FromDataSource(frame->provisionalDataSource())); | 3755 DocumentState::FromDataSource(frame->provisionalDataSource())); |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4385 InternalDocumentStateData* internal_data = | 4374 InternalDocumentStateData* internal_data = |
4386 InternalDocumentStateData::FromDocumentState(document_state); | 4375 InternalDocumentStateData::FromDocumentState(document_state); |
4387 | 4376 |
4388 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 4377 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
4389 params.http_status_code = response.httpStatusCode(); | 4378 params.http_status_code = response.httpStatusCode(); |
4390 params.url_is_unreachable = ds->hasUnreachableURL(); | 4379 params.url_is_unreachable = ds->hasUnreachableURL(); |
4391 params.is_post = false; | 4380 params.is_post = false; |
4392 params.intended_as_new_entry = | 4381 params.intended_as_new_entry = |
4393 navigation_state->request_params().intended_as_new_entry; | 4382 navigation_state->request_params().intended_as_new_entry; |
4394 params.did_create_new_entry = commit_type == blink::WebStandardCommit; | 4383 params.did_create_new_entry = commit_type == blink::WebStandardCommit; |
| 4384 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); |
4395 params.post_id = -1; | 4385 params.post_id = -1; |
4396 params.page_id = render_view_->page_id_; | 4386 params.page_id = render_view_->page_id_; |
4397 params.nav_entry_id = navigation_state->request_params().nav_entry_id; | 4387 params.nav_entry_id = navigation_state->request_params().nav_entry_id; |
4398 // We need to track the RenderViewHost routing_id because of downstream | 4388 // We need to track the RenderViewHost routing_id because of downstream |
4399 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, | 4389 // dependencies (crbug.com/392171 DownloadRequestHandle, SaveFileManager, |
4400 // ResourceDispatcherHostImpl, MediaStreamUIProxy, | 4390 // ResourceDispatcherHostImpl, MediaStreamUIProxy, |
4401 // SpeechRecognitionDispatcherHost and possibly others). They look up the view | 4391 // SpeechRecognitionDispatcherHost and possibly others). They look up the view |
4402 // based on the ID stored in the resource requests. Once those dependencies | 4392 // based on the ID stored in the resource requests. Once those dependencies |
4403 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the | 4393 // are unwound or moved to RenderFrameHost (crbug.com/304341) we can move the |
4404 // client to be based on the routing_id of the RenderFrameHost. | 4394 // client to be based on the routing_id of the RenderFrameHost. |
(...skipping 805 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5210 bool should_replace_current_entry, | 5200 bool should_replace_current_entry, |
5211 bool is_history_navigation_in_new_child) { | 5201 bool is_history_navigation_in_new_child) { |
5212 FrameHostMsg_OpenURL_Params params; | 5202 FrameHostMsg_OpenURL_Params params; |
5213 params.url = url; | 5203 params.url = url; |
5214 params.referrer = referrer; | 5204 params.referrer = referrer; |
5215 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); | 5205 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); |
5216 | 5206 |
5217 if (IsBrowserInitiated(pending_navigation_params_.get())) { | 5207 if (IsBrowserInitiated(pending_navigation_params_.get())) { |
5218 // This is necessary to preserve the should_replace_current_entry value on | 5208 // This is necessary to preserve the should_replace_current_entry value on |
5219 // cross-process redirects, in the event it was set by a previous process. | 5209 // cross-process redirects, in the event it was set by a previous process. |
5220 // | 5210 WebDataSource* ds = frame_->provisionalDataSource(); |
5221 // TODO(davidben): Avoid this awkward duplication of state. See comment on | 5211 DCHECK(ds); |
5222 // NavigationState::should_replace_current_entry(). | 5212 params.should_replace_current_entry = ds->replacesCurrentHistoryItem(); |
5223 params.should_replace_current_entry = | |
5224 pending_navigation_params_->common_params.should_replace_current_entry; | |
5225 } else { | 5213 } else { |
5226 params.should_replace_current_entry = | 5214 params.should_replace_current_entry = |
5227 should_replace_current_entry && render_view_->history_list_length_; | 5215 should_replace_current_entry && render_view_->history_list_length_; |
5228 } | 5216 } |
5229 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); | 5217 params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); |
5230 if (GetContentClient()->renderer()->AllowPopup()) | 5218 if (GetContentClient()->renderer()->AllowPopup()) |
5231 params.user_gesture = true; | 5219 params.user_gesture = true; |
5232 | 5220 |
5233 if (policy == blink::WebNavigationPolicyNewBackgroundTab || | 5221 if (policy == blink::WebNavigationPolicyNewBackgroundTab || |
5234 policy == blink::WebNavigationPolicyNewForegroundTab || | 5222 policy == blink::WebNavigationPolicyNewForegroundTab || |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5291 new NavigationParams(common_params, start_params, request_params)); | 5279 new NavigationParams(common_params, start_params, request_params)); |
5292 | 5280 |
5293 // Unless the load is a WebFrameLoadType::Standard, this should remain | 5281 // Unless the load is a WebFrameLoadType::Standard, this should remain |
5294 // uninitialized. It will be updated when the load type is determined to be | 5282 // uninitialized. It will be updated when the load type is determined to be |
5295 // Standard, or after the previous document's unload handler has been | 5283 // Standard, or after the previous document's unload handler has been |
5296 // triggered. This occurs in UpdateNavigationState. | 5284 // triggered. This occurs in UpdateNavigationState. |
5297 // TODO(csharrison) See if we can always use the browser timestamp. | 5285 // TODO(csharrison) See if we can always use the browser timestamp. |
5298 pending_navigation_params_->common_params.navigation_start = | 5286 pending_navigation_params_->common_params.navigation_start = |
5299 base::TimeTicks(); | 5287 base::TimeTicks(); |
5300 | 5288 |
5301 // Create parameters for a standard navigation. | 5289 // Create parameters for a standard navigation, indicating whether it should |
5302 blink::WebFrameLoadType load_type = blink::WebFrameLoadType::Standard; | 5290 // replace the current NavigationEntry. |
| 5291 blink::WebFrameLoadType load_type = |
| 5292 common_params.should_replace_current_entry |
| 5293 ? blink::WebFrameLoadType::ReplaceCurrentItem |
| 5294 : blink::WebFrameLoadType::Standard; |
5303 blink::WebHistoryLoadType history_load_type = | 5295 blink::WebHistoryLoadType history_load_type = |
5304 blink::WebHistoryDifferentDocumentLoad; | 5296 blink::WebHistoryDifferentDocumentLoad; |
5305 bool should_load_request = false; | 5297 bool should_load_request = false; |
5306 WebHistoryItem item_for_history_navigation; | 5298 WebHistoryItem item_for_history_navigation; |
5307 WebURLRequest request = | 5299 WebURLRequest request = |
5308 CreateURLRequestForNavigation(common_params, std::move(stream_params), | 5300 CreateURLRequestForNavigation(common_params, std::move(stream_params), |
5309 frame_->isViewSourceModeEnabled()); | 5301 frame_->isViewSourceModeEnabled()); |
5310 | 5302 |
5311 // Used to determine whether this frame is actually loading a request as part | 5303 // Used to determine whether this frame is actually loading a request as part |
5312 // of a history navigation. | 5304 // of a history navigation. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5423 | 5415 |
5424 should_load_request = true; | 5416 should_load_request = true; |
5425 } | 5417 } |
5426 | 5418 |
5427 if (should_load_request) { | 5419 if (should_load_request) { |
5428 // Sanitize navigation start now that we know the load_type. | 5420 // Sanitize navigation start now that we know the load_type. |
5429 pending_navigation_params_->common_params.navigation_start = | 5421 pending_navigation_params_->common_params.navigation_start = |
5430 SanitizeNavigationTiming(load_type, common_params.navigation_start, | 5422 SanitizeNavigationTiming(load_type, common_params.navigation_start, |
5431 renderer_navigation_start); | 5423 renderer_navigation_start); |
5432 | 5424 |
5433 // PlzNavigate: Check if the load should replace the current item. | |
5434 // TODO(clamy): Remove this when | |
5435 // https://codereview.chromium.org/1250163002/ lands and makes it default | |
5436 // for the current architecture. | |
5437 if (browser_side_navigation && common_params.should_replace_current_entry) { | |
5438 DCHECK(load_type == blink::WebFrameLoadType::Standard); | |
5439 load_type = blink::WebFrameLoadType::ReplaceCurrentItem; | |
5440 } | |
5441 | |
5442 // PlzNavigate: check if the navigation being committed originated as a | 5425 // PlzNavigate: check if the navigation being committed originated as a |
5443 // client redirect. | 5426 // client redirect. |
5444 bool is_client_redirect = | 5427 bool is_client_redirect = |
5445 browser_side_navigation | 5428 browser_side_navigation |
5446 ? !!(common_params.transition & ui::PAGE_TRANSITION_CLIENT_REDIRECT) | 5429 ? !!(common_params.transition & ui::PAGE_TRANSITION_CLIENT_REDIRECT) |
5447 : false; | 5430 : false; |
5448 | 5431 |
5449 // Perform a navigation to a data url if needed. | 5432 // Perform a navigation to a data url if needed. |
5450 // Note: the base URL might be invalid, so also check the data URL string. | 5433 // Note: the base URL might be invalid, so also check the data URL string. |
5451 if (!common_params.base_url_for_data_url.is_empty() || | 5434 if (!common_params.base_url_for_data_url.is_empty() || |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6085 int match_count, | 6068 int match_count, |
6086 int ordinal, | 6069 int ordinal, |
6087 const WebRect& selection_rect, | 6070 const WebRect& selection_rect, |
6088 bool final_status_update) { | 6071 bool final_status_update) { |
6089 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, | 6072 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, |
6090 selection_rect, ordinal, | 6073 selection_rect, ordinal, |
6091 final_status_update)); | 6074 final_status_update)); |
6092 } | 6075 } |
6093 | 6076 |
6094 } // namespace content | 6077 } // namespace content |
OLD | NEW |