| 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 "base/logging.h" | 9 #include "base/logging.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/common/resource_request_body_impl.h" |
| 17 #include "content/public/browser/content_browser_client.h" | 17 #include "content/public/browser/content_browser_client.h" |
| 18 #include "content/public/common/browser_side_navigation_policy.h" | 18 #include "content/public/common/browser_side_navigation_policy.h" |
| 19 #include "content/public/common/content_client.h" | 19 #include "content/public/common/content_client.h" |
| 20 #include "net/url_request/redirect_info.h" | 20 #include "net/url_request/redirect_info.h" |
| 21 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 22 #include "url/url_constants.h" | 22 #include "url/url_constants.h" |
| 23 | 23 |
| 24 namespace content { | 24 namespace content { |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 248 |
| 249 NavigationThrottle::ThrottleCheckResult | 249 NavigationThrottle::ThrottleCheckResult |
| 250 NavigationHandleImpl::CallWillStartRequestForTesting( | 250 NavigationHandleImpl::CallWillStartRequestForTesting( |
| 251 bool is_post, | 251 bool is_post, |
| 252 const Referrer& sanitized_referrer, | 252 const Referrer& sanitized_referrer, |
| 253 bool has_user_gesture, | 253 bool has_user_gesture, |
| 254 ui::PageTransition transition, | 254 ui::PageTransition transition, |
| 255 bool is_external_protocol) { | 255 bool is_external_protocol) { |
| 256 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; | 256 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; |
| 257 | 257 |
| 258 scoped_refptr<ResourceRequestBody> resource_request_body; | 258 scoped_refptr<ResourceRequestBodyImpl> resource_request_body; |
| 259 std::string method = "GET"; | 259 std::string method = "GET"; |
| 260 if (is_post) { | 260 if (is_post) { |
| 261 method = "POST"; | 261 method = "POST"; |
| 262 | 262 |
| 263 std::string body = "test=body"; | 263 std::string body = "test=body"; |
| 264 resource_request_body = new ResourceRequestBody(); | 264 resource_request_body = new ResourceRequestBodyImpl(); |
| 265 resource_request_body->AppendBytes(body.data(), body.size()); | 265 resource_request_body->AppendBytes(body.data(), body.size()); |
| 266 } | 266 } |
| 267 | 267 |
| 268 WillStartRequest(method, resource_request_body, sanitized_referrer, | 268 WillStartRequest(method, resource_request_body, sanitized_referrer, |
| 269 has_user_gesture, transition, is_external_protocol, | 269 has_user_gesture, transition, is_external_protocol, |
| 270 base::Bind(&UpdateThrottleCheckResult, &result)); | 270 base::Bind(&UpdateThrottleCheckResult, &result)); |
| 271 | 271 |
| 272 // Reset the callback to ensure it will not be called later. | 272 // Reset the callback to ensure it will not be called later. |
| 273 complete_callback_.Reset(); | 273 complete_callback_.Reset(); |
| 274 return result; | 274 return result; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 297 | 297 |
| 298 void NavigationHandleImpl::InitServiceWorkerHandle( | 298 void NavigationHandleImpl::InitServiceWorkerHandle( |
| 299 ServiceWorkerContextWrapper* service_worker_context) { | 299 ServiceWorkerContextWrapper* service_worker_context) { |
| 300 DCHECK(IsBrowserSideNavigationEnabled()); | 300 DCHECK(IsBrowserSideNavigationEnabled()); |
| 301 service_worker_handle_.reset( | 301 service_worker_handle_.reset( |
| 302 new ServiceWorkerNavigationHandle(service_worker_context)); | 302 new ServiceWorkerNavigationHandle(service_worker_context)); |
| 303 } | 303 } |
| 304 | 304 |
| 305 void NavigationHandleImpl::WillStartRequest( | 305 void NavigationHandleImpl::WillStartRequest( |
| 306 const std::string& method, | 306 const std::string& method, |
| 307 scoped_refptr<content::ResourceRequestBody> resource_request_body, | 307 scoped_refptr<content::ResourceRequestBodyImpl> resource_request_body, |
| 308 const Referrer& sanitized_referrer, | 308 const Referrer& sanitized_referrer, |
| 309 bool has_user_gesture, | 309 bool has_user_gesture, |
| 310 ui::PageTransition transition, | 310 ui::PageTransition transition, |
| 311 bool is_external_protocol, | 311 bool is_external_protocol, |
| 312 const ThrottleChecksFinishedCallback& callback) { | 312 const ThrottleChecksFinishedCallback& callback) { |
| 313 // |method != "POST"| should imply absence of |resource_request_body|. | 313 // |method != "POST"| should imply absence of |resource_request_body|. |
| 314 if (method != "POST" && resource_request_body) { | 314 if (method != "POST" && resource_request_body) { |
| 315 NOTREACHED(); | 315 NOTREACHED(); |
| 316 resource_request_body = nullptr; | 316 resource_request_body = nullptr; |
| 317 } | 317 } |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 complete_callback_.Reset(); | 531 complete_callback_.Reset(); |
| 532 | 532 |
| 533 if (!callback.is_null()) | 533 if (!callback.is_null()) |
| 534 callback.Run(result); | 534 callback.Run(result); |
| 535 | 535 |
| 536 // No code after running the callback, as it might have resulted in our | 536 // No code after running the callback, as it might have resulted in our |
| 537 // destruction. | 537 // destruction. |
| 538 } | 538 } |
| 539 | 539 |
| 540 } // namespace content | 540 } // namespace content |
| OLD | NEW |