OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_handle_impl.h" | 5 #include "content/browser/frame_host/navigation_handle_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "content/browser/frame_host/ancestor_throttle.h" | 9 #include "content/browser/frame_host/ancestor_throttle.h" |
10 #include "content/browser/frame_host/frame_tree_node.h" | 10 #include "content/browser/frame_host/frame_tree_node.h" |
11 #include "content/browser/frame_host/navigator.h" | 11 #include "content/browser/frame_host/navigator.h" |
12 #include "content/browser/frame_host/navigator_delegate.h" | 12 #include "content/browser/frame_host/navigator_delegate.h" |
13 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 13 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
14 #include "content/browser/service_worker/service_worker_navigation_handle.h" | 14 #include "content/browser/service_worker/service_worker_navigation_handle.h" |
15 #include "content/common/frame_messages.h" | 15 #include "content/common/frame_messages.h" |
| 16 #include "content/common/resource_request_body.h" |
16 #include "content/public/browser/content_browser_client.h" | 17 #include "content/public/browser/content_browser_client.h" |
17 #include "content/public/common/browser_side_navigation_policy.h" | 18 #include "content/public/common/browser_side_navigation_policy.h" |
18 #include "content/public/common/content_client.h" | 19 #include "content/public/common/content_client.h" |
19 #include "net/url_request/redirect_info.h" | 20 #include "net/url_request/redirect_info.h" |
20 | 21 |
21 namespace content { | 22 namespace content { |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 void UpdateThrottleCheckResult( | 26 void UpdateThrottleCheckResult( |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 } | 237 } |
237 | 238 |
238 NavigationThrottle::ThrottleCheckResult | 239 NavigationThrottle::ThrottleCheckResult |
239 NavigationHandleImpl::CallWillStartRequestForTesting( | 240 NavigationHandleImpl::CallWillStartRequestForTesting( |
240 bool is_post, | 241 bool is_post, |
241 const Referrer& sanitized_referrer, | 242 const Referrer& sanitized_referrer, |
242 bool has_user_gesture, | 243 bool has_user_gesture, |
243 ui::PageTransition transition, | 244 ui::PageTransition transition, |
244 bool is_external_protocol) { | 245 bool is_external_protocol) { |
245 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; | 246 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; |
246 WillStartRequest(is_post ? "POST" : "GET", sanitized_referrer, | 247 WillStartRequest(is_post ? "POST" : "GET", nullptr, sanitized_referrer, |
247 has_user_gesture, transition, is_external_protocol, | 248 has_user_gesture, transition, is_external_protocol, |
248 base::Bind(&UpdateThrottleCheckResult, &result)); | 249 base::Bind(&UpdateThrottleCheckResult, &result)); |
249 | 250 |
250 // Reset the callback to ensure it will not be called later. | 251 // Reset the callback to ensure it will not be called later. |
251 complete_callback_.Reset(); | 252 complete_callback_.Reset(); |
252 return result; | 253 return result; |
253 } | 254 } |
254 | 255 |
255 NavigationThrottle::ThrottleCheckResult | 256 NavigationThrottle::ThrottleCheckResult |
256 NavigationHandleImpl::CallWillRedirectRequestForTesting( | 257 NavigationHandleImpl::CallWillRedirectRequestForTesting( |
(...skipping 14 matching lines...) Expand all Loading... |
271 | 272 |
272 void NavigationHandleImpl::InitServiceWorkerHandle( | 273 void NavigationHandleImpl::InitServiceWorkerHandle( |
273 ServiceWorkerContextWrapper* service_worker_context) { | 274 ServiceWorkerContextWrapper* service_worker_context) { |
274 DCHECK(IsBrowserSideNavigationEnabled()); | 275 DCHECK(IsBrowserSideNavigationEnabled()); |
275 service_worker_handle_.reset( | 276 service_worker_handle_.reset( |
276 new ServiceWorkerNavigationHandle(service_worker_context)); | 277 new ServiceWorkerNavigationHandle(service_worker_context)); |
277 } | 278 } |
278 | 279 |
279 void NavigationHandleImpl::WillStartRequest( | 280 void NavigationHandleImpl::WillStartRequest( |
280 const std::string& method, | 281 const std::string& method, |
| 282 const scoped_refptr<content::ResourceRequestBody>& resource_request_body, |
281 const Referrer& sanitized_referrer, | 283 const Referrer& sanitized_referrer, |
282 bool has_user_gesture, | 284 bool has_user_gesture, |
283 ui::PageTransition transition, | 285 ui::PageTransition transition, |
284 bool is_external_protocol, | 286 bool is_external_protocol, |
285 const ThrottleChecksFinishedCallback& callback) { | 287 const ThrottleChecksFinishedCallback& callback) { |
286 // Update the navigation parameters. | 288 // Update the navigation parameters. |
287 method_ = method; | 289 method_ = method; |
| 290 resource_request_body_ = resource_request_body; |
288 sanitized_referrer_ = sanitized_referrer; | 291 sanitized_referrer_ = sanitized_referrer; |
289 has_user_gesture_ = has_user_gesture; | 292 has_user_gesture_ = has_user_gesture; |
290 transition_ = transition; | 293 transition_ = transition; |
291 is_external_protocol_ = is_external_protocol; | 294 is_external_protocol_ = is_external_protocol; |
292 | 295 |
293 state_ = WILL_SEND_REQUEST; | 296 state_ = WILL_SEND_REQUEST; |
294 complete_callback_ = callback; | 297 complete_callback_ = callback; |
295 | 298 |
296 // Register the platform's navigation throttles. | 299 // Register the platform's navigation throttles. |
297 std::unique_ptr<content::NavigationThrottle> ancestor_throttle = | 300 std::unique_ptr<content::NavigationThrottle> ancestor_throttle = |
(...skipping 26 matching lines...) Expand all Loading... |
324 scoped_refptr<net::HttpResponseHeaders> response_headers, | 327 scoped_refptr<net::HttpResponseHeaders> response_headers, |
325 const ThrottleChecksFinishedCallback& callback) { | 328 const ThrottleChecksFinishedCallback& callback) { |
326 // Update the navigation parameters. | 329 // Update the navigation parameters. |
327 url_ = new_url; | 330 url_ = new_url; |
328 method_ = new_method; | 331 method_ = new_method; |
329 sanitized_referrer_.url = new_referrer_url; | 332 sanitized_referrer_.url = new_referrer_url; |
330 sanitized_referrer_ = Referrer::SanitizeForRequest(url_, sanitized_referrer_); | 333 sanitized_referrer_ = Referrer::SanitizeForRequest(url_, sanitized_referrer_); |
331 is_external_protocol_ = new_is_external_protocol; | 334 is_external_protocol_ = new_is_external_protocol; |
332 response_headers_ = response_headers; | 335 response_headers_ = response_headers; |
333 was_redirected_ = true; | 336 was_redirected_ = true; |
| 337 if (new_method != "POST") |
| 338 resource_request_body_ = nullptr; |
334 | 339 |
335 state_ = WILL_REDIRECT_REQUEST; | 340 state_ = WILL_REDIRECT_REQUEST; |
336 complete_callback_ = callback; | 341 complete_callback_ = callback; |
337 | 342 |
338 // Notify each throttle of the request. | 343 // Notify each throttle of the request. |
339 NavigationThrottle::ThrottleCheckResult result = CheckWillRedirectRequest(); | 344 NavigationThrottle::ThrottleCheckResult result = CheckWillRedirectRequest(); |
340 | 345 |
341 // If the navigation is not deferred, run the callback. | 346 // If the navigation is not deferred, run the callback. |
342 if (result != NavigationThrottle::DEFER) | 347 if (result != NavigationThrottle::DEFER) |
343 RunCompleteCallback(result); | 348 RunCompleteCallback(result); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 complete_callback_.Reset(); | 503 complete_callback_.Reset(); |
499 | 504 |
500 if (!callback.is_null()) | 505 if (!callback.is_null()) |
501 callback.Run(result); | 506 callback.Run(result); |
502 | 507 |
503 // No code after running the callback, as it might have resulted in our | 508 // No code after running the callback, as it might have resulted in our |
504 // destruction. | 509 // destruction. |
505 } | 510 } |
506 | 511 |
507 } // namespace content | 512 } // namespace content |
OLD | NEW |