Chromium Code Reviews| 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 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 3081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3092 // TODO(nasko): When the top-level frame is remote, there is no document. | 3092 // TODO(nasko): When the top-level frame is remote, there is no document. |
| 3093 // This is broken and should be fixed to propagate the first party. | 3093 // This is broken and should be fixed to propagate the first party. |
| 3094 WebFrame* top = frame->top(); | 3094 WebFrame* top = frame->top(); |
| 3095 if (top->isWebLocalFrame()) { | 3095 if (top->isWebLocalFrame()) { |
| 3096 request.setFirstPartyForCookies( | 3096 request.setFirstPartyForCookies( |
| 3097 frame->top()->document().firstPartyForCookies()); | 3097 frame->top()->document().firstPartyForCookies()); |
| 3098 } | 3098 } |
| 3099 } | 3099 } |
| 3100 } | 3100 } |
| 3101 | 3101 |
| 3102 WebFrame* top_frame = frame->top(); | 3102 WebDataSource* provisional_data_source = frame->provisionalDataSource(); |
| 3103 // TODO(nasko): Hack around asking about top-frame data source. This means | |
| 3104 // for out-of-process iframes we are treating the current frame as the | |
| 3105 // top-level frame, which is wrong. | |
| 3106 if (!top_frame || top_frame->isWebRemoteFrame()) | |
| 3107 top_frame = frame; | |
| 3108 WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); | |
| 3109 WebDataSource* top_data_source = top_frame->dataSource(); | |
| 3110 WebDataSource* data_source = | 3103 WebDataSource* data_source = |
| 3111 provisional_data_source ? provisional_data_source : top_data_source; | 3104 provisional_data_source ? provisional_data_source : frame->dataSource(); |
| 3112 | 3105 |
| 3113 DocumentState* document_state = DocumentState::FromDataSource(data_source); | 3106 DocumentState* document_state = DocumentState::FromDataSource(data_source); |
| 3114 DCHECK(document_state); | 3107 DCHECK(document_state); |
| 3115 InternalDocumentStateData* internal_data = | 3108 InternalDocumentStateData* internal_data = |
| 3116 InternalDocumentStateData::FromDocumentState(document_state); | 3109 InternalDocumentStateData::FromDocumentState(document_state); |
| 3117 NavigationStateImpl* navigation_state = | 3110 NavigationStateImpl* navigation_state = |
| 3118 static_cast<NavigationStateImpl*>(document_state->navigation_state()); | 3111 static_cast<NavigationStateImpl*>(document_state->navigation_state()); |
| 3119 ui::PageTransition transition_type = navigation_state->GetTransitionType(); | 3112 ui::PageTransition transition_type = navigation_state->GetTransitionType(); |
| 3120 WebDataSource* frame_ds = frame->provisionalDataSource(); | 3113 if (provisional_data_source && provisional_data_source->isClientRedirect()) { |
|
Charlie Reis
2015/07/09 17:40:11
Noticed this was redundant now.
| |
| 3121 if (frame_ds && frame_ds->isClientRedirect()) { | |
| 3122 transition_type = ui::PageTransitionFromInt( | 3114 transition_type = ui::PageTransitionFromInt( |
| 3123 transition_type | ui::PAGE_TRANSITION_CLIENT_REDIRECT); | 3115 transition_type | ui::PAGE_TRANSITION_CLIENT_REDIRECT); |
| 3124 } | 3116 } |
| 3125 | 3117 |
| 3126 GURL request_url(request.url()); | 3118 GURL request_url(request.url()); |
| 3127 GURL new_url; | 3119 GURL new_url; |
| 3128 if (GetContentClient()->renderer()->WillSendRequest( | 3120 if (GetContentClient()->renderer()->WillSendRequest( |
| 3129 frame, | 3121 frame, |
| 3130 transition_type, | 3122 transition_type, |
| 3131 request_url, | 3123 request_url, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3179 | 3171 |
| 3180 // Add an empty HTTP origin header for non GET methods if none is currently | 3172 // Add an empty HTTP origin header for non GET methods if none is currently |
| 3181 // present. | 3173 // present. |
| 3182 request.addHTTPOriginIfNeeded(WebString()); | 3174 request.addHTTPOriginIfNeeded(WebString()); |
| 3183 | 3175 |
| 3184 // Attach |should_replace_current_entry| state to requests so that, should | 3176 // Attach |should_replace_current_entry| state to requests so that, should |
| 3185 // this navigation later require a request transfer, all state is preserved | 3177 // this navigation later require a request transfer, all state is preserved |
| 3186 // when it is re-created in the new process. | 3178 // when it is re-created in the new process. |
| 3187 bool should_replace_current_entry = false; | 3179 bool should_replace_current_entry = false; |
| 3188 if (navigation_state->IsContentInitiated()) { | 3180 if (navigation_state->IsContentInitiated()) { |
| 3189 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); | 3181 should_replace_current_entry = data_source->replacesCurrentHistoryItem(); |
|
Charlie Reis
2015/07/09 17:40:11
This adds to my confidence in this change, because
| |
| 3190 } else { | 3182 } else { |
| 3191 // If the navigation is browser-initiated, the NavigationState contains the | 3183 // If the navigation is browser-initiated, the NavigationState contains the |
| 3192 // correct value instead of the WebDataSource. | 3184 // correct value instead of the WebDataSource. |
| 3193 // | 3185 // |
| 3194 // TODO(davidben): Avoid this awkward duplication of state. See comment on | 3186 // TODO(davidben): Avoid this awkward duplication of state. See comment on |
| 3195 // NavigationState::should_replace_current_entry(). | 3187 // NavigationState::should_replace_current_entry(). |
| 3196 should_replace_current_entry = | 3188 should_replace_current_entry = |
| 3197 navigation_state->start_params().should_replace_current_entry; | 3189 navigation_state->start_params().should_replace_current_entry; |
| 3198 } | 3190 } |
| 3199 | 3191 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3233 extra_data->set_is_main_frame(!parent); | 3225 extra_data->set_is_main_frame(!parent); |
| 3234 extra_data->set_frame_origin( | 3226 extra_data->set_frame_origin( |
| 3235 GURL(frame->document().securityOrigin().toString())); | 3227 GURL(frame->document().securityOrigin().toString())); |
| 3236 extra_data->set_parent_is_main_frame(parent && !parent->parent()); | 3228 extra_data->set_parent_is_main_frame(parent && !parent->parent()); |
| 3237 extra_data->set_parent_render_frame_id(parent_routing_id); | 3229 extra_data->set_parent_render_frame_id(parent_routing_id); |
| 3238 extra_data->set_allow_download( | 3230 extra_data->set_allow_download( |
| 3239 navigation_state->common_params().allow_download); | 3231 navigation_state->common_params().allow_download); |
| 3240 extra_data->set_transition_type(transition_type); | 3232 extra_data->set_transition_type(transition_type); |
| 3241 extra_data->set_should_replace_current_entry(should_replace_current_entry); | 3233 extra_data->set_should_replace_current_entry(should_replace_current_entry); |
| 3242 extra_data->set_transferred_request_child_id( | 3234 extra_data->set_transferred_request_child_id( |
| 3243 navigation_state->start_params().transferred_request_child_id); | 3235 navigation_state->start_params().transferred_request_child_id); |
|
Charlie Reis
2015/07/09 17:40:11
(This was what motivated this CL in the first plac
| |
| 3244 extra_data->set_transferred_request_request_id( | 3236 extra_data->set_transferred_request_request_id( |
| 3245 navigation_state->start_params().transferred_request_request_id); | 3237 navigation_state->start_params().transferred_request_request_id); |
| 3246 extra_data->set_service_worker_provider_id(provider_id); | 3238 extra_data->set_service_worker_provider_id(provider_id); |
| 3247 extra_data->set_stream_override(stream_override.Pass()); | 3239 extra_data->set_stream_override(stream_override.Pass()); |
| 3248 request.setExtraData(extra_data); | 3240 request.setExtraData(extra_data); |
| 3249 | 3241 |
| 3250 DocumentState* top_document_state = | 3242 // TODO(creis): Update prefetching to work with out-of-process iframes. |
| 3251 DocumentState::FromDataSource(top_data_source); | 3243 WebFrame* top_frame = frame->top(); |
| 3252 if (top_document_state) { | 3244 if (top_frame && top_frame->isWebLocalFrame()) { |
| 3253 // TODO(gavinp): separate out prefetching and prerender field trials | 3245 DocumentState* top_document_state = |
| 3254 // if the rel=prerender rel type is sticking around. | 3246 DocumentState::FromDataSource(top_frame->dataSource()); |
| 3255 if (request.requestContext() == WebURLRequest::RequestContextPrefetch) | 3247 if (top_document_state) { |
| 3256 top_document_state->set_was_prefetcher(true); | 3248 // TODO(gavinp): separate out prefetching and prerender field trials |
| 3249 // if the rel=prerender rel type is sticking around. | |
| 3250 if (request.requestContext() == WebURLRequest::RequestContextPrefetch) | |
| 3251 top_document_state->set_was_prefetcher(true); | |
| 3252 } | |
| 3257 } | 3253 } |
| 3258 | 3254 |
| 3259 // This is an instance where we embed a copy of the routing id | 3255 // This is an instance where we embed a copy of the routing id |
| 3260 // into the data portion of the message. This can cause problems if we | 3256 // into the data portion of the message. This can cause problems if we |
| 3261 // don't register this id on the browser side, since the download manager | 3257 // don't register this id on the browser side, since the download manager |
| 3262 // expects to find a RenderViewHost based off the id. | 3258 // expects to find a RenderViewHost based off the id. |
| 3263 request.setRequestorID(render_view_->GetRoutingID()); | 3259 request.setRequestorID(render_view_->GetRoutingID()); |
| 3264 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture()); | 3260 request.setHasUserGesture(WebUserGestureIndicator::isProcessingUserGesture()); |
| 3265 | 3261 |
| 3266 if (!navigation_state->start_params().extra_headers.empty()) { | 3262 if (!navigation_state->start_params().extra_headers.empty()) { |
| (...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4413 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { | 4409 if (is_reload && !render_view_->history_controller()->GetCurrentEntry()) { |
| 4414 // We cannot reload if we do not have any history state. This happens, for | 4410 // We cannot reload if we do not have any history state. This happens, for |
| 4415 // example, when recovering from a crash. | 4411 // example, when recovering from a crash. |
| 4416 is_reload = false; | 4412 is_reload = false; |
| 4417 cache_policy = WebURLRequest::ReloadIgnoringCacheData; | 4413 cache_policy = WebURLRequest::ReloadIgnoringCacheData; |
| 4418 } | 4414 } |
| 4419 | 4415 |
| 4420 pending_navigation_params_.reset( | 4416 pending_navigation_params_.reset( |
| 4421 new NavigationParams(common_params, start_params, request_params)); | 4417 new NavigationParams(common_params, start_params, request_params)); |
| 4422 | 4418 |
| 4423 // Create parameters for a standard navigation. | 4419 // Create parameters for a standard navigation, indicating whether it should |
| 4424 blink::WebFrameLoadType load_type = blink::WebFrameLoadType::Standard; | 4420 // replace the current NavigationEntry. |
| 4421 blink::WebFrameLoadType load_type = | |
| 4422 start_params.should_replace_current_entry ? | |
| 4423 blink::WebFrameLoadType::RedirectWithLockedBackForwardList : | |
|
Charlie Reis
2015/07/09 17:40:11
This is the fix for https://crbug.com/317872, and
| |
| 4424 blink::WebFrameLoadType::Standard; | |
| 4425 bool should_load_request = false; | 4425 bool should_load_request = false; |
| 4426 WebHistoryItem item_for_history_navigation; | 4426 WebHistoryItem item_for_history_navigation; |
| 4427 WebURLRequest request = CreateURLRequestForNavigation( | 4427 WebURLRequest request = CreateURLRequestForNavigation( |
| 4428 common_params, stream_params.Pass(), frame_->isViewSourceModeEnabled()); | 4428 common_params, stream_params.Pass(), frame_->isViewSourceModeEnabled()); |
| 4429 | 4429 |
| 4430 // PlzNavigate: Make sure that Blink's loader will not try to use browser side | 4430 // PlzNavigate: Make sure that Blink's loader will not try to use browser side |
| 4431 // navigation for this request (since it already went to the browser). | 4431 // navigation for this request (since it already went to the browser). |
| 4432 if (browser_side_navigation) | 4432 if (browser_side_navigation) |
| 4433 request.setCheckForBrowserSideNavigation(false); | 4433 request.setCheckForBrowserSideNavigation(false); |
| 4434 | 4434 |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5012 void RenderFrameImpl::RegisterMojoServices() { | 5012 void RenderFrameImpl::RegisterMojoServices() { |
| 5013 // Only main frame have ImageDownloader service. | 5013 // Only main frame have ImageDownloader service. |
| 5014 if (!frame_->parent()) { | 5014 if (!frame_->parent()) { |
| 5015 GetServiceRegistry()->AddService<image_downloader::ImageDownloader>( | 5015 GetServiceRegistry()->AddService<image_downloader::ImageDownloader>( |
| 5016 base::Bind(&ImageDownloaderImpl::CreateMojoService, | 5016 base::Bind(&ImageDownloaderImpl::CreateMojoService, |
| 5017 base::Unretained(this))); | 5017 base::Unretained(this))); |
| 5018 } | 5018 } |
| 5019 } | 5019 } |
| 5020 | 5020 |
| 5021 } // namespace content | 5021 } // namespace content |
| OLD | NEW |