| 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/frame_tree_node.h" | 9 #include "content/browser/frame_host/frame_tree_node.h" |
| 10 #include "content/browser/frame_host/navigator.h" | 10 #include "content/browser/frame_host/navigator.h" |
| 11 #include "content/browser/frame_host/navigator_delegate.h" | 11 #include "content/browser/frame_host/navigator_delegate.h" |
| 12 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 12 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 13 #include "content/browser/service_worker/service_worker_navigation_handle.h" | 13 #include "content/browser/service_worker/service_worker_navigation_handle.h" |
| 14 #include "content/common/frame_messages.h" | 14 #include "content/common/frame_messages.h" |
| 15 #include "content/common/resource_request_body.h" | 15 #include "content/common/resource_request_body_impl.h" |
| 16 #include "content/public/browser/content_browser_client.h" | 16 #include "content/public/browser/content_browser_client.h" |
| 17 #include "content/public/common/browser_side_navigation_policy.h" | 17 #include "content/public/common/browser_side_navigation_policy.h" |
| 18 #include "content/public/common/content_client.h" | 18 #include "content/public/common/content_client.h" |
| 19 #include "net/url_request/redirect_info.h" | 19 #include "net/url_request/redirect_info.h" |
| 20 | 20 |
| 21 namespace content { | 21 namespace content { |
| 22 | 22 |
| 23 namespace { | 23 namespace { |
| 24 | 24 |
| 25 void UpdateThrottleCheckResult( | 25 void UpdateThrottleCheckResult( |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 | 245 |
| 246 NavigationThrottle::ThrottleCheckResult | 246 NavigationThrottle::ThrottleCheckResult |
| 247 NavigationHandleImpl::CallWillStartRequestForTesting( | 247 NavigationHandleImpl::CallWillStartRequestForTesting( |
| 248 bool is_post, | 248 bool is_post, |
| 249 const Referrer& sanitized_referrer, | 249 const Referrer& sanitized_referrer, |
| 250 bool has_user_gesture, | 250 bool has_user_gesture, |
| 251 ui::PageTransition transition, | 251 ui::PageTransition transition, |
| 252 bool is_external_protocol) { | 252 bool is_external_protocol) { |
| 253 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; | 253 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; |
| 254 | 254 |
| 255 scoped_refptr<ResourceRequestBody> resource_request_body; | 255 scoped_refptr<ResourceRequestBodyImpl> resource_request_body; |
| 256 std::string method = "GET"; | 256 std::string method = "GET"; |
| 257 if (is_post) { | 257 if (is_post) { |
| 258 method = "POST"; | 258 method = "POST"; |
| 259 | 259 |
| 260 std::string body = "test=body"; | 260 std::string body = "test=body"; |
| 261 resource_request_body = new ResourceRequestBody(); | 261 resource_request_body = new ResourceRequestBodyImpl(); |
| 262 resource_request_body->AppendBytes(body.data(), body.size()); | 262 resource_request_body->AppendBytes(body.data(), body.size()); |
| 263 } | 263 } |
| 264 | 264 |
| 265 WillStartRequest(method, resource_request_body, sanitized_referrer, | 265 WillStartRequest(method, resource_request_body, sanitized_referrer, |
| 266 has_user_gesture, transition, is_external_protocol, | 266 has_user_gesture, transition, is_external_protocol, |
| 267 base::Bind(&UpdateThrottleCheckResult, &result)); | 267 base::Bind(&UpdateThrottleCheckResult, &result)); |
| 268 | 268 |
| 269 // Reset the callback to ensure it will not be called later. | 269 // Reset the callback to ensure it will not be called later. |
| 270 complete_callback_.Reset(); | 270 complete_callback_.Reset(); |
| 271 return result; | 271 return result; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 294 | 294 |
| 295 void NavigationHandleImpl::InitServiceWorkerHandle( | 295 void NavigationHandleImpl::InitServiceWorkerHandle( |
| 296 ServiceWorkerContextWrapper* service_worker_context) { | 296 ServiceWorkerContextWrapper* service_worker_context) { |
| 297 DCHECK(IsBrowserSideNavigationEnabled()); | 297 DCHECK(IsBrowserSideNavigationEnabled()); |
| 298 service_worker_handle_.reset( | 298 service_worker_handle_.reset( |
| 299 new ServiceWorkerNavigationHandle(service_worker_context)); | 299 new ServiceWorkerNavigationHandle(service_worker_context)); |
| 300 } | 300 } |
| 301 | 301 |
| 302 void NavigationHandleImpl::WillStartRequest( | 302 void NavigationHandleImpl::WillStartRequest( |
| 303 const std::string& method, | 303 const std::string& method, |
| 304 const scoped_refptr<content::ResourceRequestBody>& resource_request_body, | 304 const scoped_refptr<content::ResourceRequestBodyImpl>& |
| 305 resource_request_body, |
| 305 const Referrer& sanitized_referrer, | 306 const Referrer& sanitized_referrer, |
| 306 bool has_user_gesture, | 307 bool has_user_gesture, |
| 307 ui::PageTransition transition, | 308 ui::PageTransition transition, |
| 308 bool is_external_protocol, | 309 bool is_external_protocol, |
| 309 const ThrottleChecksFinishedCallback& callback) { | 310 const ThrottleChecksFinishedCallback& callback) { |
| 310 // |method != "POST"| should imply absence of |resource_request_body|. | 311 // |method != "POST"| should imply absence of |resource_request_body|. |
| 311 DCHECK(method == "POST" || !resource_request_body); | 312 DCHECK(method == "POST" || !resource_request_body); |
| 312 | 313 |
| 313 // Update the navigation parameters. | 314 // Update the navigation parameters. |
| 314 method_ = method; | 315 method_ = method; |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 complete_callback_.Reset(); | 525 complete_callback_.Reset(); |
| 525 | 526 |
| 526 if (!callback.is_null()) | 527 if (!callback.is_null()) |
| 527 callback.Run(result); | 528 callback.Run(result); |
| 528 | 529 |
| 529 // No code after running the callback, as it might have resulted in our | 530 // No code after running the callback, as it might have resulted in our |
| 530 // destruction. | 531 // destruction. |
| 531 } | 532 } |
| 532 | 533 |
| 533 } // namespace content | 534 } // namespace content |
| OLD | NEW |