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