| 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 "content/browser/frame_host/frame_tree_node.h" | 7 #include "content/browser/frame_host/frame_tree_node.h" |
| 8 #include "content/browser/frame_host/navigator.h" | 8 #include "content/browser/frame_host/navigator.h" |
| 9 #include "content/browser/frame_host/navigator_delegate.h" | 9 #include "content/browser/frame_host/navigator_delegate.h" |
| 10 #include "content/public/browser/content_browser_client.h" | 10 #include "content/public/browser/content_browser_client.h" |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 RenderFrameHostImpl* render_frame_host) { | 241 RenderFrameHostImpl* render_frame_host) { |
| 242 CHECK(!render_frame_host_); | 242 CHECK(!render_frame_host_); |
| 243 render_frame_host_ = render_frame_host; | 243 render_frame_host_ = render_frame_host; |
| 244 state_ = READY_TO_COMMIT; | 244 state_ = READY_TO_COMMIT; |
| 245 GetDelegate()->ReadyToCommitNavigation(this); | 245 GetDelegate()->ReadyToCommitNavigation(this); |
| 246 } | 246 } |
| 247 | 247 |
| 248 void NavigationHandleImpl::DidCommitNavigation( | 248 void NavigationHandleImpl::DidCommitNavigation( |
| 249 bool same_page, | 249 bool same_page, |
| 250 RenderFrameHostImpl* render_frame_host) { | 250 RenderFrameHostImpl* render_frame_host) { |
| 251 CHECK_IMPLIES(render_frame_host_, render_frame_host_ == render_frame_host); | 251 CHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); |
| 252 is_same_page_ = same_page; | 252 is_same_page_ = same_page; |
| 253 render_frame_host_ = render_frame_host; | 253 render_frame_host_ = render_frame_host; |
| 254 state_ = net_error_code_ == net::OK ? DID_COMMIT : DID_COMMIT_ERROR_PAGE; | 254 state_ = net_error_code_ == net::OK ? DID_COMMIT : DID_COMMIT_ERROR_PAGE; |
| 255 } | 255 } |
| 256 | 256 |
| 257 NavigationThrottle::ThrottleCheckResult | 257 NavigationThrottle::ThrottleCheckResult |
| 258 NavigationHandleImpl::CheckWillStartRequest() { | 258 NavigationHandleImpl::CheckWillStartRequest() { |
| 259 DCHECK(state_ == WILL_SEND_REQUEST || state_ == DEFERRING_START); | 259 DCHECK(state_ == WILL_SEND_REQUEST || state_ == DEFERRING_START); |
| 260 DCHECK_IMPLIES(state_ == WILL_SEND_REQUEST, next_index_ == 0); | 260 DCHECK(state_ != WILL_SEND_REQUEST || next_index_ == 0); |
| 261 DCHECK_IMPLIES(state_ == DEFERRING_START, next_index_ != 0); | 261 DCHECK(state_ != DEFERRING_START || next_index_ != 0); |
| 262 for (size_t i = next_index_; i < throttles_.size(); ++i) { | 262 for (size_t i = next_index_; i < throttles_.size(); ++i) { |
| 263 NavigationThrottle::ThrottleCheckResult result = | 263 NavigationThrottle::ThrottleCheckResult result = |
| 264 throttles_[i]->WillStartRequest(); | 264 throttles_[i]->WillStartRequest(); |
| 265 switch (result) { | 265 switch (result) { |
| 266 case NavigationThrottle::PROCEED: | 266 case NavigationThrottle::PROCEED: |
| 267 continue; | 267 continue; |
| 268 | 268 |
| 269 case NavigationThrottle::CANCEL_AND_IGNORE: | 269 case NavigationThrottle::CANCEL_AND_IGNORE: |
| 270 return result; | 270 return result; |
| 271 | 271 |
| 272 case NavigationThrottle::DEFER: | 272 case NavigationThrottle::DEFER: |
| 273 state_ = DEFERRING_START; | 273 state_ = DEFERRING_START; |
| 274 next_index_ = i + 1; | 274 next_index_ = i + 1; |
| 275 return result; | 275 return result; |
| 276 | 276 |
| 277 default: | 277 default: |
| 278 NOTREACHED(); | 278 NOTREACHED(); |
| 279 } | 279 } |
| 280 } | 280 } |
| 281 next_index_ = 0; | 281 next_index_ = 0; |
| 282 state_ = WILL_SEND_REQUEST; | 282 state_ = WILL_SEND_REQUEST; |
| 283 return NavigationThrottle::PROCEED; | 283 return NavigationThrottle::PROCEED; |
| 284 } | 284 } |
| 285 | 285 |
| 286 NavigationThrottle::ThrottleCheckResult | 286 NavigationThrottle::ThrottleCheckResult |
| 287 NavigationHandleImpl::CheckWillRedirectRequest() { | 287 NavigationHandleImpl::CheckWillRedirectRequest() { |
| 288 DCHECK(state_ == WILL_REDIRECT_REQUEST || state_ == DEFERRING_REDIRECT); | 288 DCHECK(state_ == WILL_REDIRECT_REQUEST || state_ == DEFERRING_REDIRECT); |
| 289 DCHECK_IMPLIES(state_ == WILL_REDIRECT_REQUEST, next_index_ == 0); | 289 DCHECK(state_ != WILL_REDIRECT_REQUEST || next_index_ == 0); |
| 290 DCHECK_IMPLIES(state_ == DEFERRING_REDIRECT, next_index_ != 0); | 290 DCHECK(state_ != DEFERRING_REDIRECT || next_index_ != 0); |
| 291 for (size_t i = next_index_; i < throttles_.size(); ++i) { | 291 for (size_t i = next_index_; i < throttles_.size(); ++i) { |
| 292 NavigationThrottle::ThrottleCheckResult result = | 292 NavigationThrottle::ThrottleCheckResult result = |
| 293 throttles_[i]->WillRedirectRequest(); | 293 throttles_[i]->WillRedirectRequest(); |
| 294 switch (result) { | 294 switch (result) { |
| 295 case NavigationThrottle::PROCEED: | 295 case NavigationThrottle::PROCEED: |
| 296 continue; | 296 continue; |
| 297 | 297 |
| 298 case NavigationThrottle::CANCEL_AND_IGNORE: | 298 case NavigationThrottle::CANCEL_AND_IGNORE: |
| 299 return result; | 299 return result; |
| 300 | 300 |
| 301 case NavigationThrottle::DEFER: | 301 case NavigationThrottle::DEFER: |
| 302 state_ = DEFERRING_REDIRECT; | 302 state_ = DEFERRING_REDIRECT; |
| 303 next_index_ = i + 1; | 303 next_index_ = i + 1; |
| 304 return result; | 304 return result; |
| 305 | 305 |
| 306 default: | 306 default: |
| 307 NOTREACHED(); | 307 NOTREACHED(); |
| 308 } | 308 } |
| 309 } | 309 } |
| 310 next_index_ = 0; | 310 next_index_ = 0; |
| 311 state_ = WILL_REDIRECT_REQUEST; | 311 state_ = WILL_REDIRECT_REQUEST; |
| 312 return NavigationThrottle::PROCEED; | 312 return NavigationThrottle::PROCEED; |
| 313 } | 313 } |
| 314 | 314 |
| 315 } // namespace content | 315 } // namespace content |
| OLD | NEW |