| 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/devtools/render_frame_devtools_agent_host.h" | 10 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 is_renderer_initiated_(is_renderer_initiated), | 65 is_renderer_initiated_(is_renderer_initiated), |
| 66 is_same_page_(false), | 66 is_same_page_(false), |
| 67 is_synchronous_(is_synchronous), | 67 is_synchronous_(is_synchronous), |
| 68 is_srcdoc_(is_srcdoc), | 68 is_srcdoc_(is_srcdoc), |
| 69 was_redirected_(false), | 69 was_redirected_(false), |
| 70 state_(INITIAL), | 70 state_(INITIAL), |
| 71 is_transferring_(false), | 71 is_transferring_(false), |
| 72 frame_tree_node_(frame_tree_node), | 72 frame_tree_node_(frame_tree_node), |
| 73 next_index_(0), | 73 next_index_(0), |
| 74 navigation_start_(navigation_start), | 74 navigation_start_(navigation_start), |
| 75 pending_nav_entry_id_(pending_nav_entry_id) { | 75 pending_nav_entry_id_(pending_nav_entry_id), |
| 76 fetch_request_context_type_(REQUEST_CONTEXT_TYPE_UNSPECIFIED) { |
| 76 DCHECK(!navigation_start.is_null()); | 77 DCHECK(!navigation_start.is_null()); |
| 77 GetDelegate()->DidStartNavigation(this); | 78 GetDelegate()->DidStartNavigation(this); |
| 78 | 79 |
| 79 if (IsInMainFrame()) { | 80 if (IsInMainFrame()) { |
| 80 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( | 81 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( |
| 81 "navigation", "Navigation StartToCommit", this, | 82 "navigation", "Navigation StartToCommit", this, |
| 82 navigation_start.ToInternalValue(), "Initial URL", url_.spec()); | 83 navigation_start.ToInternalValue(), "Initial URL", url_.spec()); |
| 83 } | 84 } |
| 84 } | 85 } |
| 85 | 86 |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 if (is_post) { | 264 if (is_post) { |
| 264 method = "POST"; | 265 method = "POST"; |
| 265 | 266 |
| 266 std::string body = "test=body"; | 267 std::string body = "test=body"; |
| 267 resource_request_body = new ResourceRequestBodyImpl(); | 268 resource_request_body = new ResourceRequestBodyImpl(); |
| 268 resource_request_body->AppendBytes(body.data(), body.size()); | 269 resource_request_body->AppendBytes(body.data(), body.size()); |
| 269 } | 270 } |
| 270 | 271 |
| 271 WillStartRequest(method, resource_request_body, sanitized_referrer, | 272 WillStartRequest(method, resource_request_body, sanitized_referrer, |
| 272 has_user_gesture, transition, is_external_protocol, | 273 has_user_gesture, transition, is_external_protocol, |
| 274 REQUEST_CONTEXT_TYPE_LOCATION, |
| 273 base::Bind(&UpdateThrottleCheckResult, &result)); | 275 base::Bind(&UpdateThrottleCheckResult, &result)); |
| 274 | 276 |
| 275 // Reset the callback to ensure it will not be called later. | 277 // Reset the callback to ensure it will not be called later. |
| 276 complete_callback_.Reset(); | 278 complete_callback_.Reset(); |
| 277 return result; | 279 return result; |
| 278 } | 280 } |
| 279 | 281 |
| 280 NavigationThrottle::ThrottleCheckResult | 282 NavigationThrottle::ThrottleCheckResult |
| 281 NavigationHandleImpl::CallWillRedirectRequestForTesting( | 283 NavigationHandleImpl::CallWillRedirectRequestForTesting( |
| 282 const GURL& new_url, | 284 const GURL& new_url, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 298 return navigation_data_.get(); | 300 return navigation_data_.get(); |
| 299 } | 301 } |
| 300 | 302 |
| 301 void NavigationHandleImpl::WillStartRequest( | 303 void NavigationHandleImpl::WillStartRequest( |
| 302 const std::string& method, | 304 const std::string& method, |
| 303 scoped_refptr<content::ResourceRequestBodyImpl> resource_request_body, | 305 scoped_refptr<content::ResourceRequestBodyImpl> resource_request_body, |
| 304 const Referrer& sanitized_referrer, | 306 const Referrer& sanitized_referrer, |
| 305 bool has_user_gesture, | 307 bool has_user_gesture, |
| 306 ui::PageTransition transition, | 308 ui::PageTransition transition, |
| 307 bool is_external_protocol, | 309 bool is_external_protocol, |
| 310 RequestContextType fetch_request_context_type, |
| 308 const ThrottleChecksFinishedCallback& callback) { | 311 const ThrottleChecksFinishedCallback& callback) { |
| 309 // |method != "POST"| should imply absence of |resource_request_body|. | 312 // |method != "POST"| should imply absence of |resource_request_body|. |
| 310 if (method != "POST" && resource_request_body) { | 313 if (method != "POST" && resource_request_body) { |
| 311 NOTREACHED(); | 314 NOTREACHED(); |
| 312 resource_request_body = nullptr; | 315 resource_request_body = nullptr; |
| 313 } | 316 } |
| 314 | 317 |
| 315 // Update the navigation parameters. | 318 // Update the navigation parameters. |
| 316 method_ = method; | 319 method_ = method; |
| 317 if (method_ == "POST") | 320 if (method_ == "POST") |
| 318 resource_request_body_ = resource_request_body; | 321 resource_request_body_ = resource_request_body; |
| 319 sanitized_referrer_ = sanitized_referrer; | 322 sanitized_referrer_ = sanitized_referrer; |
| 320 has_user_gesture_ = has_user_gesture; | 323 has_user_gesture_ = has_user_gesture; |
| 321 transition_ = transition; | 324 transition_ = transition; |
| 322 is_external_protocol_ = is_external_protocol; | 325 is_external_protocol_ = is_external_protocol; |
| 323 | 326 fetch_request_context_type_ = fetch_request_context_type; |
| 324 state_ = WILL_SEND_REQUEST; | 327 state_ = WILL_SEND_REQUEST; |
| 325 complete_callback_ = callback; | 328 complete_callback_ = callback; |
| 326 | 329 |
| 327 RegisterNavigationThrottles(); | 330 RegisterNavigationThrottles(); |
| 328 | 331 |
| 329 // Notify each throttle of the request. | 332 // Notify each throttle of the request. |
| 330 NavigationThrottle::ThrottleCheckResult result = CheckWillStartRequest(); | 333 NavigationThrottle::ThrottleCheckResult result = CheckWillStartRequest(); |
| 331 | 334 |
| 332 // If the navigation is not deferred, run the callback. | 335 // If the navigation is not deferred, run the callback. |
| 333 if (result != NavigationThrottle::DEFER) | 336 if (result != NavigationThrottle::DEFER) |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 throttles_to_register.end()); | 539 throttles_to_register.end()); |
| 537 throttles_to_register.weak_clear(); | 540 throttles_to_register.weak_clear(); |
| 538 } | 541 } |
| 539 std::unique_ptr<NavigationThrottle> devtools_throttle = | 542 std::unique_ptr<NavigationThrottle> devtools_throttle = |
| 540 RenderFrameDevToolsAgentHost::CreateThrottleForNavigation(this); | 543 RenderFrameDevToolsAgentHost::CreateThrottleForNavigation(this); |
| 541 if (devtools_throttle) | 544 if (devtools_throttle) |
| 542 throttles_.push_back(devtools_throttle.release()); | 545 throttles_.push_back(devtools_throttle.release()); |
| 543 } | 546 } |
| 544 | 547 |
| 545 } // namespace content | 548 } // namespace content |
| OLD | NEW |