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" | |
| 11 #include "content/browser/devtools/render_frame_devtools_agent_host.h" | 12 #include "content/browser/devtools/render_frame_devtools_agent_host.h" |
| 12 #include "content/browser/frame_host/frame_tree_node.h" | 13 #include "content/browser/frame_host/frame_tree_node.h" |
| 13 #include "content/browser/frame_host/navigator.h" | 14 #include "content/browser/frame_host/navigator.h" |
| 14 #include "content/browser/frame_host/navigator_delegate.h" | 15 #include "content/browser/frame_host/navigator_delegate.h" |
| 15 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 16 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 16 #include "content/common/frame_messages.h" | 17 #include "content/common/frame_messages.h" |
| 17 #include "content/common/resource_request_body_impl.h" | 18 #include "content/common/resource_request_body_impl.h" |
| 19 #include "content/common/site_isolation_policy.h" | |
| 18 #include "content/public/browser/content_browser_client.h" | 20 #include "content/public/browser/content_browser_client.h" |
| 21 #include "content/public/browser/site_instance.h" | |
| 19 #include "content/public/common/browser_side_navigation_policy.h" | 22 #include "content/public/common/browser_side_navigation_policy.h" |
| 20 #include "content/public/common/content_client.h" | 23 #include "content/public/common/content_client.h" |
| 21 #include "net/url_request/redirect_info.h" | 24 #include "net/url_request/redirect_info.h" |
| 22 #include "url/gurl.h" | 25 #include "url/gurl.h" |
| 23 #include "url/url_constants.h" | 26 #include "url/url_constants.h" |
| 24 | 27 |
| 25 namespace content { | 28 namespace content { |
| 26 | 29 |
| 27 namespace { | 30 namespace { |
| 28 | 31 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 61 has_user_gesture_(false), | 64 has_user_gesture_(false), |
| 62 transition_(ui::PAGE_TRANSITION_LINK), | 65 transition_(ui::PAGE_TRANSITION_LINK), |
| 63 is_external_protocol_(false), | 66 is_external_protocol_(false), |
| 64 net_error_code_(net::OK), | 67 net_error_code_(net::OK), |
| 65 render_frame_host_(nullptr), | 68 render_frame_host_(nullptr), |
| 66 is_renderer_initiated_(is_renderer_initiated), | 69 is_renderer_initiated_(is_renderer_initiated), |
| 67 is_same_page_(false), | 70 is_same_page_(false), |
| 68 is_synchronous_(is_synchronous), | 71 is_synchronous_(is_synchronous), |
| 69 is_srcdoc_(is_srcdoc), | 72 is_srcdoc_(is_srcdoc), |
| 70 was_redirected_(false), | 73 was_redirected_(false), |
| 74 original_url_(url), | |
| 71 state_(INITIAL), | 75 state_(INITIAL), |
| 72 is_transferring_(false), | 76 is_transferring_(false), |
| 73 frame_tree_node_(frame_tree_node), | 77 frame_tree_node_(frame_tree_node), |
| 74 next_index_(0), | 78 next_index_(0), |
| 75 navigation_start_(navigation_start), | 79 navigation_start_(navigation_start), |
| 76 pending_nav_entry_id_(pending_nav_entry_id), | 80 pending_nav_entry_id_(pending_nav_entry_id), |
| 77 request_context_type_(REQUEST_CONTEXT_TYPE_UNSPECIFIED) { | 81 request_context_type_(REQUEST_CONTEXT_TYPE_UNSPECIFIED), |
| 82 should_replace_current_entry_(false), | |
| 83 is_download_(false), | |
| 84 is_stream_(false), | |
| 85 weak_factory_(this) { | |
| 78 DCHECK(!navigation_start.is_null()); | 86 DCHECK(!navigation_start.is_null()); |
| 79 GetDelegate()->DidStartNavigation(this); | 87 GetDelegate()->DidStartNavigation(this); |
| 88 redirect_chain_.push_back(url); | |
|
Charlie Reis
2016/09/16 21:19:25
Why is this after the DidStartNavigation call? I
clamy
2016/09/20 15:57:22
Done.
| |
| 80 | 89 |
| 81 if (IsInMainFrame()) { | 90 if (IsInMainFrame()) { |
| 82 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( | 91 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( |
| 83 "navigation", "Navigation StartToCommit", this, | 92 "navigation", "Navigation StartToCommit", this, |
| 84 navigation_start.ToInternalValue(), "Initial URL", url_.spec()); | 93 navigation_start.ToInternalValue(), "Initial URL", url_.spec()); |
| 85 } | 94 } |
| 86 } | 95 } |
| 87 | 96 |
| 88 NavigationHandleImpl::~NavigationHandleImpl() { | 97 NavigationHandleImpl::~NavigationHandleImpl() { |
| 89 GetDelegate()->DidFinishNavigation(this); | 98 GetDelegate()->DidFinishNavigation(this); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 | 236 |
| 228 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; | 237 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; |
| 229 if (state_ == DEFERRING_START) { | 238 if (state_ == DEFERRING_START) { |
| 230 result = CheckWillStartRequest(); | 239 result = CheckWillStartRequest(); |
| 231 } else if (state_ == DEFERRING_REDIRECT) { | 240 } else if (state_ == DEFERRING_REDIRECT) { |
| 232 result = CheckWillRedirectRequest(); | 241 result = CheckWillRedirectRequest(); |
| 233 } else { | 242 } else { |
| 234 result = CheckWillProcessResponse(); | 243 result = CheckWillProcessResponse(); |
| 235 | 244 |
| 236 // If the navigation is about to proceed after processing the response, then | 245 // If the navigation is about to proceed after processing the response, then |
| 237 // it's ready to commit. | 246 // it's ready to commit. Determine the final RenderFrameHost handling it. |
|
Charlie Reis
2016/09/16 21:19:25
nit: Change last sentence to: Determine which Rend
clamy
2016/09/20 15:57:22
Done.
| |
| 238 if (result == NavigationThrottle::PROCEED) | 247 // Note: if FindFinalRenderFrameHost() returns false, this means that this |
| 239 ReadyToCommitNavigation(render_frame_host_); | 248 // NavigationHandle was deleted, so return immediately. |
| 249 if (result == NavigationThrottle::PROCEED && !FindFinalRenderFrameHost()) | |
| 250 return; | |
| 240 } | 251 } |
| 241 | 252 |
| 242 if (result != NavigationThrottle::DEFER) | 253 if (result != NavigationThrottle::DEFER) |
| 243 RunCompleteCallback(result); | 254 RunCompleteCallback(result); |
| 244 } | 255 } |
| 245 | 256 |
| 246 void NavigationHandleImpl::CancelDeferredNavigation( | 257 void NavigationHandleImpl::CancelDeferredNavigation( |
| 247 NavigationThrottle::ThrottleCheckResult result) { | 258 NavigationThrottle::ThrottleCheckResult result) { |
| 248 DCHECK(state_ == DEFERRING_START || state_ == DEFERRING_REDIRECT); | 259 DCHECK(state_ == DEFERRING_START || state_ == DEFERRING_REDIRECT); |
| 249 DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE || | 260 DCHECK(result == NavigationThrottle::CANCEL_AND_IGNORE || |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 complete_callback_.Reset(); | 313 complete_callback_.Reset(); |
| 303 return result; | 314 return result; |
| 304 } | 315 } |
| 305 | 316 |
| 306 NavigationThrottle::ThrottleCheckResult | 317 NavigationThrottle::ThrottleCheckResult |
| 307 NavigationHandleImpl::CallWillProcessResponseForTesting( | 318 NavigationHandleImpl::CallWillProcessResponseForTesting( |
| 308 content::RenderFrameHost* render_frame_host) { | 319 content::RenderFrameHost* render_frame_host) { |
| 309 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; | 320 NavigationThrottle::ThrottleCheckResult result = NavigationThrottle::DEFER; |
| 310 WillProcessResponse(static_cast<RenderFrameHostImpl*>(render_frame_host), | 321 WillProcessResponse(static_cast<RenderFrameHostImpl*>(render_frame_host), |
| 311 scoped_refptr<net::HttpResponseHeaders>(), SSLStatus(), | 322 scoped_refptr<net::HttpResponseHeaders>(), SSLStatus(), |
| 323 GlobalRequestID(), false, false, false, base::Closure(), | |
| 312 base::Bind(&UpdateThrottleCheckResult, &result)); | 324 base::Bind(&UpdateThrottleCheckResult, &result)); |
| 313 | 325 |
| 314 // Reset the callback to ensure it will not be called later. | 326 // Reset the callback to ensure it will not be called later. |
| 315 complete_callback_.Reset(); | 327 complete_callback_.Reset(); |
| 316 return result; | 328 return result; |
| 317 } | 329 } |
| 318 | 330 |
| 319 NavigationData* NavigationHandleImpl::GetNavigationData() { | 331 NavigationData* NavigationHandleImpl::GetNavigationData() { |
| 320 return navigation_data_.get(); | 332 return navigation_data_.get(); |
| 321 } | 333 } |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 365 scoped_refptr<net::HttpResponseHeaders> response_headers, | 377 scoped_refptr<net::HttpResponseHeaders> response_headers, |
| 366 const ThrottleChecksFinishedCallback& callback) { | 378 const ThrottleChecksFinishedCallback& callback) { |
| 367 // Update the navigation parameters. | 379 // Update the navigation parameters. |
| 368 url_ = new_url; | 380 url_ = new_url; |
| 369 method_ = new_method; | 381 method_ = new_method; |
| 370 sanitized_referrer_.url = new_referrer_url; | 382 sanitized_referrer_.url = new_referrer_url; |
| 371 sanitized_referrer_ = Referrer::SanitizeForRequest(url_, sanitized_referrer_); | 383 sanitized_referrer_ = Referrer::SanitizeForRequest(url_, sanitized_referrer_); |
| 372 is_external_protocol_ = new_is_external_protocol; | 384 is_external_protocol_ = new_is_external_protocol; |
| 373 response_headers_ = response_headers; | 385 response_headers_ = response_headers; |
| 374 was_redirected_ = true; | 386 was_redirected_ = true; |
| 387 redirect_chain_.push_back(new_url); | |
| 375 if (new_method != "POST") | 388 if (new_method != "POST") |
| 376 resource_request_body_ = nullptr; | 389 resource_request_body_ = nullptr; |
| 377 | 390 |
| 378 state_ = WILL_REDIRECT_REQUEST; | 391 state_ = WILL_REDIRECT_REQUEST; |
| 379 complete_callback_ = callback; | 392 complete_callback_ = callback; |
| 380 | 393 |
| 381 // Notify each throttle of the request. | 394 // Notify each throttle of the request. |
| 382 NavigationThrottle::ThrottleCheckResult result = CheckWillRedirectRequest(); | 395 NavigationThrottle::ThrottleCheckResult result = CheckWillRedirectRequest(); |
| 383 | 396 |
| 384 // If the navigation is not deferred, run the callback. | 397 // If the navigation is not deferred, run the callback. |
| 385 if (result != NavigationThrottle::DEFER) | 398 if (result != NavigationThrottle::DEFER) |
| 386 RunCompleteCallback(result); | 399 RunCompleteCallback(result); |
| 387 } | 400 } |
| 388 | 401 |
| 389 void NavigationHandleImpl::WillProcessResponse( | 402 void NavigationHandleImpl::WillProcessResponse( |
| 390 RenderFrameHostImpl* render_frame_host, | 403 RenderFrameHostImpl* render_frame_host, |
| 391 scoped_refptr<net::HttpResponseHeaders> response_headers, | 404 scoped_refptr<net::HttpResponseHeaders> response_headers, |
| 392 const SSLStatus& ssl_status, | 405 const SSLStatus& ssl_status, |
| 406 const GlobalRequestID& request_id, | |
| 407 bool should_replace_current_entry, | |
| 408 bool is_download, | |
| 409 bool is_stream, | |
| 410 const base::Closure& transfer_callback, | |
| 393 const ThrottleChecksFinishedCallback& callback) { | 411 const ThrottleChecksFinishedCallback& callback) { |
| 394 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); | 412 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); |
| 395 render_frame_host_ = render_frame_host; | 413 render_frame_host_ = render_frame_host; |
| 396 response_headers_ = response_headers; | 414 response_headers_ = response_headers; |
| 415 request_id_ = request_id; | |
| 416 should_replace_current_entry_ = should_replace_current_entry; | |
| 417 is_download_ = is_download; | |
| 418 is_stream_ = is_stream; | |
| 397 state_ = WILL_PROCESS_RESPONSE; | 419 state_ = WILL_PROCESS_RESPONSE; |
| 398 ssl_status_ = ssl_status; | 420 ssl_status_ = ssl_status; |
| 399 complete_callback_ = callback; | 421 complete_callback_ = callback; |
| 422 transfer_callback_ = transfer_callback; | |
| 400 | 423 |
| 401 // Notify each throttle of the response. | 424 // Notify each throttle of the response. |
| 402 NavigationThrottle::ThrottleCheckResult result = CheckWillProcessResponse(); | 425 NavigationThrottle::ThrottleCheckResult result = CheckWillProcessResponse(); |
| 403 | 426 |
| 404 // If the navigation is about to proceed, then it's ready to commit. | 427 // If the navigation is about to proceed, check for the final RenderFrameHost |
| 405 if (result == NavigationThrottle::PROCEED) | 428 // for the navigation. |
|
Charlie Reis
2016/09/16 21:19:25
Let's use the same comment as in Resume().
Why do
clamy
2016/09/20 15:57:22
Done. I've slightly modified the first part of the
| |
| 406 ReadyToCommitNavigation(render_frame_host); | 429 // Note: if FindFinalRenderFrameHost() returns false, this means that this |
| 430 // NavigationHandle was deleted, so return immediately. | |
| 431 if (result == NavigationThrottle::PROCEED && !FindFinalRenderFrameHost()) | |
| 432 return; | |
| 407 | 433 |
| 408 // If the navigation is not deferred, run the callback. | 434 // If the navigation is not deferred, run the callback. |
| 409 if (result != NavigationThrottle::DEFER) | 435 if (result != NavigationThrottle::DEFER) |
| 410 RunCompleteCallback(result); | 436 RunCompleteCallback(result); |
| 411 } | 437 } |
| 412 | 438 |
| 413 void NavigationHandleImpl::ReadyToCommitNavigation( | 439 void NavigationHandleImpl::ReadyToCommitNavigation( |
| 414 RenderFrameHostImpl* render_frame_host) { | 440 RenderFrameHostImpl* render_frame_host) { |
| 415 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); | 441 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); |
| 416 render_frame_host_ = render_frame_host; | 442 render_frame_host_ = render_frame_host; |
| 417 state_ = READY_TO_COMMIT; | 443 state_ = READY_TO_COMMIT; |
| 418 | 444 |
| 419 // Only notify the WebContentsObservers when PlzNavigate is enabled, as | 445 GetDelegate()->ReadyToCommitNavigation(this); |
| 420 // |render_frame_host_| may be wrong in the case of transfer navigations. | |
| 421 if (IsBrowserSideNavigationEnabled()) | |
| 422 GetDelegate()->ReadyToCommitNavigation(this); | |
| 423 } | 446 } |
| 424 | 447 |
| 425 void NavigationHandleImpl::DidCommitNavigation( | 448 void NavigationHandleImpl::DidCommitNavigation( |
| 426 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, | 449 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, |
| 427 bool same_page, | 450 bool same_page, |
| 428 RenderFrameHostImpl* render_frame_host) { | 451 RenderFrameHostImpl* render_frame_host) { |
| 429 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); | 452 DCHECK(!render_frame_host_ || render_frame_host_ == render_frame_host); |
| 430 DCHECK_EQ(frame_tree_node_, render_frame_host->frame_tree_node()); | 453 DCHECK_EQ(frame_tree_node_, render_frame_host->frame_tree_node()); |
| 431 CHECK_EQ(url_, params.url); | 454 CHECK_EQ(url_, params.url); |
| 432 | 455 |
| 433 method_ = params.method; | 456 method_ = params.method; |
| 434 has_user_gesture_ = (params.gesture == NavigationGestureUser); | 457 has_user_gesture_ = (params.gesture == NavigationGestureUser); |
| 435 transition_ = params.transition; | 458 transition_ = params.transition; |
| 436 render_frame_host_ = render_frame_host; | 459 render_frame_host_ = render_frame_host; |
| 437 is_same_page_ = same_page; | 460 is_same_page_ = same_page; |
| 438 | 461 |
| 439 state_ = net_error_code_ == net::OK ? DID_COMMIT : DID_COMMIT_ERROR_PAGE; | 462 state_ = net_error_code_ == net::OK ? DID_COMMIT : DID_COMMIT_ERROR_PAGE; |
| 440 } | 463 } |
| 441 | 464 |
| 465 void NavigationHandleImpl::TransferToSiteInstance(SiteInstance* site_instance) { | |
| 466 DCHECK(!IsBrowserSideNavigationEnabled()); | |
| 467 if (site_instance->GetId() != | |
| 468 render_frame_host_->GetSiteInstance()->GetId()) { | |
|
Charlie Reis
2016/09/16 21:19:26
It's a bit unexpected to call this method if no tr
clamy
2016/09/20 15:57:21
Done.
| |
| 469 // This is an actual transfer. Inform the NavigationResourceThrottle. | |
|
Charlie Reis
2016/09/16 21:19:25
Please elaborate on why the IO thread needs to kno
clamy
2016/09/20 15:57:21
I have elaborated in the comments.
| |
| 470 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, transfer_callback_); | |
| 471 transfer_callback_.Reset(); | |
| 472 } | |
| 473 } | |
| 474 | |
| 475 void NavigationHandleImpl::TransferToRenderFrameHost( | |
|
Charlie Reis
2016/09/16 21:19:26
This is very different from TransferToSiteInstance
clamy
2016/09/20 15:57:21
Done.
| |
| 476 RenderFrameHostImpl* render_frame_host) { | |
| 477 render_frame_host_ = render_frame_host; | |
| 478 } | |
| 479 | |
| 442 NavigationThrottle::ThrottleCheckResult | 480 NavigationThrottle::ThrottleCheckResult |
| 443 NavigationHandleImpl::CheckWillStartRequest() { | 481 NavigationHandleImpl::CheckWillStartRequest() { |
| 444 DCHECK(state_ == WILL_SEND_REQUEST || state_ == DEFERRING_START); | 482 DCHECK(state_ == WILL_SEND_REQUEST || state_ == DEFERRING_START); |
| 445 DCHECK(state_ != WILL_SEND_REQUEST || next_index_ == 0); | 483 DCHECK(state_ != WILL_SEND_REQUEST || next_index_ == 0); |
| 446 DCHECK(state_ != DEFERRING_START || next_index_ != 0); | 484 DCHECK(state_ != DEFERRING_START || next_index_ != 0); |
| 447 for (size_t i = next_index_; i < throttles_.size(); ++i) { | 485 for (size_t i = next_index_; i < throttles_.size(); ++i) { |
| 448 NavigationThrottle::ThrottleCheckResult result = | 486 NavigationThrottle::ThrottleCheckResult result = |
| 449 throttles_[i]->WillStartRequest(); | 487 throttles_[i]->WillStartRequest(); |
| 450 switch (result) { | 488 switch (result) { |
| 451 case NavigationThrottle::PROCEED: | 489 case NavigationThrottle::PROCEED: |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 528 | 566 |
| 529 case NavigationThrottle::BLOCK_REQUEST: | 567 case NavigationThrottle::BLOCK_REQUEST: |
| 530 NOTREACHED(); | 568 NOTREACHED(); |
| 531 } | 569 } |
| 532 } | 570 } |
| 533 next_index_ = 0; | 571 next_index_ = 0; |
| 534 state_ = WILL_PROCESS_RESPONSE; | 572 state_ = WILL_PROCESS_RESPONSE; |
| 535 return NavigationThrottle::PROCEED; | 573 return NavigationThrottle::PROCEED; |
| 536 } | 574 } |
| 537 | 575 |
| 576 bool NavigationHandleImpl::FindFinalRenderFrameHost() { | |
|
Charlie Reis
2016/09/16 21:19:25
This method feels misnamed, because it doesn't do
clamy
2016/09/20 15:57:22
Done.
| |
| 577 DCHECK_EQ(WILL_PROCESS_RESPONSE, state_); | |
| 578 | |
| 579 // Check if the navigation should transfer. This may result in the | |
| 580 // destruction of this NavigationHandle, and the cancellation of the request. | |
| 581 if (!MaybeTransferAndProceed()) | |
| 582 return false; | |
| 583 | |
| 584 // Inform observers that the navigation is now ready to commit, unless a | |
| 585 // transfer of the navigation failed. | |
| 586 ReadyToCommitNavigation(render_frame_host_); | |
| 587 return true; | |
| 588 } | |
| 589 | |
| 590 bool NavigationHandleImpl::MaybeTransferAndProceed() { | |
| 591 DCHECK(render_frame_host_); | |
| 592 // PlzNavigate: the final RenderFrameHost handling this navigation has been | |
| 593 // decided before calling WillProcessResponse. | |
|
Charlie Reis
2016/09/16 21:19:26
Where does this happen? It would have been nice t
clamy
2016/09/20 15:57:22
We already had code written to chose a RFH to comm
Charlie Reis
2016/09/21 03:31:47
Yes, no need to move PlzNavigate code in this CL.
| |
| 594 if (IsBrowserSideNavigationEnabled()) | |
| 595 return true; | |
| 596 | |
| 597 // Subframes shouldn't swap processes unless out-of-process iframes are | |
| 598 // possible. | |
| 599 if (!IsInMainFrame() && !SiteIsolationPolicy::AreCrossProcessFramesPossible()) | |
| 600 return true; | |
| 601 | |
| 602 // If this is a download, do not do a cross-site check. The renderer will | |
| 603 // see it is a download and abort the request. | |
| 604 // | |
| 605 // Similarly, HTTP 204 (No Content) responses leave the renderer showing the | |
| 606 // previous page. The navigation should be allowed to finish without running | |
| 607 // the unload handler or swapping in the pending RenderFrameHost. | |
| 608 if (is_download_ || is_stream_ || | |
| 609 (response_headers_.get() && response_headers_->response_code() == 204)) { | |
| 610 return true; | |
| 611 } | |
| 612 | |
| 613 // The content embedder can decide that a transfer to a different process is | |
| 614 // required for this URL. | |
| 615 bool should_transfer = | |
| 616 GetContentClient()->browser()->ShouldSwapProcessesForRedirect( | |
| 617 frame_tree_node_->navigator()->GetController()->GetBrowserContext(), | |
| 618 original_url_, url_); | |
| 619 | |
| 620 RenderFrameHostManager* manager = | |
| 621 render_frame_host_->frame_tree_node()->render_manager(); | |
| 622 | |
| 623 // In the site-per-process model, the RenderFrameHostManager may also decide | |
| 624 // (independently from the content embedder's ShouldSwapProcessesForRedirect | |
| 625 // above) that a process transfer is needed. Process transfers are skipped for | |
| 626 // WebUI processes for now, since e.g. chrome://settings has multiple | |
| 627 // "cross-site" chrome:// frames, and that doesn't yet work cross- process. | |
| 628 if (SiteIsolationPolicy::AreCrossProcessFramesPossible() && | |
| 629 !ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( | |
| 630 render_frame_host_->GetProcess()->GetID())) { | |
| 631 should_transfer |= manager->IsRendererTransferNeededForNavigation( | |
| 632 render_frame_host_, url_); | |
| 633 } | |
| 634 | |
| 635 // Start the transfer if needed. | |
| 636 if (should_transfer) { | |
| 637 // This may destroy the NavigationHandle if the transfer fails. | |
| 638 base::WeakPtr<NavigationHandleImpl> weak_self = weak_factory_.GetWeakPtr(); | |
| 639 manager->OnCrossSiteResponse(render_frame_host_, request_id_, | |
| 640 redirect_chain_, sanitized_referrer_, | |
| 641 transition_, should_replace_current_entry_); | |
| 642 if (!weak_self) | |
| 643 return false; | |
| 644 } | |
| 645 | |
| 646 return true; | |
| 647 } | |
| 648 | |
| 538 void NavigationHandleImpl::RunCompleteCallback( | 649 void NavigationHandleImpl::RunCompleteCallback( |
| 539 NavigationThrottle::ThrottleCheckResult result) { | 650 NavigationThrottle::ThrottleCheckResult result) { |
| 540 DCHECK(result != NavigationThrottle::DEFER); | 651 DCHECK(result != NavigationThrottle::DEFER); |
| 541 | 652 |
| 542 ThrottleChecksFinishedCallback callback = complete_callback_; | 653 ThrottleChecksFinishedCallback callback = complete_callback_; |
| 543 complete_callback_.Reset(); | 654 complete_callback_.Reset(); |
| 544 | 655 |
| 545 if (!callback.is_null()) | 656 if (!callback.is_null()) |
| 546 callback.Run(result); | 657 callback.Run(result); |
| 547 | 658 |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 567 throttles_to_register.push_back(std::move(clear_site_data_throttle)); | 678 throttles_to_register.push_back(std::move(clear_site_data_throttle)); |
| 568 | 679 |
| 569 if (throttles_to_register.size() > 0) { | 680 if (throttles_to_register.size() > 0) { |
| 570 throttles_.insert(throttles_.begin(), throttles_to_register.begin(), | 681 throttles_.insert(throttles_.begin(), throttles_to_register.begin(), |
| 571 throttles_to_register.end()); | 682 throttles_to_register.end()); |
| 572 throttles_to_register.weak_clear(); | 683 throttles_to_register.weak_clear(); |
| 573 } | 684 } |
| 574 } | 685 } |
| 575 | 686 |
| 576 } // namespace content | 687 } // namespace content |
| OLD | NEW |