| 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 "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "content/browser/appcache/appcache_navigation_handle.h" | 10 #include "content/browser/appcache/appcache_navigation_handle.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 } // namespace | 194 } // namespace |
| 195 | 195 |
| 196 // static | 196 // static |
| 197 std::unique_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated( | 197 std::unique_ptr<NavigationRequest> NavigationRequest::CreateBrowserInitiated( |
| 198 FrameTreeNode* frame_tree_node, | 198 FrameTreeNode* frame_tree_node, |
| 199 const GURL& dest_url, | 199 const GURL& dest_url, |
| 200 const Referrer& dest_referrer, | 200 const Referrer& dest_referrer, |
| 201 const FrameNavigationEntry& frame_entry, | 201 const FrameNavigationEntry& frame_entry, |
| 202 const NavigationEntryImpl& entry, | 202 const NavigationEntryImpl& entry, |
| 203 FrameMsg_Navigate_Type::Value navigation_type, | 203 FrameMsg_Navigate_Type::Value navigation_type, |
| 204 LoFiState lofi_state, | 204 PreviewsState previews_state, |
| 205 bool is_same_document_history_load, | 205 bool is_same_document_history_load, |
| 206 bool is_history_navigation_in_new_child, | 206 bool is_history_navigation_in_new_child, |
| 207 const base::TimeTicks& navigation_start, | 207 const base::TimeTicks& navigation_start, |
| 208 NavigationControllerImpl* controller) { | 208 NavigationControllerImpl* controller) { |
| 209 // Fill POST data in the request body. | 209 // Fill POST data in the request body. |
| 210 scoped_refptr<ResourceRequestBodyImpl> request_body; | 210 scoped_refptr<ResourceRequestBodyImpl> request_body; |
| 211 if (frame_entry.method() == "POST") | 211 if (frame_entry.method() == "POST") |
| 212 request_body = frame_entry.GetPostData(); | 212 request_body = frame_entry.GetPostData(); |
| 213 | 213 |
| 214 base::Optional<url::Origin> initiator = | 214 base::Optional<url::Origin> initiator = |
| 215 frame_tree_node->IsMainFrame() | 215 frame_tree_node->IsMainFrame() |
| 216 ? base::Optional<url::Origin>() | 216 ? base::Optional<url::Origin>() |
| 217 : base::Optional<url::Origin>( | 217 : base::Optional<url::Origin>( |
| 218 frame_tree_node->frame_tree()->root()->current_origin()); | 218 frame_tree_node->frame_tree()->root()->current_origin()); |
| 219 | 219 |
| 220 // While the navigation was started via the LoadURL path it may have come from | 220 // While the navigation was started via the LoadURL path it may have come from |
| 221 // the renderer in the first place as part of OpenURL. | 221 // the renderer in the first place as part of OpenURL. |
| 222 bool browser_initiated = !entry.is_renderer_initiated(); | 222 bool browser_initiated = !entry.is_renderer_initiated(); |
| 223 | 223 |
| 224 std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest( | 224 std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest( |
| 225 frame_tree_node, entry.ConstructCommonNavigationParams( | 225 frame_tree_node, entry.ConstructCommonNavigationParams( |
| 226 frame_entry, request_body, dest_url, dest_referrer, | 226 frame_entry, request_body, dest_url, dest_referrer, |
| 227 navigation_type, lofi_state, navigation_start), | 227 navigation_type, previews_state, navigation_start), |
| 228 BeginNavigationParams(entry.extra_headers(), net::LOAD_NORMAL, | 228 BeginNavigationParams(entry.extra_headers(), net::LOAD_NORMAL, |
| 229 false, // has_user_gestures | 229 false, // has_user_gestures |
| 230 false, // skip_service_worker | 230 false, // skip_service_worker |
| 231 REQUEST_CONTEXT_TYPE_LOCATION, initiator), | 231 REQUEST_CONTEXT_TYPE_LOCATION, initiator), |
| 232 entry.ConstructRequestNavigationParams( | 232 entry.ConstructRequestNavigationParams( |
| 233 frame_entry, is_same_document_history_load, | 233 frame_entry, is_same_document_history_load, |
| 234 is_history_navigation_in_new_child, | 234 is_history_navigation_in_new_child, |
| 235 entry.GetSubframeUniqueNames(frame_tree_node), | 235 entry.GetSubframeUniqueNames(frame_tree_node), |
| 236 frame_tree_node->has_committed_real_load(), | 236 frame_tree_node->has_committed_real_load(), |
| 237 controller->GetPendingEntryIndex() == -1, | 237 controller->GetPendingEntryIndex() == -1, |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 did_create_service_worker_host | 483 did_create_service_worker_host |
| 484 ? navigation_handle_->service_worker_handle() | 484 ? navigation_handle_->service_worker_handle() |
| 485 ->service_worker_provider_host_id() | 485 ->service_worker_provider_host_id() |
| 486 : kInvalidServiceWorkerProviderId; | 486 : kInvalidServiceWorkerProviderId; |
| 487 | 487 |
| 488 request_params_.appcache_host_id = | 488 request_params_.appcache_host_id = |
| 489 navigation_handle_->appcache_handle() | 489 navigation_handle_->appcache_handle() |
| 490 ? navigation_handle_->appcache_handle()->appcache_host_id() | 490 ? navigation_handle_->appcache_handle()->appcache_host_id() |
| 491 : kAppCacheNoHostId; | 491 : kAppCacheNoHostId; |
| 492 | 492 |
| 493 // Update the lofi state of the request. | 493 // Update the previews state of the request. |
| 494 if (response->head.is_using_lofi) | 494 common_params_.previews_state = response->head.previews_state; |
| 495 common_params_.lofi_state = LOFI_ON; | |
| 496 else | |
| 497 common_params_.lofi_state = LOFI_OFF; | |
| 498 | 495 |
| 499 // Select an appropriate renderer to commit the navigation. | 496 // Select an appropriate renderer to commit the navigation. |
| 500 RenderFrameHostImpl* render_frame_host = nullptr; | 497 RenderFrameHostImpl* render_frame_host = nullptr; |
| 501 if (response_should_be_rendered_) { | 498 if (response_should_be_rendered_) { |
| 502 render_frame_host = | 499 render_frame_host = |
| 503 frame_tree_node_->render_manager()->GetFrameHostForNavigation(*this); | 500 frame_tree_node_->render_manager()->GetFrameHostForNavigation(*this); |
| 504 NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL( | 501 NavigatorImpl::CheckWebUIRendererDoesNotDisplayNormalURL( |
| 505 render_frame_host, common_params_.url); | 502 render_frame_host, common_params_.url); |
| 506 } | 503 } |
| 507 DCHECK(render_frame_host || !response_should_be_rendered_); | 504 DCHECK(render_frame_host || !response_should_be_rendered_); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); | 711 DCHECK_EQ(request_params_.has_user_gesture, begin_params_.has_user_gesture); |
| 715 | 712 |
| 716 render_frame_host->CommitNavigation(response_.get(), std::move(body_), | 713 render_frame_host->CommitNavigation(response_.get(), std::move(body_), |
| 717 common_params_, request_params_, | 714 common_params_, request_params_, |
| 718 is_view_source_); | 715 is_view_source_); |
| 719 | 716 |
| 720 frame_tree_node_->ResetNavigationRequest(true); | 717 frame_tree_node_->ResetNavigationRequest(true); |
| 721 } | 718 } |
| 722 | 719 |
| 723 } // namespace content | 720 } // namespace content |
| OLD | NEW |