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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 bool is_same_document_history_load, | 74 bool is_same_document_history_load, |
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 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 (frame_entry.method() == "POST") { | 86 entry.ConstructBodyFromBrowserInitiatedPostData(); |
clamy
2016/05/20 15:49:14
It's very important to check frame_entry.GetPostDa
Łukasz Anforowicz
2016/05/20 22:18:47
Done.
| |
87 request_body = frame_entry.GetPostData(); | |
88 if (!request_body && entry.GetBrowserInitiatedPostData()) { | |
89 request_body = new ResourceRequestBody(); | |
90 request_body->AppendBytes( | |
91 reinterpret_cast<const char*>( | |
92 entry.GetBrowserInitiatedPostData()->front()), | |
93 entry.GetBrowserInitiatedPostData()->size()); | |
94 } | |
95 } | |
96 | 87 |
97 std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest( | 88 std::unique_ptr<NavigationRequest> navigation_request(new NavigationRequest( |
98 frame_tree_node, entry.ConstructCommonNavigationParams( | 89 frame_tree_node, |
99 frame_entry, dest_url, dest_referrer, | 90 entry.ConstructCommonNavigationParams( |
100 navigation_type, lofi_state, navigation_start), | 91 frame_entry, |
92 false, // |force_post_method|, ignored in PlzNavigate mode. | |
93 dest_url, dest_referrer, navigation_type, lofi_state, | |
94 navigation_start), | |
101 BeginNavigationParams(headers.ToString(), | 95 BeginNavigationParams(headers.ToString(), |
102 LoadFlagFromNavigationType(navigation_type), | 96 LoadFlagFromNavigationType(navigation_type), |
103 false, // has_user_gestures | 97 false, // has_user_gestures |
104 false, // skip_service_worker | 98 false, // skip_service_worker |
105 REQUEST_CONTEXT_TYPE_LOCATION), | 99 REQUEST_CONTEXT_TYPE_LOCATION), |
106 entry.ConstructRequestNavigationParams( | 100 entry.ConstructRequestNavigationParams( |
107 frame_entry, is_same_document_history_load, | 101 frame_entry, is_same_document_history_load, |
108 frame_tree_node->has_committed_real_load(), | 102 frame_tree_node->has_committed_real_load(), |
109 controller->GetPendingEntryIndex() == -1, | 103 controller->GetPendingEntryIndex() == -1, |
110 controller->GetIndexOfEntry(&entry), | 104 controller->GetIndexOfEntry(&entry), |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
212 state_ = STARTED; | 206 state_ = STARTED; |
213 RenderFrameDevToolsAgentHost::OnBeforeNavigation(navigation_handle_.get()); | 207 RenderFrameDevToolsAgentHost::OnBeforeNavigation(navigation_handle_.get()); |
214 | 208 |
215 if (ShouldMakeNetworkRequestForURL(common_params_.url)) { | 209 if (ShouldMakeNetworkRequestForURL(common_params_.url)) { |
216 // It's safe to use base::Unretained because this NavigationRequest owns | 210 // It's safe to use base::Unretained because this NavigationRequest owns |
217 // the NavigationHandle where the callback will be stored. | 211 // the NavigationHandle where the callback will be stored. |
218 // TODO(clamy): pass the real value for |is_external_protocol| if needed. | 212 // TODO(clamy): pass the real value for |is_external_protocol| if needed. |
219 // TODO(clamy): pass the method to the NavigationHandle instead of a | 213 // TODO(clamy): pass the method to the NavigationHandle instead of a |
220 // boolean. | 214 // boolean. |
221 navigation_handle_->WillStartRequest( | 215 navigation_handle_->WillStartRequest( |
222 common_params_.method, Referrer::SanitizeForRequest( | 216 common_params_.method, info_->request_body, |
223 common_params_.url, common_params_.referrer), | 217 Referrer::SanitizeForRequest(common_params_.url, |
218 common_params_.referrer), | |
224 begin_params_.has_user_gesture, common_params_.transition, false, | 219 begin_params_.has_user_gesture, common_params_.transition, false, |
225 base::Bind(&NavigationRequest::OnStartChecksComplete, | 220 base::Bind(&NavigationRequest::OnStartChecksComplete, |
226 base::Unretained(this))); | 221 base::Unretained(this))); |
227 return; | 222 return; |
228 } | 223 } |
229 | 224 |
230 // There is no need to make a network request for this navigation, so commit | 225 // There is no need to make a network request for this navigation, so commit |
231 // it immediately. | 226 // it immediately. |
232 state_ = RESPONSE_STARTED; | 227 state_ = RESPONSE_STARTED; |
233 | 228 |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
467 browser_context, navigating_frame_host->GetSiteInstance()); | 462 browser_context, navigating_frame_host->GetSiteInstance()); |
468 DCHECK(partition); | 463 DCHECK(partition); |
469 | 464 |
470 ServiceWorkerContextWrapper* service_worker_context = | 465 ServiceWorkerContextWrapper* service_worker_context = |
471 static_cast<ServiceWorkerContextWrapper*>( | 466 static_cast<ServiceWorkerContextWrapper*>( |
472 partition->GetServiceWorkerContext()); | 467 partition->GetServiceWorkerContext()); |
473 navigation_handle_->InitServiceWorkerHandle(service_worker_context); | 468 navigation_handle_->InitServiceWorkerHandle(service_worker_context); |
474 } | 469 } |
475 | 470 |
476 } // namespace content | 471 } // namespace content |
OLD | NEW |