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/devtools/render_frame_devtools_agent_host.h" | 9 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
10 #include "content/browser/frame_host/frame_tree.h" | 10 #include "content/browser/frame_host/frame_tree.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
75 const base::TimeTicks& navigation_start, | 75 const base::TimeTicks& navigation_start, |
76 NavigationControllerImpl* controller) { | 76 NavigationControllerImpl* controller) { |
77 // Copy existing headers and add necessary headers that may not be present | 77 // Copy existing headers and add necessary headers that may not be present |
78 // in the RequestNavigationParams. | 78 // in the RequestNavigationParams. |
79 net::HttpRequestHeaders headers; | 79 net::HttpRequestHeaders headers; |
80 headers.AddHeadersFromString(entry.extra_headers()); | 80 headers.AddHeadersFromString(entry.extra_headers()); |
81 headers.SetHeaderIfMissing(net::HttpRequestHeaders::kUserAgent, | 81 headers.SetHeaderIfMissing(net::HttpRequestHeaders::kUserAgent, |
82 GetContentClient()->GetUserAgent()); | 82 GetContentClient()->GetUserAgent()); |
83 | 83 |
84 // Fill POST data from the browser in the request body. | 84 // Fill POST data from the browser in the request body. |
85 scoped_refptr<ResourceRequestBody> request_body; | 85 scoped_refptr<ResourceRequestBody> request_body = |
86 if (entry.GetHasPostData()) { | 86 entry.ConstructResourceRequestBody(); |
87 request_body = new ResourceRequestBody(); | |
88 request_body->AppendBytes( | |
89 reinterpret_cast<const char *>( | |
90 entry.GetBrowserInitiatedPostData()->front()), | |
91 entry.GetBrowserInitiatedPostData()->size()); | |
92 } | |
93 | 87 |
94 std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest( | 88 std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest( |
95 frame_tree_node, entry.ConstructCommonNavigationParams( | 89 frame_tree_node, |
96 dest_url, dest_referrer, navigation_type, lofi_state, | 90 entry.ConstructCommonNavigationParams( |
97 navigation_start), | 91 request_body ? "POST" : "GET", dest_url, dest_referrer, |
clamy
2016/05/19 16:08:00
This should be frame_entry.method().
Łukasz Anforowicz
2016/05/19 18:06:58
Arrgh. Thanks for catching this. Done.
| |
92 navigation_type, lofi_state, navigation_start), | |
98 BeginNavigationParams(headers.ToString(), | 93 BeginNavigationParams(headers.ToString(), |
99 LoadFlagFromNavigationType(navigation_type), | 94 LoadFlagFromNavigationType(navigation_type), |
100 false, // has_user_gestures | 95 false, // has_user_gestures |
101 false, // skip_service_worker | 96 false, // skip_service_worker |
102 REQUEST_CONTEXT_TYPE_LOCATION), | 97 REQUEST_CONTEXT_TYPE_LOCATION), |
103 entry.ConstructRequestNavigationParams( | 98 entry.ConstructRequestNavigationParams( |
104 frame_entry, is_same_document_history_load, | 99 frame_entry, is_same_document_history_load, |
105 frame_tree_node->has_committed_real_load(), | 100 frame_tree_node->has_committed_real_load(), |
106 controller->GetPendingEntryIndex() == -1, | 101 controller->GetPendingEntryIndex() == -1, |
107 controller->GetIndexOfEntry(&entry), | 102 controller->GetIndexOfEntry(&entry), |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 state_ = STARTED; | 203 state_ = STARTED; |
209 RenderFrameDevToolsAgentHost::OnBeforeNavigation(navigation_handle_.get()); | 204 RenderFrameDevToolsAgentHost::OnBeforeNavigation(navigation_handle_.get()); |
210 | 205 |
211 if (ShouldMakeNetworkRequestForURL(common_params_.url)) { | 206 if (ShouldMakeNetworkRequestForURL(common_params_.url)) { |
212 // It's safe to use base::Unretained because this NavigationRequest owns | 207 // It's safe to use base::Unretained because this NavigationRequest owns |
213 // the NavigationHandle where the callback will be stored. | 208 // the NavigationHandle where the callback will be stored. |
214 // TODO(clamy): pass the real value for |is_external_protocol| if needed. | 209 // TODO(clamy): pass the real value for |is_external_protocol| if needed. |
215 // TODO(clamy): pass the method to the NavigationHandle instead of a | 210 // TODO(clamy): pass the method to the NavigationHandle instead of a |
216 // boolean. | 211 // boolean. |
217 navigation_handle_->WillStartRequest( | 212 navigation_handle_->WillStartRequest( |
218 common_params_.method, Referrer::SanitizeForRequest( | 213 common_params_.method, info_->request_body, |
219 common_params_.url, common_params_.referrer), | 214 Referrer::SanitizeForRequest(common_params_.url, |
215 common_params_.referrer), | |
220 begin_params_.has_user_gesture, common_params_.transition, false, | 216 begin_params_.has_user_gesture, common_params_.transition, false, |
221 base::Bind(&NavigationRequest::OnStartChecksComplete, | 217 base::Bind(&NavigationRequest::OnStartChecksComplete, |
222 base::Unretained(this))); | 218 base::Unretained(this))); |
223 return; | 219 return; |
224 } | 220 } |
225 | 221 |
226 // There is no need to make a network request for this navigation, so commit | 222 // There is no need to make a network request for this navigation, so commit |
227 // it immediately. | 223 // it immediately. |
228 state_ = RESPONSE_STARTED; | 224 state_ = RESPONSE_STARTED; |
229 | 225 |
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
459 browser_context, navigating_frame_host->GetSiteInstance()); | 455 browser_context, navigating_frame_host->GetSiteInstance()); |
460 DCHECK(partition); | 456 DCHECK(partition); |
461 | 457 |
462 ServiceWorkerContextWrapper* service_worker_context = | 458 ServiceWorkerContextWrapper* service_worker_context = |
463 static_cast<ServiceWorkerContextWrapper*>( | 459 static_cast<ServiceWorkerContextWrapper*>( |
464 partition->GetServiceWorkerContext()); | 460 partition->GetServiceWorkerContext()); |
465 navigation_handle_->InitServiceWorkerHandle(service_worker_context); | 461 navigation_handle_->InitServiceWorkerHandle(service_worker_context); |
466 } | 462 } |
467 | 463 |
468 } // namespace content | 464 } // namespace content |
OLD | NEW |