| 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" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 if (state_ == DEFERRING_START) { | 198 if (state_ == DEFERRING_START) { |
| 199 result = CheckWillStartRequest(); | 199 result = CheckWillStartRequest(); |
| 200 } else if (state_ == DEFERRING_REDIRECT) { | 200 } else if (state_ == DEFERRING_REDIRECT) { |
| 201 result = CheckWillRedirectRequest(); | 201 result = CheckWillRedirectRequest(); |
| 202 } else { | 202 } else { |
| 203 result = CheckWillProcessResponse(); | 203 result = CheckWillProcessResponse(); |
| 204 | 204 |
| 205 // If the navigation is about to proceed after processing the response, then | 205 // If the navigation is about to proceed after processing the response, then |
| 206 // it's ready to commit. | 206 // it's ready to commit. |
| 207 if (result == NavigationThrottle::PROCEED) | 207 if (result == NavigationThrottle::PROCEED) |
| 208 ReadyToCommitNavigation(render_frame_host_, response_headers_); | 208 ReadyToCommitNavigation(render_frame_host_); |
| 209 } | 209 } |
| 210 | 210 |
| 211 if (result != NavigationThrottle::DEFER) | 211 if (result != NavigationThrottle::DEFER) |
| 212 RunCompleteCallback(result); | 212 RunCompleteCallback(result); |
| 213 } | 213 } |
| 214 | 214 |
| 215 void NavigationHandleImpl::CancelDeferredNavigation( | 215 void NavigationHandleImpl::CancelDeferredNavigation( |
| 216 NavigationThrottle::ThrottleCheckResult result) { | 216 NavigationThrottle::ThrottleCheckResult result) { |
| 217 DCHECK(state_ == DEFERRING_START || state_ == DEFERRING_REDIRECT); | 217 DCHECK(state_ == DEFERRING_START || state_ == DEFERRING_REDIRECT); |
| 218 DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE || | 218 DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE || |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 render_frame_host_ = render_frame_host; | 339 render_frame_host_ = render_frame_host; |
| 340 response_headers_ = response_headers; | 340 response_headers_ = response_headers; |
| 341 state_ = WILL_PROCESS_RESPONSE; | 341 state_ = WILL_PROCESS_RESPONSE; |
| 342 complete_callback_ = callback; | 342 complete_callback_ = callback; |
| 343 | 343 |
| 344 // Notify each throttle of the response. | 344 // Notify each throttle of the response. |
| 345 NavigationThrottle::ThrottleCheckResult result = CheckWillProcessResponse(); | 345 NavigationThrottle::ThrottleCheckResult result = CheckWillProcessResponse(); |
| 346 | 346 |
| 347 // If the navigation is about to proceed, then it's ready to commit. | 347 // If the navigation is about to proceed, then it's ready to commit. |
| 348 if (result == NavigationThrottle::PROCEED) | 348 if (result == NavigationThrottle::PROCEED) |
| 349 ReadyToCommitNavigation(render_frame_host, response_headers); | 349 ReadyToCommitNavigation(render_frame_host); |
| 350 | 350 |
| 351 // If the navigation is not deferred, run the callback. | 351 // If the navigation is not deferred, run the callback. |
| 352 if (result != NavigationThrottle::DEFER) | 352 if (result != NavigationThrottle::DEFER) |
| 353 RunCompleteCallback(result); | 353 RunCompleteCallback(result); |
| 354 } | 354 } |
| 355 | 355 |
| 356 void NavigationHandleImpl::ReadyToCommitNavigation( | 356 void NavigationHandleImpl::ReadyToCommitNavigation( |
| 357 RenderFrameHostImpl* render_frame_host, | 357 RenderFrameHostImpl* render_frame_host) { |
| 358 scoped_refptr<net::HttpResponseHeaders> response_headers) { | |
| 359 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); | 358 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); |
| 360 render_frame_host_ = render_frame_host; | 359 render_frame_host_ = render_frame_host; |
| 361 response_headers_ = response_headers; | |
| 362 state_ = READY_TO_COMMIT; | 360 state_ = READY_TO_COMMIT; |
| 363 | 361 |
| 364 // Only notify the WebContentsObservers when PlzNavigate is enabled, as | 362 // Only notify the WebContentsObservers when PlzNavigate is enabled, as |
| 365 // |render_frame_host_| may be wrong in the case of transfer navigations. | 363 // |render_frame_host_| may be wrong in the case of transfer navigations. |
| 366 if (IsBrowserSideNavigationEnabled()) | 364 if (IsBrowserSideNavigationEnabled()) |
| 367 GetDelegate()->ReadyToCommitNavigation(this); | 365 GetDelegate()->ReadyToCommitNavigation(this); |
| 368 } | 366 } |
| 369 | 367 |
| 370 void NavigationHandleImpl::DidCommitNavigation( | 368 void NavigationHandleImpl::DidCommitNavigation( |
| 371 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, | 369 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 complete_callback_.Reset(); | 485 complete_callback_.Reset(); |
| 488 | 486 |
| 489 if (!callback.is_null()) | 487 if (!callback.is_null()) |
| 490 callback.Run(result); | 488 callback.Run(result); |
| 491 | 489 |
| 492 // No code after running the callback, as it might have resulted in our | 490 // No code after running the callback, as it might have resulted in our |
| 493 // destruction. | 491 // destruction. |
| 494 } | 492 } |
| 495 | 493 |
| 496 } // namespace content | 494 } // namespace content |
| OLD | NEW |