| 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 <iterator> | 7 #include <iterator> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "content/browser/appcache/appcache_navigation_handle.h" | 10 #include "content/browser/appcache/appcache_navigation_handle.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 redirect_chain_(redirect_chain), | 113 redirect_chain_(redirect_chain), |
| 114 is_download_(false), | 114 is_download_(false), |
| 115 is_stream_(false), | 115 is_stream_(false), |
| 116 started_from_context_menu_(started_from_context_menu), | 116 started_from_context_menu_(started_from_context_menu), |
| 117 reload_type_(ReloadType::NONE), | 117 reload_type_(ReloadType::NONE), |
| 118 restore_type_(RestoreType::NONE), | 118 restore_type_(RestoreType::NONE), |
| 119 navigation_type_(NAVIGATION_TYPE_UNKNOWN), | 119 navigation_type_(NAVIGATION_TYPE_UNKNOWN), |
| 120 should_check_main_world_csp_(should_check_main_world_csp), | 120 should_check_main_world_csp_(should_check_main_world_csp), |
| 121 is_form_submission_(is_form_submission), | 121 is_form_submission_(is_form_submission), |
| 122 weak_factory_(this) { | 122 weak_factory_(this) { |
| 123 TRACE_EVENT_ASYNC_BEGIN2("navigation", "NavigationHandle", this, |
| 124 "frame_tree_node", |
| 125 frame_tree_node_->frame_tree_node_id(), "url", |
| 126 url_.possibly_invalid_spec()); |
| 123 DCHECK(!navigation_start.is_null()); | 127 DCHECK(!navigation_start.is_null()); |
| 124 if (redirect_chain_.empty()) | 128 if (redirect_chain_.empty()) |
| 125 redirect_chain_.push_back(url); | 129 redirect_chain_.push_back(url); |
| 126 | 130 |
| 127 starting_site_instance_ = | 131 starting_site_instance_ = |
| 128 frame_tree_node_->current_frame_host()->GetSiteInstance(); | 132 frame_tree_node_->current_frame_host()->GetSiteInstance(); |
| 129 | 133 |
| 130 if (pending_nav_entry_id_) { | 134 if (pending_nav_entry_id_) { |
| 131 NavigationControllerImpl* nav_controller = | 135 NavigationControllerImpl* nav_controller = |
| 132 static_cast<NavigationControllerImpl*>( | 136 static_cast<NavigationControllerImpl*>( |
| (...skipping 14 matching lines...) Expand all Loading... |
| 147 } | 151 } |
| 148 | 152 |
| 149 if (!IsRendererDebugURL(url_)) | 153 if (!IsRendererDebugURL(url_)) |
| 150 GetDelegate()->DidStartNavigation(this); | 154 GetDelegate()->DidStartNavigation(this); |
| 151 | 155 |
| 152 if (IsInMainFrame()) { | 156 if (IsInMainFrame()) { |
| 153 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( | 157 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( |
| 154 "navigation", "Navigation StartToCommit", this, | 158 "navigation", "Navigation StartToCommit", this, |
| 155 navigation_start, "Initial URL", url_.spec()); | 159 navigation_start, "Initial URL", url_.spec()); |
| 156 } | 160 } |
| 161 |
| 162 if (is_same_page_) { |
| 163 TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationHandle", this, |
| 164 "Same document"); |
| 165 } |
| 157 } | 166 } |
| 158 | 167 |
| 159 NavigationHandleImpl::~NavigationHandleImpl() { | 168 NavigationHandleImpl::~NavigationHandleImpl() { |
| 160 // Transfer requests that have not matched up with another navigation request | 169 // Transfer requests that have not matched up with another navigation request |
| 161 // from the renderer need to be cleaned up. These are marked as protected in | 170 // from the renderer need to be cleaned up. These are marked as protected in |
| 162 // the RDHI, so they do not get cancelled when frames are destroyed. | 171 // the RDHI, so they do not get cancelled when frames are destroyed. |
| 163 if (is_transferring()) { | 172 if (is_transferring()) { |
| 164 BrowserThread::PostTask( | 173 BrowserThread::PostTask( |
| 165 BrowserThread::IO, FROM_HERE, | 174 BrowserThread::IO, FROM_HERE, |
| 166 base::Bind(&NotifyAbandonedTransferNavigation, GetGlobalRequestID())); | 175 base::Bind(&NotifyAbandonedTransferNavigation, GetGlobalRequestID())); |
| 167 } | 176 } |
| 168 | 177 |
| 169 if (!IsRendererDebugURL(url_)) | 178 if (!IsRendererDebugURL(url_)) |
| 170 GetDelegate()->DidFinishNavigation(this); | 179 GetDelegate()->DidFinishNavigation(this); |
| 171 | 180 |
| 172 // Cancel the navigation on the IO thread if the NavigationHandle is being | 181 // Cancel the navigation on the IO thread if the NavigationHandle is being |
| 173 // destroyed in the middle of the NavigationThrottles checks. | 182 // destroyed in the middle of the NavigationThrottles checks. |
| 174 if (!IsBrowserSideNavigationEnabled() && !complete_callback_.is_null()) | 183 if (!IsBrowserSideNavigationEnabled() && !complete_callback_.is_null()) |
| 175 RunCompleteCallback(NavigationThrottle::CANCEL_AND_IGNORE); | 184 RunCompleteCallback(NavigationThrottle::CANCEL_AND_IGNORE); |
| 176 | 185 |
| 177 if (IsInMainFrame()) { | 186 if (IsInMainFrame()) { |
| 178 TRACE_EVENT_ASYNC_END2("navigation", "Navigation StartToCommit", this, | 187 TRACE_EVENT_ASYNC_END2("navigation", "Navigation StartToCommit", this, |
| 179 "URL", url_.spec(), "Net Error Code", | 188 "URL", url_.spec(), "Net Error Code", |
| 180 net_error_code_); | 189 net_error_code_); |
| 181 } | 190 } |
| 191 TRACE_EVENT_ASYNC_END0("navigation", "NavigationHandle", this); |
| 182 } | 192 } |
| 183 | 193 |
| 184 NavigatorDelegate* NavigationHandleImpl::GetDelegate() const { | 194 NavigatorDelegate* NavigationHandleImpl::GetDelegate() const { |
| 185 return frame_tree_node_->navigator()->GetDelegate(); | 195 return frame_tree_node_->navigator()->GetDelegate(); |
| 186 } | 196 } |
| 187 | 197 |
| 188 const GURL& NavigationHandleImpl::GetURL() { | 198 const GURL& NavigationHandleImpl::GetURL() { |
| 189 return url_; | 199 return url_; |
| 190 } | 200 } |
| 191 | 201 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 net::HostPortPair NavigationHandleImpl::GetSocketAddress() { | 330 net::HostPortPair NavigationHandleImpl::GetSocketAddress() { |
| 321 DCHECK(state_ == DID_COMMIT || state_ == DID_COMMIT_ERROR_PAGE); | 331 DCHECK(state_ == DID_COMMIT || state_ == DID_COMMIT_ERROR_PAGE); |
| 322 return socket_address_; | 332 return socket_address_; |
| 323 } | 333 } |
| 324 | 334 |
| 325 void NavigationHandleImpl::Resume() { | 335 void NavigationHandleImpl::Resume() { |
| 326 if (state_ != DEFERRING_START && state_ != DEFERRING_REDIRECT && | 336 if (state_ != DEFERRING_START && state_ != DEFERRING_REDIRECT && |
| 327 state_ != DEFERRING_RESPONSE) { | 337 state_ != DEFERRING_RESPONSE) { |
| 328 return; | 338 return; |
| 329 } | 339 } |
| 340 TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationHandle", this, |
| 341 "Resume"); |
| 330 | 342 |
| 331 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; | 343 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; |
| 332 if (state_ == DEFERRING_START) { | 344 if (state_ == DEFERRING_START) { |
| 333 result = CheckWillStartRequest(); | 345 result = CheckWillStartRequest(); |
| 334 } else if (state_ == DEFERRING_REDIRECT) { | 346 } else if (state_ == DEFERRING_REDIRECT) { |
| 335 result = CheckWillRedirectRequest(); | 347 result = CheckWillRedirectRequest(); |
| 336 } else { | 348 } else { |
| 337 result = CheckWillProcessResponse(); | 349 result = CheckWillProcessResponse(); |
| 338 | 350 |
| 339 // If the navigation is about to proceed after having been deferred while | 351 // If the navigation is about to proceed after having been deferred while |
| 340 // processing the response, then it's ready to commit. Determine which | 352 // processing the response, then it's ready to commit. Determine which |
| 341 // RenderFrameHost should render the response, based on its site (after any | 353 // RenderFrameHost should render the response, based on its site (after any |
| 342 // redirects). | 354 // redirects). |
| 343 // Note: if MaybeTransferAndProceed returns false, this means that this | 355 // Note: if MaybeTransferAndProceed returns false, this means that this |
| 344 // NavigationHandle was deleted, so return immediately. | 356 // NavigationHandle was deleted, so return immediately. |
| 345 if (result == NavigationThrottle::PROCEED && !MaybeTransferAndProceed()) | 357 if (result == NavigationThrottle::PROCEED && !MaybeTransferAndProceed()) |
| 346 return; | 358 return; |
| 347 } | 359 } |
| 348 | 360 |
| 349 if (result != NavigationThrottle::DEFER) | 361 if (result != NavigationThrottle::DEFER) { |
| 362 TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationHandle", this, |
| 363 "Resuming"); |
| 350 RunCompleteCallback(result); | 364 RunCompleteCallback(result); |
| 365 } |
| 351 } | 366 } |
| 352 | 367 |
| 353 void NavigationHandleImpl::CancelDeferredNavigation( | 368 void NavigationHandleImpl::CancelDeferredNavigation( |
| 354 NavigationThrottle::ThrottleCheckResult result) { | 369 NavigationThrottle::ThrottleCheckResult result) { |
| 355 DCHECK(state_ == DEFERRING_START || | 370 DCHECK(state_ == DEFERRING_START || |
| 356 state_ == DEFERRING_REDIRECT || | 371 state_ == DEFERRING_REDIRECT || |
| 357 state_ == DEFERRING_RESPONSE); | 372 state_ == DEFERRING_RESPONSE); |
| 358 DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE || | 373 DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE || |
| 359 result == NavigationThrottle::CANCEL); | 374 result == NavigationThrottle::CANCEL); |
| 375 TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationHandle", this, |
| 376 "CancelDeferredNavigation"); |
| 360 state_ = CANCELING; | 377 state_ = CANCELING; |
| 361 RunCompleteCallback(result); | 378 RunCompleteCallback(result); |
| 362 } | 379 } |
| 363 | 380 |
| 364 void NavigationHandleImpl::RegisterThrottleForTesting( | 381 void NavigationHandleImpl::RegisterThrottleForTesting( |
| 365 std::unique_ptr<NavigationThrottle> navigation_throttle) { | 382 std::unique_ptr<NavigationThrottle> navigation_throttle) { |
| 366 throttles_.push_back(std::move(navigation_throttle)); | 383 throttles_.push_back(std::move(navigation_throttle)); |
| 367 } | 384 } |
| 368 | 385 |
| 369 NavigationThrottle::ThrottleCheckResult | 386 NavigationThrottle::ThrottleCheckResult |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 void NavigationHandleImpl::WillStartRequest( | 521 void NavigationHandleImpl::WillStartRequest( |
| 505 const std::string& method, | 522 const std::string& method, |
| 506 scoped_refptr<content::ResourceRequestBodyImpl> resource_request_body, | 523 scoped_refptr<content::ResourceRequestBodyImpl> resource_request_body, |
| 507 const Referrer& sanitized_referrer, | 524 const Referrer& sanitized_referrer, |
| 508 bool has_user_gesture, | 525 bool has_user_gesture, |
| 509 ui::PageTransition transition, | 526 ui::PageTransition transition, |
| 510 bool is_external_protocol, | 527 bool is_external_protocol, |
| 511 RequestContextType request_context_type, | 528 RequestContextType request_context_type, |
| 512 blink::WebMixedContentContextType mixed_content_context_type, | 529 blink::WebMixedContentContextType mixed_content_context_type, |
| 513 const ThrottleChecksFinishedCallback& callback) { | 530 const ThrottleChecksFinishedCallback& callback) { |
| 531 TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationHandle", this, |
| 532 "WillStartRequest"); |
| 514 if (method != "POST") | 533 if (method != "POST") |
| 515 DCHECK(!resource_request_body); | 534 DCHECK(!resource_request_body); |
| 516 | 535 |
| 517 // Update the navigation parameters. | 536 // Update the navigation parameters. |
| 518 method_ = method; | 537 method_ = method; |
| 519 if (method_ == "POST") | 538 if (method_ == "POST") |
| 520 resource_request_body_ = resource_request_body; | 539 resource_request_body_ = resource_request_body; |
| 521 has_user_gesture_ = has_user_gesture; | 540 has_user_gesture_ = has_user_gesture; |
| 522 transition_ = transition; | 541 transition_ = transition; |
| 523 // Mirrors the logic in RenderFrameImpl::SendDidCommitProvisionalLoad. | 542 // Mirrors the logic in RenderFrameImpl::SendDidCommitProvisionalLoad. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 543 | 562 |
| 544 RegisterNavigationThrottles(); | 563 RegisterNavigationThrottles(); |
| 545 | 564 |
| 546 if (IsBrowserSideNavigationEnabled()) | 565 if (IsBrowserSideNavigationEnabled()) |
| 547 navigation_ui_data_ = GetDelegate()->GetNavigationUIData(this); | 566 navigation_ui_data_ = GetDelegate()->GetNavigationUIData(this); |
| 548 | 567 |
| 549 // Notify each throttle of the request. | 568 // Notify each throttle of the request. |
| 550 NavigationThrottle::ThrottleCheckResult result = CheckWillStartRequest(); | 569 NavigationThrottle::ThrottleCheckResult result = CheckWillStartRequest(); |
| 551 | 570 |
| 552 // If the navigation is not deferred, run the callback. | 571 // If the navigation is not deferred, run the callback. |
| 553 if (result != NavigationThrottle::DEFER) | 572 if (result != NavigationThrottle::DEFER) { |
| 573 TRACE_EVENT_ASYNC_STEP_INTO1("navigation", "NavigationHandle", this, |
| 574 "StartRequest", "result", result); |
| 554 RunCompleteCallback(result); | 575 RunCompleteCallback(result); |
| 576 } |
| 555 } | 577 } |
| 556 | 578 |
| 557 void NavigationHandleImpl::WillRedirectRequest( | 579 void NavigationHandleImpl::WillRedirectRequest( |
| 558 const GURL& new_url, | 580 const GURL& new_url, |
| 559 const std::string& new_method, | 581 const std::string& new_method, |
| 560 const GURL& new_referrer_url, | 582 const GURL& new_referrer_url, |
| 561 bool new_is_external_protocol, | 583 bool new_is_external_protocol, |
| 562 scoped_refptr<net::HttpResponseHeaders> response_headers, | 584 scoped_refptr<net::HttpResponseHeaders> response_headers, |
| 563 net::HttpResponseInfo::ConnectionInfo connection_info, | 585 net::HttpResponseInfo::ConnectionInfo connection_info, |
| 564 const ThrottleChecksFinishedCallback& callback) { | 586 const ThrottleChecksFinishedCallback& callback) { |
| 587 TRACE_EVENT_ASYNC_STEP_INTO1("navigation", "NavigationHandle", this, |
| 588 "WillRedirectRequest", "url", |
| 589 new_url.possibly_invalid_spec()); |
| 590 |
| 565 // Update the navigation parameters. | 591 // Update the navigation parameters. |
| 566 url_ = new_url; | 592 url_ = new_url; |
| 567 method_ = new_method; | 593 method_ = new_method; |
| 568 | 594 |
| 569 if (!(transition_ & ui::PAGE_TRANSITION_CLIENT_REDIRECT)) { | 595 if (!(transition_ & ui::PAGE_TRANSITION_CLIENT_REDIRECT)) { |
| 570 sanitized_referrer_.url = new_referrer_url; | 596 sanitized_referrer_.url = new_referrer_url; |
| 571 sanitized_referrer_ = | 597 sanitized_referrer_ = |
| 572 Referrer::SanitizeForRequest(url_, sanitized_referrer_); | 598 Referrer::SanitizeForRequest(url_, sanitized_referrer_); |
| 573 } | 599 } |
| 574 | 600 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 586 if (IsSelfReferentialURL()) { | 612 if (IsSelfReferentialURL()) { |
| 587 state_ = CANCELING; | 613 state_ = CANCELING; |
| 588 RunCompleteCallback(NavigationThrottle::CANCEL); | 614 RunCompleteCallback(NavigationThrottle::CANCEL); |
| 589 return; | 615 return; |
| 590 } | 616 } |
| 591 | 617 |
| 592 // Notify each throttle of the request. | 618 // Notify each throttle of the request. |
| 593 NavigationThrottle::ThrottleCheckResult result = CheckWillRedirectRequest(); | 619 NavigationThrottle::ThrottleCheckResult result = CheckWillRedirectRequest(); |
| 594 | 620 |
| 595 // If the navigation is not deferred, run the callback. | 621 // If the navigation is not deferred, run the callback. |
| 596 if (result != NavigationThrottle::DEFER) | 622 if (result != NavigationThrottle::DEFER) { |
| 623 TRACE_EVENT_ASYNC_STEP_INTO1("navigation", "NavigationHandle", this, |
| 624 "RedirectRequest", "result", result); |
| 597 RunCompleteCallback(result); | 625 RunCompleteCallback(result); |
| 626 } |
| 598 } | 627 } |
| 599 | 628 |
| 600 void NavigationHandleImpl::WillProcessResponse( | 629 void NavigationHandleImpl::WillProcessResponse( |
| 601 RenderFrameHostImpl* render_frame_host, | 630 RenderFrameHostImpl* render_frame_host, |
| 602 scoped_refptr<net::HttpResponseHeaders> response_headers, | 631 scoped_refptr<net::HttpResponseHeaders> response_headers, |
| 603 net::HttpResponseInfo::ConnectionInfo connection_info, | 632 net::HttpResponseInfo::ConnectionInfo connection_info, |
| 604 const SSLStatus& ssl_status, | 633 const SSLStatus& ssl_status, |
| 605 const GlobalRequestID& request_id, | 634 const GlobalRequestID& request_id, |
| 606 bool should_replace_current_entry, | 635 bool should_replace_current_entry, |
| 607 bool is_download, | 636 bool is_download, |
| 608 bool is_stream, | 637 bool is_stream, |
| 609 const base::Closure& transfer_callback, | 638 const base::Closure& transfer_callback, |
| 610 const ThrottleChecksFinishedCallback& callback) { | 639 const ThrottleChecksFinishedCallback& callback) { |
| 640 TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationHandle", this, |
| 641 "WillProcessResponse"); |
| 642 |
| 611 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); | 643 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); |
| 612 render_frame_host_ = render_frame_host; | 644 render_frame_host_ = render_frame_host; |
| 613 response_headers_ = response_headers; | 645 response_headers_ = response_headers; |
| 614 connection_info_ = connection_info; | 646 connection_info_ = connection_info; |
| 615 request_id_ = request_id; | 647 request_id_ = request_id; |
| 616 should_replace_current_entry_ = should_replace_current_entry; | 648 should_replace_current_entry_ = should_replace_current_entry; |
| 617 is_download_ = is_download; | 649 is_download_ = is_download; |
| 618 is_stream_ = is_stream; | 650 is_stream_ = is_stream; |
| 619 state_ = WILL_PROCESS_RESPONSE; | 651 state_ = WILL_PROCESS_RESPONSE; |
| 620 ssl_status_ = ssl_status; | 652 ssl_status_ = ssl_status; |
| 621 complete_callback_ = callback; | 653 complete_callback_ = callback; |
| 622 transfer_callback_ = transfer_callback; | 654 transfer_callback_ = transfer_callback; |
| 623 | 655 |
| 624 // Notify each throttle of the response. | 656 // Notify each throttle of the response. |
| 625 NavigationThrottle::ThrottleCheckResult result = CheckWillProcessResponse(); | 657 NavigationThrottle::ThrottleCheckResult result = CheckWillProcessResponse(); |
| 626 | 658 |
| 627 // If the navigation is done processing the response, then it's ready to | 659 // If the navigation is done processing the response, then it's ready to |
| 628 // commit. Determine which RenderFrameHost should render the response, based | 660 // commit. Determine which RenderFrameHost should render the response, based |
| 629 // on its site (after any redirects). | 661 // on its site (after any redirects). |
| 630 // Note: if MaybeTransferAndProceed returns false, this means that this | 662 // Note: if MaybeTransferAndProceed returns false, this means that this |
| 631 // NavigationHandle was deleted, so return immediately. | 663 // NavigationHandle was deleted, so return immediately. |
| 632 if (result == NavigationThrottle::PROCEED && !MaybeTransferAndProceed()) | 664 if (result == NavigationThrottle::PROCEED && !MaybeTransferAndProceed()) |
| 633 return; | 665 return; |
| 634 | 666 |
| 635 // If the navigation is not deferred, run the callback. | 667 // If the navigation is not deferred, run the callback. |
| 636 if (result != NavigationThrottle::DEFER) | 668 if (result != NavigationThrottle::DEFER) { |
| 669 TRACE_EVENT_ASYNC_STEP_INTO1("navigation", "NavigationHandle", this, |
| 670 "ProcessResponse", "result", result); |
| 637 RunCompleteCallback(result); | 671 RunCompleteCallback(result); |
| 672 } |
| 638 } | 673 } |
| 639 | 674 |
| 640 void NavigationHandleImpl::ReadyToCommitNavigation( | 675 void NavigationHandleImpl::ReadyToCommitNavigation( |
| 641 RenderFrameHostImpl* render_frame_host) { | 676 RenderFrameHostImpl* render_frame_host) { |
| 677 TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationHandle", this, |
| 678 "ReadyToCommitNavigation"); |
| 679 |
| 642 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); | 680 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); |
| 643 render_frame_host_ = render_frame_host; | 681 render_frame_host_ = render_frame_host; |
| 644 state_ = READY_TO_COMMIT; | 682 state_ = READY_TO_COMMIT; |
| 645 | 683 |
| 646 if (!IsRendererDebugURL(url_) && !IsSameDocument()) | 684 if (!IsRendererDebugURL(url_) && !IsSameDocument()) |
| 647 GetDelegate()->ReadyToCommitNavigation(this); | 685 GetDelegate()->ReadyToCommitNavigation(this); |
| 648 } | 686 } |
| 649 | 687 |
| 650 void NavigationHandleImpl::DidCommitNavigation( | 688 void NavigationHandleImpl::DidCommitNavigation( |
| 651 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, | 689 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 671 | 709 |
| 672 DCHECK(!IsInMainFrame() || navigation_entry_committed) | 710 DCHECK(!IsInMainFrame() || navigation_entry_committed) |
| 673 << "Only subframe navigations can get here without changing the " | 711 << "Only subframe navigations can get here without changing the " |
| 674 << "NavigationEntry"; | 712 << "NavigationEntry"; |
| 675 subframe_entry_committed_ = navigation_entry_committed; | 713 subframe_entry_committed_ = navigation_entry_committed; |
| 676 | 714 |
| 677 // If an error page reloads, net_error_code might be 200 but we still want to | 715 // If an error page reloads, net_error_code might be 200 but we still want to |
| 678 // count it as an error page. | 716 // count it as an error page. |
| 679 if (params.base_url.spec() == kUnreachableWebDataURL || | 717 if (params.base_url.spec() == kUnreachableWebDataURL || |
| 680 net_error_code_ != net::OK) { | 718 net_error_code_ != net::OK) { |
| 719 TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationHandle", this, |
| 720 "DidCommitNavigation: error page"); |
| 681 state_ = DID_COMMIT_ERROR_PAGE; | 721 state_ = DID_COMMIT_ERROR_PAGE; |
| 682 } else { | 722 } else { |
| 723 TRACE_EVENT_ASYNC_STEP_INTO0("navigation", "NavigationHandle", this, |
| 724 "DidCommitNavigation"); |
| 683 state_ = DID_COMMIT; | 725 state_ = DID_COMMIT; |
| 684 } | 726 } |
| 685 } | 727 } |
| 686 | 728 |
| 687 void NavigationHandleImpl::Transfer() { | 729 void NavigationHandleImpl::Transfer() { |
| 688 DCHECK(!IsBrowserSideNavigationEnabled()); | 730 DCHECK(!IsBrowserSideNavigationEnabled()); |
| 689 // This is an actual transfer. Inform the NavigationResourceThrottle. This | 731 // This is an actual transfer. Inform the NavigationResourceThrottle. This |
| 690 // will allow to mark the URLRequest as transferring. When it is marked as | 732 // will allow to mark the URLRequest as transferring. When it is marked as |
| 691 // transferring, the URLRequest can no longer be cancelled by its original | 733 // transferring, the URLRequest can no longer be cancelled by its original |
| 692 // RenderFrame. Instead it will persist until being picked up by the transfer | 734 // RenderFrame. Instead it will persist until being picked up by the transfer |
| 693 // RenderFrame, even if the original RenderFrame is destroyed. | 735 // RenderFrame, even if the original RenderFrame is destroyed. |
| 694 // Note: |transfer_callback_| can be null in unit tests. | 736 // Note: |transfer_callback_| can be null in unit tests. |
| 695 if (!transfer_callback_.is_null()) | 737 if (!transfer_callback_.is_null()) |
| 696 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, transfer_callback_); | 738 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, transfer_callback_); |
| 697 transfer_callback_.Reset(); | 739 transfer_callback_.Reset(); |
| 698 } | 740 } |
| 699 | 741 |
| 700 NavigationThrottle::ThrottleCheckResult | 742 NavigationThrottle::ThrottleCheckResult |
| 701 NavigationHandleImpl::CheckWillStartRequest() { | 743 NavigationHandleImpl::CheckWillStartRequest() { |
| 702 DCHECK(state_ == WILL_SEND_REQUEST || state_ == DEFERRING_START); | 744 DCHECK(state_ == WILL_SEND_REQUEST || state_ == DEFERRING_START); |
| 703 DCHECK(state_ != WILL_SEND_REQUEST || next_index_ == 0); | 745 DCHECK(state_ != WILL_SEND_REQUEST || next_index_ == 0); |
| 704 DCHECK(state_ != DEFERRING_START || next_index_ != 0); | 746 DCHECK(state_ != DEFERRING_START || next_index_ != 0); |
| 705 for (size_t i = next_index_; i < throttles_.size(); ++i) { | 747 for (size_t i = next_index_; i < throttles_.size(); ++i) { |
| 706 NavigationThrottle::ThrottleCheckResult result = | 748 NavigationThrottle::ThrottleCheckResult result = |
| 707 throttles_[i]->WillStartRequest(); | 749 throttles_[i]->WillStartRequest(); |
| 750 TRACE_EVENT_ASYNC_STEP_INTO0( |
| 751 "navigation", "NavigationHandle", this, |
| 752 base::StringPrintf("CheckWillStartRequest: %s: %d", |
| 753 throttles_[i]->GetNameForLogging(), result)); |
| 708 switch (result) { | 754 switch (result) { |
| 709 case NavigationThrottle::PROCEED: | 755 case NavigationThrottle::PROCEED: |
| 710 continue; | 756 continue; |
| 711 | 757 |
| 712 case NavigationThrottle::BLOCK_REQUEST: | 758 case NavigationThrottle::BLOCK_REQUEST: |
| 713 case NavigationThrottle::CANCEL: | 759 case NavigationThrottle::CANCEL: |
| 714 case NavigationThrottle::CANCEL_AND_IGNORE: | 760 case NavigationThrottle::CANCEL_AND_IGNORE: |
| 715 state_ = CANCELING; | 761 state_ = CANCELING; |
| 716 return result; | 762 return result; |
| 717 | 763 |
| 718 case NavigationThrottle::DEFER: | 764 case NavigationThrottle::DEFER: |
| 719 state_ = DEFERRING_START; | 765 state_ = DEFERRING_START; |
| 720 next_index_ = i + 1; | 766 next_index_ = i + 1; |
| 721 return result; | 767 return result; |
| 722 | 768 |
| 723 case NavigationThrottle::BLOCK_RESPONSE: | 769 case NavigationThrottle::BLOCK_RESPONSE: |
| 724 NOTREACHED(); | 770 NOTREACHED(); |
| 725 } | 771 } |
| 726 } | 772 } |
| 727 next_index_ = 0; | 773 next_index_ = 0; |
| 728 state_ = WILL_SEND_REQUEST; | 774 state_ = WILL_SEND_REQUEST; |
| 775 |
| 729 return NavigationThrottle::PROCEED; | 776 return NavigationThrottle::PROCEED; |
| 730 } | 777 } |
| 731 | 778 |
| 732 NavigationThrottle::ThrottleCheckResult | 779 NavigationThrottle::ThrottleCheckResult |
| 733 NavigationHandleImpl::CheckWillRedirectRequest() { | 780 NavigationHandleImpl::CheckWillRedirectRequest() { |
| 734 DCHECK(state_ == WILL_REDIRECT_REQUEST || state_ == DEFERRING_REDIRECT); | 781 DCHECK(state_ == WILL_REDIRECT_REQUEST || state_ == DEFERRING_REDIRECT); |
| 735 DCHECK(state_ != WILL_REDIRECT_REQUEST || next_index_ == 0); | 782 DCHECK(state_ != WILL_REDIRECT_REQUEST || next_index_ == 0); |
| 736 DCHECK(state_ != DEFERRING_REDIRECT || next_index_ != 0); | 783 DCHECK(state_ != DEFERRING_REDIRECT || next_index_ != 0); |
| 784 |
| 737 for (size_t i = next_index_; i < throttles_.size(); ++i) { | 785 for (size_t i = next_index_; i < throttles_.size(); ++i) { |
| 738 NavigationThrottle::ThrottleCheckResult result = | 786 NavigationThrottle::ThrottleCheckResult result = |
| 739 throttles_[i]->WillRedirectRequest(); | 787 throttles_[i]->WillRedirectRequest(); |
| 788 TRACE_EVENT_ASYNC_STEP_INTO0( |
| 789 "navigation", "NavigationHandle", this, |
| 790 base::StringPrintf("CheckWillRedirectRequest: %s: %d", |
| 791 throttles_[i]->GetNameForLogging(), result)); |
| 740 switch (result) { | 792 switch (result) { |
| 741 case NavigationThrottle::PROCEED: | 793 case NavigationThrottle::PROCEED: |
| 742 continue; | 794 continue; |
| 743 | 795 |
| 744 case NavigationThrottle::BLOCK_REQUEST: | 796 case NavigationThrottle::BLOCK_REQUEST: |
| 745 CHECK(IsBrowserSideNavigationEnabled()) | 797 CHECK(IsBrowserSideNavigationEnabled()) |
| 746 << "BLOCK_REQUEST must not be used on redirect without PlzNavigate"; | 798 << "BLOCK_REQUEST must not be used on redirect without PlzNavigate"; |
| 747 case NavigationThrottle::CANCEL: | 799 case NavigationThrottle::CANCEL: |
| 748 case NavigationThrottle::CANCEL_AND_IGNORE: | 800 case NavigationThrottle::CANCEL_AND_IGNORE: |
| 749 state_ = CANCELING; | 801 state_ = CANCELING; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 766 GetDelegate()->DidRedirectNavigation(this); | 818 GetDelegate()->DidRedirectNavigation(this); |
| 767 | 819 |
| 768 return NavigationThrottle::PROCEED; | 820 return NavigationThrottle::PROCEED; |
| 769 } | 821 } |
| 770 | 822 |
| 771 NavigationThrottle::ThrottleCheckResult | 823 NavigationThrottle::ThrottleCheckResult |
| 772 NavigationHandleImpl::CheckWillProcessResponse() { | 824 NavigationHandleImpl::CheckWillProcessResponse() { |
| 773 DCHECK(state_ == WILL_PROCESS_RESPONSE || state_ == DEFERRING_RESPONSE); | 825 DCHECK(state_ == WILL_PROCESS_RESPONSE || state_ == DEFERRING_RESPONSE); |
| 774 DCHECK(state_ != WILL_PROCESS_RESPONSE || next_index_ == 0); | 826 DCHECK(state_ != WILL_PROCESS_RESPONSE || next_index_ == 0); |
| 775 DCHECK(state_ != DEFERRING_RESPONSE || next_index_ != 0); | 827 DCHECK(state_ != DEFERRING_RESPONSE || next_index_ != 0); |
| 828 |
| 776 for (size_t i = next_index_; i < throttles_.size(); ++i) { | 829 for (size_t i = next_index_; i < throttles_.size(); ++i) { |
| 777 NavigationThrottle::ThrottleCheckResult result = | 830 NavigationThrottle::ThrottleCheckResult result = |
| 778 throttles_[i]->WillProcessResponse(); | 831 throttles_[i]->WillProcessResponse(); |
| 832 TRACE_EVENT_ASYNC_STEP_INTO0( |
| 833 "navigation", "NavigationHandle", this, |
| 834 base::StringPrintf("CheckWillProcessResponse: %s: %d", |
| 835 throttles_[i]->GetNameForLogging(), result)); |
| 779 switch (result) { | 836 switch (result) { |
| 780 case NavigationThrottle::PROCEED: | 837 case NavigationThrottle::PROCEED: |
| 781 continue; | 838 continue; |
| 782 | 839 |
| 783 case NavigationThrottle::CANCEL: | 840 case NavigationThrottle::CANCEL: |
| 784 case NavigationThrottle::CANCEL_AND_IGNORE: | 841 case NavigationThrottle::CANCEL_AND_IGNORE: |
| 785 case NavigationThrottle::BLOCK_RESPONSE: | 842 case NavigationThrottle::BLOCK_RESPONSE: |
| 786 state_ = CANCELING; | 843 state_ = CANCELING; |
| 787 return result; | 844 return result; |
| 788 | 845 |
| 789 case NavigationThrottle::DEFER: | 846 case NavigationThrottle::DEFER: |
| 790 state_ = DEFERRING_RESPONSE; | 847 state_ = DEFERRING_RESPONSE; |
| 791 next_index_ = i + 1; | 848 next_index_ = i + 1; |
| 792 return result; | 849 return result; |
| 793 | 850 |
| 794 case NavigationThrottle::BLOCK_REQUEST: | 851 case NavigationThrottle::BLOCK_REQUEST: |
| 795 NOTREACHED(); | 852 NOTREACHED(); |
| 796 } | 853 } |
| 797 } | 854 } |
| 798 next_index_ = 0; | 855 next_index_ = 0; |
| 799 state_ = WILL_PROCESS_RESPONSE; | 856 state_ = WILL_PROCESS_RESPONSE; |
| 857 |
| 800 return NavigationThrottle::PROCEED; | 858 return NavigationThrottle::PROCEED; |
| 801 } | 859 } |
| 802 | 860 |
| 803 bool NavigationHandleImpl::MaybeTransferAndProceed() { | 861 bool NavigationHandleImpl::MaybeTransferAndProceed() { |
| 804 DCHECK_EQ(WILL_PROCESS_RESPONSE, state_); | 862 DCHECK_EQ(WILL_PROCESS_RESPONSE, state_); |
| 805 | 863 |
| 806 // Check if the navigation should transfer. This may result in the | 864 // Check if the navigation should transfer. This may result in the |
| 807 // destruction of this NavigationHandle, and the cancellation of the request. | 865 // destruction of this NavigationHandle, and the cancellation of the request. |
| 808 if (!MaybeTransferAndProceedInternal()) | 866 if (!MaybeTransferAndProceedInternal()) |
| 809 return false; | 867 return false; |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 if (node->current_url().EqualsIgnoringRef(url_)) { | 1047 if (node->current_url().EqualsIgnoringRef(url_)) { |
| 990 if (found_self_reference) | 1048 if (found_self_reference) |
| 991 return true; | 1049 return true; |
| 992 found_self_reference = true; | 1050 found_self_reference = true; |
| 993 } | 1051 } |
| 994 } | 1052 } |
| 995 return false; | 1053 return false; |
| 996 } | 1054 } |
| 997 | 1055 |
| 998 } // namespace content | 1056 } // namespace content |
| OLD | NEW |