| 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 18 matching lines...) Expand all Loading... |
| 275 | 276 |
| 276 void NavigationHandleImpl::InitServiceWorkerHandle( | 277 void NavigationHandleImpl::InitServiceWorkerHandle( |
| 277 ServiceWorkerContextWrapper* service_worker_context) { | 278 ServiceWorkerContextWrapper* service_worker_context) { |
| 278 DCHECK(IsBrowserSideNavigationEnabled()); | 279 DCHECK(IsBrowserSideNavigationEnabled()); |
| 279 service_worker_handle_.reset( | 280 service_worker_handle_.reset( |
| 280 new ServiceWorkerNavigationHandle(service_worker_context)); | 281 new ServiceWorkerNavigationHandle(service_worker_context)); |
| 281 } | 282 } |
| 282 | 283 |
| 283 void NavigationHandleImpl::WillStartRequest( | 284 void NavigationHandleImpl::WillStartRequest( |
| 284 const std::string& method, | 285 const std::string& method, |
| 286 const scoped_refptr<content::ResourceRequestBody>& resource_request_body, |
| 285 const Referrer& sanitized_referrer, | 287 const Referrer& sanitized_referrer, |
| 286 bool has_user_gesture, | 288 bool has_user_gesture, |
| 287 ui::PageTransition transition, | 289 ui::PageTransition transition, |
| 288 bool is_external_protocol, | 290 bool is_external_protocol, |
| 289 const ThrottleChecksFinishedCallback& callback) { | 291 const ThrottleChecksFinishedCallback& callback) { |
| 290 // Update the navigation parameters. | 292 // Update the navigation parameters. |
| 291 method_ = method; | 293 method_ = method; |
| 294 resource_request_body_ = resource_request_body; |
| 292 sanitized_referrer_ = sanitized_referrer; | 295 sanitized_referrer_ = sanitized_referrer; |
| 293 has_user_gesture_ = has_user_gesture; | 296 has_user_gesture_ = has_user_gesture; |
| 294 transition_ = transition; | 297 transition_ = transition; |
| 295 is_external_protocol_ = is_external_protocol; | 298 is_external_protocol_ = is_external_protocol; |
| 296 | 299 |
| 297 state_ = WILL_SEND_REQUEST; | 300 state_ = WILL_SEND_REQUEST; |
| 298 complete_callback_ = callback; | 301 complete_callback_ = callback; |
| 299 | 302 |
| 300 // Register the platform's navigation throttles. | 303 // Register the platform's navigation throttles. |
| 301 std::unique_ptr<content::NavigationThrottle> ancestor_throttle = | 304 std::unique_ptr<content::NavigationThrottle> ancestor_throttle = |
| (...skipping 26 matching lines...) Expand all Loading... |
| 328 scoped_refptr<net::HttpResponseHeaders> response_headers, | 331 scoped_refptr<net::HttpResponseHeaders> response_headers, |
| 329 const ThrottleChecksFinishedCallback& callback) { | 332 const ThrottleChecksFinishedCallback& callback) { |
| 330 // Update the navigation parameters. | 333 // Update the navigation parameters. |
| 331 url_ = new_url; | 334 url_ = new_url; |
| 332 method_ = new_method; | 335 method_ = new_method; |
| 333 sanitized_referrer_.url = new_referrer_url; | 336 sanitized_referrer_.url = new_referrer_url; |
| 334 sanitized_referrer_ = Referrer::SanitizeForRequest(url_, sanitized_referrer_); | 337 sanitized_referrer_ = Referrer::SanitizeForRequest(url_, sanitized_referrer_); |
| 335 is_external_protocol_ = new_is_external_protocol; | 338 is_external_protocol_ = new_is_external_protocol; |
| 336 response_headers_ = response_headers; | 339 response_headers_ = response_headers; |
| 337 was_redirected_ = true; | 340 was_redirected_ = true; |
| 341 if (new_method != "POST") |
| 342 resource_request_body_ = nullptr; |
| 338 | 343 |
| 339 state_ = WILL_REDIRECT_REQUEST; | 344 state_ = WILL_REDIRECT_REQUEST; |
| 340 complete_callback_ = callback; | 345 complete_callback_ = callback; |
| 341 | 346 |
| 342 // Notify each throttle of the request. | 347 // Notify each throttle of the request. |
| 343 NavigationThrottle::ThrottleCheckResult result = CheckWillRedirectRequest(); | 348 NavigationThrottle::ThrottleCheckResult result = CheckWillRedirectRequest(); |
| 344 | 349 |
| 345 // If the navigation is not deferred, run the callback. | 350 // If the navigation is not deferred, run the callback. |
| 346 if (result != NavigationThrottle::DEFER) | 351 if (result != NavigationThrottle::DEFER) |
| 347 RunCompleteCallback(result); | 352 RunCompleteCallback(result); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 complete_callback_.Reset(); | 507 complete_callback_.Reset(); |
| 503 | 508 |
| 504 if (!callback.is_null()) | 509 if (!callback.is_null()) |
| 505 callback.Run(result); | 510 callback.Run(result); |
| 506 | 511 |
| 507 // No code after running the callback, as it might have resulted in our | 512 // No code after running the callback, as it might have resulted in our |
| 508 // destruction. | 513 // destruction. |
| 509 } | 514 } |
| 510 | 515 |
| 511 } // namespace content | 516 } // namespace content |
| OLD | NEW |