Chromium Code Reviews| 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), | |
| 87 is_download_(false), | |
| 88 is_stream_(false), | |
| 89 started_from_context_menu_(started_from_context_menu), | |
|
Charlie Reis
2016/10/05 22:29:34
I think we need to keep this line. (I see that yo
| |
| 90 weak_factory_(this) { | |
| 91 DCHECK(!navigation_start.is_null()); | 82 DCHECK(!navigation_start.is_null()); |
| 92 redirect_chain_.push_back(url); | |
| 93 GetDelegate()->DidStartNavigation(this); | 83 GetDelegate()->DidStartNavigation(this); |
| 94 | 84 |
| 95 if (IsInMainFrame()) { | 85 if (IsInMainFrame()) { |
| 96 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( | 86 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( |
| 97 "navigation", "Navigation StartToCommit", this, | 87 "navigation", "Navigation StartToCommit", this, |
| 98 navigation_start, "Initial URL", url_.spec()); | 88 navigation_start, "Initial URL", url_.spec()); |
| 99 } | 89 } |
| 100 } | 90 } |
| 101 | 91 |
| 102 NavigationHandleImpl::~NavigationHandleImpl() { | 92 NavigationHandleImpl::~NavigationHandleImpl() { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 } | 229 } |
| 240 | 230 |
| 241 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; | 231 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; |
| 242 if (state_ == DEFERRING_START) { | 232 if (state_ == DEFERRING_START) { |
| 243 result = CheckWillStartRequest(); | 233 result = CheckWillStartRequest(); |
| 244 } else if (state_ == DEFERRING_REDIRECT) { | 234 } else if (state_ == DEFERRING_REDIRECT) { |
| 245 result = CheckWillRedirectRequest(); | 235 result = CheckWillRedirectRequest(); |
| 246 } else { | 236 } else { |
| 247 result = CheckWillProcessResponse(); | 237 result = CheckWillProcessResponse(); |
| 248 | 238 |
| 249 // If the navigation is about to proceed after having been deferred while | 239 // If the navigation is about to proceed after processing the response, then |
| 250 // processing the response, then it's ready to commit. Determine which | 240 // it's ready to commit. |
| 251 // RenderFrameHost should render the response, based on its site (after any | 241 if (result == NavigationThrottle::PROCEED) |
| 252 // redirects). | 242 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 } | 243 } |
| 258 | 244 |
| 259 if (result != NavigationThrottle::DEFER) | 245 if (result != NavigationThrottle::DEFER) |
| 260 RunCompleteCallback(result); | 246 RunCompleteCallback(result); |
| 261 } | 247 } |
| 262 | 248 |
| 263 void NavigationHandleImpl::CancelDeferredNavigation( | 249 void NavigationHandleImpl::CancelDeferredNavigation( |
| 264 NavigationThrottle::ThrottleCheckResult result) { | 250 NavigationThrottle::ThrottleCheckResult result) { |
| 265 DCHECK(state_ == DEFERRING_START || state_ == DEFERRING_REDIRECT); | 251 DCHECK(state_ == DEFERRING_START || state_ == DEFERRING_REDIRECT); |
| 266 DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE || | 252 DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE || |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 321 } | 307 } |
| 322 | 308 |
| 323 NavigationThrottle::ThrottleCheckResult | 309 NavigationThrottle::ThrottleCheckResult |
| 324 NavigationHandleImpl::CallWillProcessResponseForTesting( | 310 NavigationHandleImpl::CallWillProcessResponseForTesting( |
| 325 content::RenderFrameHost* render_frame_host, | 311 content::RenderFrameHost* render_frame_host, |
| 326 const std::string& raw_response_headers) { | 312 const std::string& raw_response_headers) { |
| 327 scoped_refptr<net::HttpResponseHeaders> headers = | 313 scoped_refptr<net::HttpResponseHeaders> headers = |
| 328 new net::HttpResponseHeaders(raw_response_headers); | 314 new net::HttpResponseHeaders(raw_response_headers); |
| 329 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; | 315 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; |
| 330 WillProcessResponse(static_cast<RenderFrameHostImpl*>(render_frame_host), | 316 WillProcessResponse(static_cast<RenderFrameHostImpl*>(render_frame_host), |
| 331 headers, SSLStatus(), GlobalRequestID(), false, false, | 317 headers, SSLStatus(), |
| 332 false, base::Closure(), | |
| 333 base::Bind(&UpdateThrottleCheckResult, &result)); | 318 base::Bind(&UpdateThrottleCheckResult, &result)); |
| 334 | 319 |
| 335 // Reset the callback to ensure it will not be called later. | 320 // Reset the callback to ensure it will not be called later. |
| 336 complete_callback_.Reset(); | 321 complete_callback_.Reset(); |
| 337 return result; | 322 return result; |
| 338 } | 323 } |
| 339 | 324 |
| 340 void NavigationHandleImpl::CallDidCommitNavigationForTesting(const GURL& url) { | 325 void NavigationHandleImpl::CallDidCommitNavigationForTesting(const GURL& url) { |
| 341 FrameHostMsg_DidCommitProvisionalLoad_Params params; | 326 FrameHostMsg_DidCommitProvisionalLoad_Params params; |
| 342 | 327 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 418 scoped_refptr<net::HttpResponseHeaders> response_headers, | 403 scoped_refptr<net::HttpResponseHeaders> response_headers, |
| 419 const ThrottleChecksFinishedCallback& callback) { | 404 const ThrottleChecksFinishedCallback& callback) { |
| 420 // Update the navigation parameters. | 405 // Update the navigation parameters. |
| 421 url_ = new_url; | 406 url_ = new_url; |
| 422 method_ = new_method; | 407 method_ = new_method; |
| 423 sanitized_referrer_.url = new_referrer_url; | 408 sanitized_referrer_.url = new_referrer_url; |
| 424 sanitized_referrer_ = Referrer::SanitizeForRequest(url_, sanitized_referrer_); | 409 sanitized_referrer_ = Referrer::SanitizeForRequest(url_, sanitized_referrer_); |
| 425 is_external_protocol_ = new_is_external_protocol; | 410 is_external_protocol_ = new_is_external_protocol; |
| 426 response_headers_ = response_headers; | 411 response_headers_ = response_headers; |
| 427 was_redirected_ = true; | 412 was_redirected_ = true; |
| 428 redirect_chain_.push_back(new_url); | |
| 429 if (new_method != "POST") | 413 if (new_method != "POST") |
| 430 resource_request_body_ = nullptr; | 414 resource_request_body_ = nullptr; |
| 431 | 415 |
| 432 state_ = WILL_REDIRECT_REQUEST; | 416 state_ = WILL_REDIRECT_REQUEST; |
| 433 complete_callback_ = callback; | 417 complete_callback_ = callback; |
| 434 | 418 |
| 435 // Notify each throttle of the request. | 419 // Notify each throttle of the request. |
| 436 NavigationThrottle::ThrottleCheckResult result = CheckWillRedirectRequest(); | 420 NavigationThrottle::ThrottleCheckResult result = CheckWillRedirectRequest(); |
| 437 | 421 |
| 438 // If the navigation is not deferred, run the callback. | 422 // If the navigation is not deferred, run the callback. |
| 439 if (result != NavigationThrottle::DEFER) | 423 if (result != NavigationThrottle::DEFER) |
| 440 RunCompleteCallback(result); | 424 RunCompleteCallback(result); |
| 441 } | 425 } |
| 442 | 426 |
| 443 void NavigationHandleImpl::WillProcessResponse( | 427 void NavigationHandleImpl::WillProcessResponse( |
| 444 RenderFrameHostImpl* render_frame_host, | 428 RenderFrameHostImpl* render_frame_host, |
| 445 scoped_refptr<net::HttpResponseHeaders> response_headers, | 429 scoped_refptr<net::HttpResponseHeaders> response_headers, |
| 446 const SSLStatus& ssl_status, | 430 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) { | 431 const ThrottleChecksFinishedCallback& callback) { |
| 453 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); | 432 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); |
| 454 render_frame_host_ = render_frame_host; | 433 render_frame_host_ = render_frame_host; |
| 455 response_headers_ = response_headers; | 434 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; | 435 state_ = WILL_PROCESS_RESPONSE; |
| 461 ssl_status_ = ssl_status; | 436 ssl_status_ = ssl_status; |
| 462 complete_callback_ = callback; | 437 complete_callback_ = callback; |
| 463 transfer_callback_ = transfer_callback; | |
| 464 | 438 |
| 465 // Notify each throttle of the response. | 439 // Notify each throttle of the response. |
| 466 NavigationThrottle::ThrottleCheckResult result = CheckWillProcessResponse(); | 440 NavigationThrottle::ThrottleCheckResult result = CheckWillProcessResponse(); |
| 467 | 441 |
| 468 // If the navigation is done processing the response, then it's ready to | 442 // If the navigation is about to proceed, then it's ready to commit. |
| 469 // commit. Determine which RenderFrameHost should render the response, based | 443 if (result == NavigationThrottle::PROCEED) |
| 470 // on its site (after any redirects). | 444 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 | 445 |
| 476 // If the navigation is not deferred, run the callback. | 446 // If the navigation is not deferred, run the callback. |
| 477 if (result != NavigationThrottle::DEFER) | 447 if (result != NavigationThrottle::DEFER) |
| 478 RunCompleteCallback(result); | 448 RunCompleteCallback(result); |
| 479 } | 449 } |
| 480 | 450 |
| 481 void NavigationHandleImpl::ReadyToCommitNavigation( | 451 void NavigationHandleImpl::ReadyToCommitNavigation( |
| 482 RenderFrameHostImpl* render_frame_host) { | 452 RenderFrameHostImpl* render_frame_host) { |
| 483 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); | 453 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); |
| 484 render_frame_host_ = render_frame_host; | 454 render_frame_host_ = render_frame_host; |
| 485 state_ = READY_TO_COMMIT; | 455 state_ = READY_TO_COMMIT; |
| 486 | 456 |
| 487 GetDelegate()->ReadyToCommitNavigation(this); | 457 // Only notify the WebContentsObservers when PlzNavigate is enabled, as |
| 458 // |render_frame_host_| may be wrong in the case of transfer navigations. | |
| 459 if (IsBrowserSideNavigationEnabled()) | |
| 460 GetDelegate()->ReadyToCommitNavigation(this); | |
| 488 } | 461 } |
| 489 | 462 |
| 490 void NavigationHandleImpl::DidCommitNavigation( | 463 void NavigationHandleImpl::DidCommitNavigation( |
| 491 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, | 464 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, |
| 492 bool same_page, | 465 bool same_page, |
| 493 RenderFrameHostImpl* render_frame_host) { | 466 RenderFrameHostImpl* render_frame_host) { |
| 494 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); | 467 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); |
| 495 DCHECK_EQ(frame_tree_node_, render_frame_host->frame_tree_node()); | 468 DCHECK_EQ(frame_tree_node_, render_frame_host->frame_tree_node()); |
| 496 CHECK_EQ(url_, params.url); | 469 CHECK_EQ(url_, params.url); |
| 497 | 470 |
| 498 method_ = params.method; | 471 method_ = params.method; |
| 499 has_user_gesture_ = (params.gesture == NavigationGestureUser); | 472 has_user_gesture_ = (params.gesture == NavigationGestureUser); |
| 500 transition_ = params.transition; | 473 transition_ = params.transition; |
| 501 render_frame_host_ = render_frame_host; | 474 render_frame_host_ = render_frame_host; |
| 502 is_same_page_ = same_page; | 475 is_same_page_ = same_page; |
| 503 | 476 |
| 504 // If an error page reloads, net_error_code might be 200 but we still want to | 477 // If an error page reloads, net_error_code might be 200 but we still want to |
| 505 // count it as an error page. | 478 // count it as an error page. |
| 506 if (params.base_url.spec() == kUnreachableWebDataURL || | 479 if (params.base_url.spec() == kUnreachableWebDataURL || |
| 507 net_error_code_ != net::OK) { | 480 net_error_code_ != net::OK) { |
| 508 state_ = DID_COMMIT_ERROR_PAGE; | 481 state_ = DID_COMMIT_ERROR_PAGE; |
| 509 } else { | 482 } else { |
| 510 state_ = DID_COMMIT; | 483 state_ = DID_COMMIT; |
| 511 } | 484 } |
| 512 } | 485 } |
| 513 | 486 |
| 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 | 487 NavigationThrottle::ThrottleCheckResult |
| 526 NavigationHandleImpl::CheckWillStartRequest() { | 488 NavigationHandleImpl::CheckWillStartRequest() { |
| 527 DCHECK(state_ == WILL_SEND_REQUEST || state_ == DEFERRING_START); | 489 DCHECK(state_ == WILL_SEND_REQUEST || state_ == DEFERRING_START); |
| 528 DCHECK(state_ != WILL_SEND_REQUEST || next_index_ == 0); | 490 DCHECK(state_ != WILL_SEND_REQUEST || next_index_ == 0); |
| 529 DCHECK(state_ != DEFERRING_START || next_index_ != 0); | 491 DCHECK(state_ != DEFERRING_START || next_index_ != 0); |
| 530 for (size_t i = next_index_; i < throttles_.size(); ++i) { | 492 for (size_t i = next_index_; i < throttles_.size(); ++i) { |
| 531 NavigationThrottle::ThrottleCheckResult result = | 493 NavigationThrottle::ThrottleCheckResult result = |
| 532 throttles_[i]->WillStartRequest(); | 494 throttles_[i]->WillStartRequest(); |
| 533 switch (result) { | 495 switch (result) { |
| 534 case NavigationThrottle::PROCEED: | 496 case NavigationThrottle::PROCEED: |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 611 | 573 |
| 612 case NavigationThrottle::BLOCK_REQUEST: | 574 case NavigationThrottle::BLOCK_REQUEST: |
| 613 NOTREACHED(); | 575 NOTREACHED(); |
| 614 } | 576 } |
| 615 } | 577 } |
| 616 next_index_ = 0; | 578 next_index_ = 0; |
| 617 state_ = WILL_PROCESS_RESPONSE; | 579 state_ = WILL_PROCESS_RESPONSE; |
| 618 return NavigationThrottle::PROCEED; | 580 return NavigationThrottle::PROCEED; |
| 619 } | 581 } |
| 620 | 582 |
| 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( | 583 void NavigationHandleImpl::RunCompleteCallback( |
| 704 NavigationThrottle::ThrottleCheckResult result) { | 584 NavigationThrottle::ThrottleCheckResult result) { |
| 705 DCHECK(result != NavigationThrottle::DEFER); | 585 DCHECK(result != NavigationThrottle::DEFER); |
| 706 | 586 |
| 707 ThrottleChecksFinishedCallback callback = complete_callback_; | 587 ThrottleChecksFinishedCallback callback = complete_callback_; |
| 708 complete_callback_.Reset(); | 588 complete_callback_.Reset(); |
| 709 | 589 |
| 710 if (!callback.is_null()) | 590 if (!callback.is_null()) |
| 711 callback.Run(result); | 591 callback.Run(result); |
| 712 | 592 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 736 throttles_to_register.end()); | 616 throttles_to_register.end()); |
| 737 throttles_to_register.weak_clear(); | 617 throttles_to_register.weak_clear(); |
| 738 } | 618 } |
| 739 } | 619 } |
| 740 | 620 |
| 741 bool NavigationHandleImpl::WasStartedFromContextMenu() const { | 621 bool NavigationHandleImpl::WasStartedFromContextMenu() const { |
| 742 return started_from_context_menu_; | 622 return started_from_context_menu_; |
| 743 } | 623 } |
| 744 | 624 |
| 745 } // namespace content | 625 } // namespace content |
| OLD | NEW |