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