| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/frame_host/navigation_request.h" | 5 #include "content/browser/frame_host/navigation_request.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "content/browser/appcache/appcache_navigation_handle.h" | 9 #include "content/browser/appcache/appcache_navigation_handle.h" |
| 10 #include "content/browser/appcache/chrome_appcache_service.h" | 10 #include "content/browser/appcache/chrome_appcache_service.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 // Fill POST data in the request body. | 198 // Fill POST data in the request body. |
| 199 scoped_refptr<ResourceRequestBodyImpl> request_body; | 199 scoped_refptr<ResourceRequestBodyImpl> request_body; |
| 200 if (frame_entry.method() == "POST") | 200 if (frame_entry.method() == "POST") |
| 201 request_body = frame_entry.GetPostData(); | 201 request_body = frame_entry.GetPostData(); |
| 202 | 202 |
| 203 std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest( | 203 std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest( |
| 204 frame_tree_node, entry.ConstructCommonNavigationParams( | 204 frame_tree_node, entry.ConstructCommonNavigationParams( |
| 205 frame_entry, request_body, dest_url, dest_referrer, | 205 frame_entry, request_body, dest_url, dest_referrer, |
| 206 navigation_type, lofi_state, navigation_start), | 206 navigation_type, lofi_state, navigation_start), |
| 207 BeginNavigationParams(entry.extra_headers(), net::LOAD_NORMAL, | 207 BeginNavigationParams(entry.extra_headers(), net::LOAD_NORMAL, |
| 208 false, // has_user_gestures |
| 208 false, // skip_service_worker | 209 false, // skip_service_worker |
| 209 REQUEST_CONTEXT_TYPE_LOCATION), | 210 REQUEST_CONTEXT_TYPE_LOCATION), |
| 210 entry.ConstructRequestNavigationParams( | 211 entry.ConstructRequestNavigationParams( |
| 211 frame_entry, is_same_document_history_load, | 212 frame_entry, is_same_document_history_load, |
| 212 is_history_navigation_in_new_child, | 213 is_history_navigation_in_new_child, |
| 213 entry.GetSubframeUniqueNames(frame_tree_node), | 214 entry.GetSubframeUniqueNames(frame_tree_node), |
| 214 frame_tree_node->has_committed_real_load(), | 215 frame_tree_node->has_committed_real_load(), |
| 215 controller->GetPendingEntryIndex() == -1, | 216 controller->GetPendingEntryIndex() == -1, |
| 216 controller->GetIndexOfEntry(&entry), | 217 controller->GetIndexOfEntry(&entry), |
| 217 controller->GetLastCommittedEntryIndex(), | 218 controller->GetLastCommittedEntryIndex(), |
| 218 controller->GetEntryCount()), | 219 controller->GetEntryCount()), |
| 219 true, &frame_entry, &entry)); | 220 true, &frame_entry, &entry)); |
| 220 return navigation_request; | 221 return navigation_request; |
| 221 } | 222 } |
| 222 | 223 |
| 223 // static | 224 // static |
| 224 std::unique_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated( | 225 std::unique_ptr<NavigationRequest> NavigationRequest::CreateRendererInitiated( |
| 225 FrameTreeNode* frame_tree_node, | 226 FrameTreeNode* frame_tree_node, |
| 226 const CommonNavigationParams& common_params, | 227 const CommonNavigationParams& common_params, |
| 227 const BeginNavigationParams& begin_params, | 228 const BeginNavigationParams& begin_params, |
| 228 int current_history_list_offset, | 229 int current_history_list_offset, |
| 229 int current_history_list_length) { | 230 int current_history_list_length) { |
| 230 // TODO(clamy): Check if some PageState should be provided here. | 231 // TODO(clamy): Check if some PageState should be provided here. |
| 231 // TODO(clamy): See how we should handle override of the user agent when the | 232 // TODO(clamy): See how we should handle override of the user agent when the |
| 232 // navigation may start in a renderer and commit in another one. | 233 // navigation may start in a renderer and commit in another one. |
| 233 // TODO(clamy): See if the navigation start time should be measured in the | 234 // TODO(clamy): See if the navigation start time should be measured in the |
| 234 // renderer and sent to the browser instead of being measured here. | 235 // renderer and sent to the browser instead of being measured here. |
| 235 // TODO(clamy): The pending history list offset should be properly set. | 236 // TODO(clamy): The pending history list offset should be properly set. |
| 236 RequestNavigationParams request_params( | 237 RequestNavigationParams request_params( |
| 237 false, // is_overriding_user_agent | 238 false, // is_overriding_user_agent |
| 238 std::vector<GURL>(), // redirects | 239 std::vector<GURL>(), // redirects |
| 239 false, // can_load_local_resources | 240 false, // can_load_local_resources |
| 240 PageState(), // page_state | 241 PageState(), // page_state |
| 241 0, // nav_entry_id | 242 0, // nav_entry_id |
| 242 false, // is_same_document_history_load | 243 false, // is_same_document_history_load |
| 243 false, // is_history_navigation_in_new_child | 244 false, // is_history_navigation_in_new_child |
| 244 std::map<std::string, bool>(), // subframe_unique_names | 245 std::map<std::string, bool>(), // subframe_unique_names |
| 245 frame_tree_node->has_committed_real_load(), | 246 frame_tree_node->has_committed_real_load(), |
| 246 false, // intended_as_new_entry | 247 false, // intended_as_new_entry |
| 247 -1, // pending_history_list_offset | 248 -1, // pending_history_list_offset |
| 248 current_history_list_offset, current_history_list_length, | 249 current_history_list_offset, current_history_list_length, |
| 249 false, // is_view_source | 250 false, // is_view_source |
| 250 false); // should_clear_history_list | 251 false, // should_clear_history_list |
| 252 begin_params.has_user_gesture); |
| 251 std::unique_ptr<NavigationRequest> navigation_request( | 253 std::unique_ptr<NavigationRequest> navigation_request( |
| 252 new NavigationRequest(frame_tree_node, common_params, begin_params, | 254 new NavigationRequest(frame_tree_node, common_params, begin_params, |
| 253 request_params, false, nullptr, nullptr)); | 255 request_params, false, nullptr, nullptr)); |
| 254 return navigation_request; | 256 return navigation_request; |
| 255 } | 257 } |
| 256 | 258 |
| 257 NavigationRequest::NavigationRequest( | 259 NavigationRequest::NavigationRequest( |
| 258 FrameTreeNode* frame_tree_node, | 260 FrameTreeNode* frame_tree_node, |
| 259 const CommonNavigationParams& common_params, | 261 const CommonNavigationParams& common_params, |
| 260 const BeginNavigationParams& begin_params, | 262 const BeginNavigationParams& begin_params, |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 if (ShouldMakeNetworkRequestForURL(common_params_.url)) { | 319 if (ShouldMakeNetworkRequestForURL(common_params_.url)) { |
| 318 // It's safe to use base::Unretained because this NavigationRequest owns | 320 // It's safe to use base::Unretained because this NavigationRequest owns |
| 319 // the NavigationHandle where the callback will be stored. | 321 // the NavigationHandle where the callback will be stored. |
| 320 // TODO(clamy): pass the real value for |is_external_protocol| if needed. | 322 // TODO(clamy): pass the real value for |is_external_protocol| if needed. |
| 321 // TODO(clamy): pass the method to the NavigationHandle instead of a | 323 // TODO(clamy): pass the method to the NavigationHandle instead of a |
| 322 // boolean. | 324 // boolean. |
| 323 navigation_handle_->WillStartRequest( | 325 navigation_handle_->WillStartRequest( |
| 324 common_params_.method, common_params_.post_data, | 326 common_params_.method, common_params_.post_data, |
| 325 Referrer::SanitizeForRequest(common_params_.url, | 327 Referrer::SanitizeForRequest(common_params_.url, |
| 326 common_params_.referrer), | 328 common_params_.referrer), |
| 327 common_params_.transition, false, begin_params_.request_context_type, | 329 begin_params_.has_user_gesture, common_params_.transition, false, |
| 330 begin_params_.request_context_type, |
| 328 base::Bind(&NavigationRequest::OnStartChecksComplete, | 331 base::Bind(&NavigationRequest::OnStartChecksComplete, |
| 329 base::Unretained(this))); | 332 base::Unretained(this))); |
| 330 return; | 333 return; |
| 331 } | 334 } |
| 332 | 335 |
| 333 // There is no need to make a network request for this navigation, so commit | 336 // There is no need to make a network request for this navigation, so commit |
| 334 // it immediately. | 337 // it immediately. |
| 335 state_ = RESPONSE_STARTED; | 338 state_ = RESPONSE_STARTED; |
| 336 | 339 |
| 337 // Select an appropriate RenderFrameHost. | 340 // Select an appropriate RenderFrameHost. |
| 338 RenderFrameHostImpl* render_frame_host = | 341 RenderFrameHostImpl* render_frame_host = |
| 339 frame_tree_node_->render_manager()->GetFrameHostForNavigation(*this); | 342 frame_tree_node_->render_manager()->GetFrameHostForNavigation(*this); |
| 340 NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host, | 343 NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL(render_frame_host, |
| 341 common_params_.url); | 344 common_params_.url); |
| 342 | 345 |
| 343 // Inform the NavigationHandle that the navigation will commit. | 346 // Inform the NavigationHandle that the navigation will commit. |
| 344 navigation_handle_->ReadyToCommitNavigation(render_frame_host); | 347 navigation_handle_->ReadyToCommitNavigation(render_frame_host); |
| 345 | 348 |
| 346 CommitNavigation(); | 349 CommitNavigation(); |
| 347 } | 350 } |
| 348 | 351 |
| 349 void NavigationRequest::CreateNavigationHandle(int pending_nav_entry_id) { | 352 void NavigationRequest::CreateNavigationHandle(int pending_nav_entry_id) { |
| 350 // TODO(nasko): Update the NavigationHandle creation to ensure that the | 353 // TODO(nasko): Update the NavigationHandle creation to ensure that the |
| 351 // proper values are specified for is_same_page. | 354 // proper values are specified for is_same_page. |
| 352 navigation_handle_ = NavigationHandleImpl::Create( | 355 navigation_handle_ = NavigationHandleImpl::Create( |
| 353 common_params_.url, frame_tree_node_, !browser_initiated_, | 356 common_params_.url, frame_tree_node_, !browser_initiated_, |
| 354 false, // is_same_page | 357 false, // is_same_page |
| 355 common_params_.navigation_start, pending_nav_entry_id, | 358 common_params_.navigation_start, pending_nav_entry_id, |
| 356 common_params_.gesture, | |
| 357 false); // started_in_context_menu | 359 false); // started_in_context_menu |
| 358 | 360 |
| 359 if (!begin_params_.searchable_form_url.is_empty()) { | 361 if (!begin_params_.searchable_form_url.is_empty()) { |
| 360 navigation_handle_->set_searchable_form_url( | 362 navigation_handle_->set_searchable_form_url( |
| 361 begin_params_.searchable_form_url); | 363 begin_params_.searchable_form_url); |
| 362 navigation_handle_->set_searchable_form_encoding( | 364 navigation_handle_->set_searchable_form_encoding( |
| 363 begin_params_.searchable_form_encoding); | 365 begin_params_.searchable_form_encoding); |
| 364 } | 366 } |
| 365 } | 367 } |
| 366 | 368 |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 647 // Retrieve the RenderFrameHost that needs to commit the navigation. | 649 // Retrieve the RenderFrameHost that needs to commit the navigation. |
| 648 RenderFrameHostImpl* render_frame_host = | 650 RenderFrameHostImpl* render_frame_host = |
| 649 navigation_handle_->GetRenderFrameHost(); | 651 navigation_handle_->GetRenderFrameHost(); |
| 650 DCHECK(render_frame_host == | 652 DCHECK(render_frame_host == |
| 651 frame_tree_node_->render_manager()->current_frame_host() || | 653 frame_tree_node_->render_manager()->current_frame_host() || |
| 652 render_frame_host == | 654 render_frame_host == |
| 653 frame_tree_node_->render_manager()->speculative_frame_host()); | 655 frame_tree_node_->render_manager()->speculative_frame_host()); |
| 654 | 656 |
| 655 TransferNavigationHandleOwnership(render_frame_host); | 657 TransferNavigationHandleOwnership(render_frame_host); |
| 656 | 658 |
| 659 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); |
| 660 |
| 657 render_frame_host->CommitNavigation(response_.get(), std::move(body_), | 661 render_frame_host->CommitNavigation(response_.get(), std::move(body_), |
| 658 common_params_, request_params_, | 662 common_params_, request_params_, |
| 659 is_view_source_); | 663 is_view_source_); |
| 660 | 664 |
| 661 frame_tree_node_->ResetNavigationRequest(true); | 665 frame_tree_node_->ResetNavigationRequest(true); |
| 662 } | 666 } |
| 663 | 667 |
| 664 } // namespace content | 668 } // namespace content |
| OLD | NEW |