| 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/debug/dump_without_crashing.h" |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 #include "content/browser/browsing_data/clear_site_data_throttle.h" | 11 #include "content/browser/browsing_data/clear_site_data_throttle.h" |
| 12 #include "content/browser/child_process_security_policy_impl.h" |
| 11 #include "content/browser/devtools/render_frame_devtools_agent_host.h" | 13 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
| 12 #include "content/browser/frame_host/frame_tree_node.h" | 14 #include "content/browser/frame_host/frame_tree_node.h" |
| 13 #include "content/browser/frame_host/navigator.h" | 15 #include "content/browser/frame_host/navigator.h" |
| 14 #include "content/browser/frame_host/navigator_delegate.h" | 16 #include "content/browser/frame_host/navigator_delegate.h" |
| 15 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 17 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 16 #include "content/browser/service_worker/service_worker_navigation_handle.h" | 18 #include "content/browser/service_worker/service_worker_navigation_handle.h" |
| 17 #include "content/common/frame_messages.h" | 19 #include "content/common/frame_messages.h" |
| 18 #include "content/common/resource_request_body_impl.h" | 20 #include "content/common/resource_request_body_impl.h" |
| 21 #include "content/common/site_isolation_policy.h" |
| 19 #include "content/public/browser/content_browser_client.h" | 22 #include "content/public/browser/content_browser_client.h" |
| 20 #include "content/public/browser/navigation_ui_data.h" | 23 #include "content/public/browser/navigation_ui_data.h" |
| 24 #include "content/public/browser/site_instance.h" |
| 21 #include "content/public/common/browser_side_navigation_policy.h" | 25 #include "content/public/common/browser_side_navigation_policy.h" |
| 22 #include "content/public/common/content_client.h" | 26 #include "content/public/common/content_client.h" |
| 23 #include "content/public/common/url_constants.h" | 27 #include "content/public/common/url_constants.h" |
| 24 #include "net/url_request/redirect_info.h" | 28 #include "net/url_request/redirect_info.h" |
| 25 #include "url/gurl.h" | 29 #include "url/gurl.h" |
| 26 #include "url/url_constants.h" | 30 #include "url/url_constants.h" |
| 27 | 31 |
| 28 namespace content { | 32 namespace content { |
| 29 | 33 |
| 30 namespace { | 34 namespace { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 has_user_gesture_(false), | 69 has_user_gesture_(false), |
| 66 transition_(ui::PAGE_TRANSITION_LINK), | 70 transition_(ui::PAGE_TRANSITION_LINK), |
| 67 is_external_protocol_(false), | 71 is_external_protocol_(false), |
| 68 net_error_code_(net::OK), | 72 net_error_code_(net::OK), |
| 69 render_frame_host_(nullptr), | 73 render_frame_host_(nullptr), |
| 70 is_renderer_initiated_(is_renderer_initiated), | 74 is_renderer_initiated_(is_renderer_initiated), |
| 71 is_same_page_(false), | 75 is_same_page_(false), |
| 72 is_synchronous_(is_synchronous), | 76 is_synchronous_(is_synchronous), |
| 73 is_srcdoc_(is_srcdoc), | 77 is_srcdoc_(is_srcdoc), |
| 74 was_redirected_(false), | 78 was_redirected_(false), |
| 79 original_url_(url), |
| 75 state_(INITIAL), | 80 state_(INITIAL), |
| 76 is_transferring_(false), | 81 is_transferring_(false), |
| 77 frame_tree_node_(frame_tree_node), | 82 frame_tree_node_(frame_tree_node), |
| 78 next_index_(0), | 83 next_index_(0), |
| 79 navigation_start_(navigation_start), | 84 navigation_start_(navigation_start), |
| 80 pending_nav_entry_id_(pending_nav_entry_id), | 85 pending_nav_entry_id_(pending_nav_entry_id), |
| 81 request_context_type_(REQUEST_CONTEXT_TYPE_UNSPECIFIED), | 86 request_context_type_(REQUEST_CONTEXT_TYPE_UNSPECIFIED), |
| 82 started_from_context_menu_(started_from_context_menu) { | 87 should_replace_current_entry_(false), |
| 88 is_download_(false), |
| 89 is_stream_(false), |
| 90 started_from_context_menu_(started_from_context_menu), |
| 91 weak_factory_(this) { |
| 83 DCHECK(!navigation_start.is_null()); | 92 DCHECK(!navigation_start.is_null()); |
| 93 redirect_chain_.push_back(url); |
| 84 GetDelegate()->DidStartNavigation(this); | 94 GetDelegate()->DidStartNavigation(this); |
| 85 | 95 |
| 86 if (IsInMainFrame()) { | 96 if (IsInMainFrame()) { |
| 87 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( | 97 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( |
| 88 "navigation", "Navigation StartToCommit", this, | 98 "navigation", "Navigation StartToCommit", this, |
| 89 navigation_start, "Initial URL", url_.spec()); | 99 navigation_start, "Initial URL", url_.spec()); |
| 90 } | 100 } |
| 91 } | 101 } |
| 92 | 102 |
| 93 NavigationHandleImpl::~NavigationHandleImpl() { | 103 NavigationHandleImpl::~NavigationHandleImpl() { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 } | 240 } |
| 231 | 241 |
| 232 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; | 242 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; |
| 233 if (state_ == DEFERRING_START) { | 243 if (state_ == DEFERRING_START) { |
| 234 result = CheckWillStartRequest(); | 244 result = CheckWillStartRequest(); |
| 235 } else if (state_ == DEFERRING_REDIRECT) { | 245 } else if (state_ == DEFERRING_REDIRECT) { |
| 236 result = CheckWillRedirectRequest(); | 246 result = CheckWillRedirectRequest(); |
| 237 } else { | 247 } else { |
| 238 result = CheckWillProcessResponse(); | 248 result = CheckWillProcessResponse(); |
| 239 | 249 |
| 240 // If the navigation is about to proceed after processing the response, then | 250 // If the navigation is about to proceed after having been deferred while |
| 241 // it's ready to commit. | 251 // processing the response, then it's ready to commit. Determine which |
| 242 if (result == NavigationThrottle::PROCEED) | 252 // RenderFrameHost should render the response, based on its site (after any |
| 243 ReadyToCommitNavigation(render_frame_host_); | 253 // redirects). |
| 254 // Note: if MaybeTransferAndProceed returns false, this means that this |
| 255 // NavigationHandle was deleted, so return immediately. |
| 256 if (result == NavigationThrottle::PROCEED && !MaybeTransferAndProceed()) |
| 257 return; |
| 244 } | 258 } |
| 245 | 259 |
| 246 if (result != NavigationThrottle::DEFER) | 260 if (result != NavigationThrottle::DEFER) |
| 247 RunCompleteCallback(result); | 261 RunCompleteCallback(result); |
| 248 } | 262 } |
| 249 | 263 |
| 250 void NavigationHandleImpl::CancelDeferredNavigation( | 264 void NavigationHandleImpl::CancelDeferredNavigation( |
| 251 NavigationThrottle::ThrottleCheckResult result) { | 265 NavigationThrottle::ThrottleCheckResult result) { |
| 252 DCHECK(state_ == DEFERRING_START || state_ == DEFERRING_REDIRECT); | 266 DCHECK(state_ == DEFERRING_START || state_ == DEFERRING_REDIRECT); |
| 253 DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE || | 267 DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE || |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 } | 322 } |
| 309 | 323 |
| 310 NavigationThrottle::ThrottleCheckResult | 324 NavigationThrottle::ThrottleCheckResult |
| 311 NavigationHandleImpl::CallWillProcessResponseForTesting( | 325 NavigationHandleImpl::CallWillProcessResponseForTesting( |
| 312 content::RenderFrameHost* render_frame_host, | 326 content::RenderFrameHost* render_frame_host, |
| 313 const std::string& raw_response_headers) { | 327 const std::string& raw_response_headers) { |
| 314 scoped_refptr<net::HttpResponseHeaders> headers = | 328 scoped_refptr<net::HttpResponseHeaders> headers = |
| 315 new net::HttpResponseHeaders(raw_response_headers); | 329 new net::HttpResponseHeaders(raw_response_headers); |
| 316 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; | 330 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; |
| 317 WillProcessResponse(static_cast<RenderFrameHostImpl*>(render_frame_host), | 331 WillProcessResponse(static_cast<RenderFrameHostImpl*>(render_frame_host), |
| 318 headers, SSLStatus(), | 332 headers, SSLStatus(), GlobalRequestID(), false, false, |
| 333 false, base::Closure(), |
| 319 base::Bind(&UpdateThrottleCheckResult, &result)); | 334 base::Bind(&UpdateThrottleCheckResult, &result)); |
| 320 | 335 |
| 321 // Reset the callback to ensure it will not be called later. | 336 // Reset the callback to ensure it will not be called later. |
| 322 complete_callback_.Reset(); | 337 complete_callback_.Reset(); |
| 323 return result; | 338 return result; |
| 324 } | 339 } |
| 325 | 340 |
| 326 void NavigationHandleImpl::CallDidCommitNavigationForTesting(const GURL& url) { | 341 void NavigationHandleImpl::CallDidCommitNavigationForTesting(const GURL& url) { |
| 327 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 342 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 328 | 343 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 scoped_refptr<net::HttpResponseHeaders> response_headers, | 419 scoped_refptr<net::HttpResponseHeaders> response_headers, |
| 405 const ThrottleChecksFinishedCallback& callback) { | 420 const ThrottleChecksFinishedCallback& callback) { |
| 406 // Update the navigation parameters. | 421 // Update the navigation parameters. |
| 407 url_ = new_url; | 422 url_ = new_url; |
| 408 method_ = new_method; | 423 method_ = new_method; |
| 409 sanitized_referrer_.url = new_referrer_url; | 424 sanitized_referrer_.url = new_referrer_url; |
| 410 sanitized_referrer_ = Referrer::SanitizeForRequest(url_, sanitized_referrer_); | 425 sanitized_referrer_ = Referrer::SanitizeForRequest(url_, sanitized_referrer_); |
| 411 is_external_protocol_ = new_is_external_protocol; | 426 is_external_protocol_ = new_is_external_protocol; |
| 412 response_headers_ = response_headers; | 427 response_headers_ = response_headers; |
| 413 was_redirected_ = true; | 428 was_redirected_ = true; |
| 429 redirect_chain_.push_back(new_url); |
| 414 if (new_method != "POST") | 430 if (new_method != "POST") |
| 415 resource_request_body_ = nullptr; | 431 resource_request_body_ = nullptr; |
| 416 | 432 |
| 417 state_ = WILL_REDIRECT_REQUEST; | 433 state_ = WILL_REDIRECT_REQUEST; |
| 418 complete_callback_ = callback; | 434 complete_callback_ = callback; |
| 419 | 435 |
| 420 // Notify each throttle of the request. | 436 // Notify each throttle of the request. |
| 421 NavigationThrottle::ThrottleCheckResult result = CheckWillRedirectRequest(); | 437 NavigationThrottle::ThrottleCheckResult result = CheckWillRedirectRequest(); |
| 422 | 438 |
| 423 // If the navigation is not deferred, run the callback. | 439 // If the navigation is not deferred, run the callback. |
| 424 if (result != NavigationThrottle::DEFER) | 440 if (result != NavigationThrottle::DEFER) |
| 425 RunCompleteCallback(result); | 441 RunCompleteCallback(result); |
| 426 } | 442 } |
| 427 | 443 |
| 428 void NavigationHandleImpl::WillProcessResponse( | 444 void NavigationHandleImpl::WillProcessResponse( |
| 429 RenderFrameHostImpl* render_frame_host, | 445 RenderFrameHostImpl* render_frame_host, |
| 430 scoped_refptr<net::HttpResponseHeaders> response_headers, | 446 scoped_refptr<net::HttpResponseHeaders> response_headers, |
| 431 const SSLStatus& ssl_status, | 447 const SSLStatus& ssl_status, |
| 448 const GlobalRequestID& request_id, |
| 449 bool should_replace_current_entry, |
| 450 bool is_download, |
| 451 bool is_stream, |
| 452 const base::Closure& transfer_callback, |
| 432 const ThrottleChecksFinishedCallback& callback) { | 453 const ThrottleChecksFinishedCallback& callback) { |
| 433 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); | 454 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); |
| 434 render_frame_host_ = render_frame_host; | 455 render_frame_host_ = render_frame_host; |
| 435 response_headers_ = response_headers; | 456 response_headers_ = response_headers; |
| 457 request_id_ = request_id; |
| 458 should_replace_current_entry_ = should_replace_current_entry; |
| 459 is_download_ = is_download; |
| 460 is_stream_ = is_stream; |
| 436 state_ = WILL_PROCESS_RESPONSE; | 461 state_ = WILL_PROCESS_RESPONSE; |
| 437 ssl_status_ = ssl_status; | 462 ssl_status_ = ssl_status; |
| 438 complete_callback_ = callback; | 463 complete_callback_ = callback; |
| 464 transfer_callback_ = transfer_callback; |
| 439 | 465 |
| 440 // Notify each throttle of the response. | 466 // Notify each throttle of the response. |
| 441 NavigationThrottle::ThrottleCheckResult result = CheckWillProcessResponse(); | 467 NavigationThrottle::ThrottleCheckResult result = CheckWillProcessResponse(); |
| 442 | 468 |
| 443 // If the navigation is about to proceed, then it's ready to commit. | 469 // If the navigation is done processing the response, then it's ready to |
| 444 if (result == NavigationThrottle::PROCEED) | 470 // commit. Determine which RenderFrameHost should render the response, based |
| 445 ReadyToCommitNavigation(render_frame_host); | 471 // on its site (after any redirects). |
| 472 // Note: if MaybeTransferAndProceed returns false, this means that this |
| 473 // NavigationHandle was deleted, so return immediately. |
| 474 if (result == NavigationThrottle::PROCEED && !MaybeTransferAndProceed()) |
| 475 return; |
| 446 | 476 |
| 447 // If the navigation is not deferred, run the callback. | 477 // If the navigation is not deferred, run the callback. |
| 448 if (result != NavigationThrottle::DEFER) | 478 if (result != NavigationThrottle::DEFER) |
| 449 RunCompleteCallback(result); | 479 RunCompleteCallback(result); |
| 450 } | 480 } |
| 451 | 481 |
| 452 void NavigationHandleImpl::ReadyToCommitNavigation( | 482 void NavigationHandleImpl::ReadyToCommitNavigation( |
| 453 RenderFrameHostImpl* render_frame_host) { | 483 RenderFrameHostImpl* render_frame_host) { |
| 454 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); | 484 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); |
| 455 render_frame_host_ = render_frame_host; | 485 render_frame_host_ = render_frame_host; |
| 456 state_ = READY_TO_COMMIT; | 486 state_ = READY_TO_COMMIT; |
| 457 | 487 |
| 458 // Only notify the WebContentsObservers when PlzNavigate is enabled, as | 488 GetDelegate()->ReadyToCommitNavigation(this); |
| 459 // |render_frame_host_| may be wrong in the case of transfer navigations. | |
| 460 if (IsBrowserSideNavigationEnabled()) | |
| 461 GetDelegate()->ReadyToCommitNavigation(this); | |
| 462 } | 489 } |
| 463 | 490 |
| 464 void NavigationHandleImpl::DidCommitNavigation( | 491 void NavigationHandleImpl::DidCommitNavigation( |
| 465 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, | 492 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, |
| 466 bool same_page, | 493 bool same_page, |
| 467 RenderFrameHostImpl* render_frame_host) { | 494 RenderFrameHostImpl* render_frame_host) { |
| 468 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); | 495 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); |
| 469 DCHECK_EQ(frame_tree_node_, render_frame_host->frame_tree_node()); | 496 DCHECK_EQ(frame_tree_node_, render_frame_host->frame_tree_node()); |
| 470 CHECK_EQ(url_, params.url); | 497 CHECK_EQ(url_, params.url); |
| 471 | 498 |
| 472 method_ = params.method; | 499 method_ = params.method; |
| 473 has_user_gesture_ = (params.gesture == NavigationGestureUser); | 500 has_user_gesture_ = (params.gesture == NavigationGestureUser); |
| 474 transition_ = params.transition; | 501 transition_ = params.transition; |
| 475 render_frame_host_ = render_frame_host; | 502 render_frame_host_ = render_frame_host; |
| 476 is_same_page_ = same_page; | 503 is_same_page_ = same_page; |
| 477 | 504 |
| 478 // If an error page reloads, net_error_code might be 200 but we still want to | 505 // If an error page reloads, net_error_code might be 200 but we still want to |
| 479 // count it as an error page. | 506 // count it as an error page. |
| 480 if (params.base_url.spec() == kUnreachableWebDataURL || | 507 if (params.base_url.spec() == kUnreachableWebDataURL || |
| 481 net_error_code_ != net::OK) { | 508 net_error_code_ != net::OK) { |
| 482 state_ = DID_COMMIT_ERROR_PAGE; | 509 state_ = DID_COMMIT_ERROR_PAGE; |
| 483 } else { | 510 } else { |
| 484 state_ = DID_COMMIT; | 511 state_ = DID_COMMIT; |
| 485 } | 512 } |
| 486 } | 513 } |
| 487 | 514 |
| 515 void NavigationHandleImpl::Transfer() { |
| 516 DCHECK(!IsBrowserSideNavigationEnabled()); |
| 517 // This is an actual transfer. Inform the NavigationResourceThrottle. This |
| 518 // will allow to mark the URLRequest as transferring. When it is marked as |
| 519 // transferring, the URLRequest can no longer be cancelled by its original |
| 520 // RenderFrame. Instead it will persist until being picked up by the transfer |
| 521 // RenderFrame, even if the original RenderFrame is destroyed. |
| 522 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, transfer_callback_); |
| 523 transfer_callback_.Reset(); |
| 524 } |
| 525 |
| 488 NavigationThrottle::ThrottleCheckResult | 526 NavigationThrottle::ThrottleCheckResult |
| 489 NavigationHandleImpl::CheckWillStartRequest() { | 527 NavigationHandleImpl::CheckWillStartRequest() { |
| 490 DCHECK(state_ == WILL_SEND_REQUEST || state_ == DEFERRING_START); | 528 DCHECK(state_ == WILL_SEND_REQUEST || state_ == DEFERRING_START); |
| 491 DCHECK(state_ != WILL_SEND_REQUEST || next_index_ == 0); | 529 DCHECK(state_ != WILL_SEND_REQUEST || next_index_ == 0); |
| 492 DCHECK(state_ != DEFERRING_START || next_index_ != 0); | 530 DCHECK(state_ != DEFERRING_START || next_index_ != 0); |
| 493 for (size_t i = next_index_; i < throttles_.size(); ++i) { | 531 for (size_t i = next_index_; i < throttles_.size(); ++i) { |
| 494 NavigationThrottle::ThrottleCheckResult result = | 532 NavigationThrottle::ThrottleCheckResult result = |
| 495 throttles_[i]->WillStartRequest(); | 533 throttles_[i]->WillStartRequest(); |
| 496 switch (result) { | 534 switch (result) { |
| 497 case NavigationThrottle::PROCEED: | 535 case NavigationThrottle::PROCEED: |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 | 612 |
| 575 case NavigationThrottle::BLOCK_REQUEST: | 613 case NavigationThrottle::BLOCK_REQUEST: |
| 576 NOTREACHED(); | 614 NOTREACHED(); |
| 577 } | 615 } |
| 578 } | 616 } |
| 579 next_index_ = 0; | 617 next_index_ = 0; |
| 580 state_ = WILL_PROCESS_RESPONSE; | 618 state_ = WILL_PROCESS_RESPONSE; |
| 581 return NavigationThrottle::PROCEED; | 619 return NavigationThrottle::PROCEED; |
| 582 } | 620 } |
| 583 | 621 |
| 622 bool NavigationHandleImpl::MaybeTransferAndProceed() { |
| 623 DCHECK_EQ(WILL_PROCESS_RESPONSE, state_); |
| 624 |
| 625 // Check if the navigation should transfer. This may result in the |
| 626 // destruction of this NavigationHandle, and the cancellation of the request. |
| 627 if (!MaybeTransferAndProceedInternal()) |
| 628 return false; |
| 629 |
| 630 // Inform observers that the navigation is now ready to commit, unless a |
| 631 // transfer of the navigation failed. |
| 632 ReadyToCommitNavigation(render_frame_host_); |
| 633 return true; |
| 634 } |
| 635 |
| 636 bool NavigationHandleImpl::MaybeTransferAndProceedInternal() { |
| 637 DCHECK(render_frame_host_); |
| 638 |
| 639 // PlzNavigate: the final RenderFrameHost handling this navigation has been |
| 640 // decided before calling WillProcessResponse in |
| 641 // NavigationRequest::OnResponseStarted. |
| 642 // TODO(clamy): See if PlzNavigate could use this code to check whether to |
| 643 // use the RFH determined at the start of the navigation or to switch to |
| 644 // another one. |
| 645 if (IsBrowserSideNavigationEnabled()) |
| 646 return true; |
| 647 |
| 648 // A navigation from a RenderFrame that is no longer active should not attempt |
| 649 // to transfer. |
| 650 if (!render_frame_host_->is_active()) { |
| 651 // This will cause the deletion of this NavigationHandle and the |
| 652 // cancellation of the navigation. |
| 653 // TODO(clamy): Remove the logging code once we understand better how we can |
| 654 // get there. |
| 655 base::debug::DumpWithoutCrashing(); |
| 656 render_frame_host_->SetNavigationHandle(nullptr); |
| 657 return false; |
| 658 } |
| 659 |
| 660 // Subframes shouldn't swap processes unless out-of-process iframes are |
| 661 // possible. |
| 662 if (!IsInMainFrame() && !SiteIsolationPolicy::AreCrossProcessFramesPossible()) |
| 663 return true; |
| 664 |
| 665 // If this is a download, do not do a cross-site check. The renderer will |
| 666 // see it is a download and abort the request. |
| 667 // |
| 668 // Similarly, HTTP 204 (No Content) responses leave the renderer showing the |
| 669 // previous page. The navigation should be allowed to finish without running |
| 670 // the unload handler or swapping in the pending RenderFrameHost. |
| 671 if (is_download_ || is_stream_ || |
| 672 (response_headers_.get() && response_headers_->response_code() == 204)) { |
| 673 return true; |
| 674 } |
| 675 |
| 676 // The content embedder can decide that a transfer to a different process is |
| 677 // required for this URL. |
| 678 bool should_transfer = |
| 679 GetContentClient()->browser()->ShouldSwapProcessesForRedirect( |
| 680 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), |
| 681 original_url_, url_); |
| 682 |
| 683 RenderFrameHostManager* manager = |
| 684 render_frame_host_->frame_tree_node()->render_manager(); |
| 685 |
| 686 // In the site-per-process model, the RenderFrameHostManager may also decide |
| 687 // (independently from the content embedder's ShouldSwapProcessesForRedirect |
| 688 // above) that a process transfer is needed. Process transfers are skipped for |
| 689 // WebUI processes for now, since e.g. chrome://settings has multiple |
| 690 // "cross-site" chrome:// frames, and that doesn't yet work cross-process. |
| 691 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() && |
| 692 !ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( |
| 693 render_frame_host_->GetProcess()->GetID())) { |
| 694 should_transfer |= manager->IsRendererTransferNeededForNavigation( |
| 695 render_frame_host_, url_); |
| 696 } |
| 697 |
| 698 // Start the transfer if needed. |
| 699 if (should_transfer) { |
| 700 // This may destroy the NavigationHandle if the transfer fails. |
| 701 base::WeakPtr<NavigationHandleImpl> weak_self = weak_factory_.GetWeakPtr(); |
| 702 manager->OnCrossSiteResponse(render_frame_host_, request_id_, |
| 703 redirect_chain_, sanitized_referrer_, |
| 704 transition_, should_replace_current_entry_); |
| 705 if (!weak_self) |
| 706 return false; |
| 707 } |
| 708 |
| 709 return true; |
| 710 } |
| 711 |
| 584 void NavigationHandleImpl::RunCompleteCallback( | 712 void NavigationHandleImpl::RunCompleteCallback( |
| 585 NavigationThrottle::ThrottleCheckResult result) { | 713 NavigationThrottle::ThrottleCheckResult result) { |
| 586 DCHECK(result != NavigationThrottle::DEFER); | 714 DCHECK(result != NavigationThrottle::DEFER); |
| 587 | 715 |
| 588 ThrottleChecksFinishedCallback callback = complete_callback_; | 716 ThrottleChecksFinishedCallback callback = complete_callback_; |
| 589 complete_callback_.Reset(); | 717 complete_callback_.Reset(); |
| 590 | 718 |
| 591 if (!callback.is_null()) | 719 if (!callback.is_null()) |
| 592 callback.Run(result); | 720 callback.Run(result); |
| 593 | 721 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 617 throttles_to_register.end()); | 745 throttles_to_register.end()); |
| 618 throttles_to_register.weak_clear(); | 746 throttles_to_register.weak_clear(); |
| 619 } | 747 } |
| 620 } | 748 } |
| 621 | 749 |
| 622 bool NavigationHandleImpl::WasStartedFromContextMenu() const { | 750 bool NavigationHandleImpl::WasStartedFromContextMenu() const { |
| 623 return started_from_context_menu_; | 751 return started_from_context_menu_; |
| 624 } | 752 } |
| 625 | 753 |
| 626 } // namespace content | 754 } // namespace content |
| OLD | NEW |