| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_request.h" | 5 #include "content/browser/frame_host/navigation_request.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "content/browser/appcache/appcache_navigation_handle.h" | 10 #include "content/browser/appcache/appcache_navigation_handle.h" |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 source_site_instance()->GetProcess()->FilterURL(false, &url); | 546 source_site_instance()->GetProcess()->FilterURL(false, &url); |
| 547 // FilterURL sets the URL to about:blank if the CSP checks prevent the | 547 // FilterURL sets the URL to about:blank if the CSP checks prevent the |
| 548 // renderer from accessing it. | 548 // renderer from accessing it. |
| 549 if ((url == url::kAboutBlankURL) && (url != common_params_.url)) { | 549 if ((url == url::kAboutBlankURL) && (url != common_params_.url)) { |
| 550 navigation_handle_->set_net_error_code(net::ERR_ABORTED); | 550 navigation_handle_->set_net_error_code(net::ERR_ABORTED); |
| 551 frame_tree_node_->ResetNavigationRequest(false, true); | 551 frame_tree_node_->ResetNavigationRequest(false, true); |
| 552 return; | 552 return; |
| 553 } | 553 } |
| 554 } | 554 } |
| 555 | 555 |
| 556 // Compute the SiteInstance to use for the redirect and pass its |
| 557 // RenderProcessHost if it has a process. Keep a reference if it has a |
| 558 // process, so that the SiteInstance and its associated process aren't deleted |
| 559 // before the navigation is ready to commit. |
| 560 scoped_refptr<SiteInstance> site_instance = |
| 561 frame_tree_node_->render_manager()->GetSiteInstanceForNavigationRequest( |
| 562 *this); |
| 563 speculative_site_instance_ = |
| 564 site_instance->HasProcess() ? site_instance : nullptr; |
| 565 |
| 566 // Check what the process of the SiteInstance is. It will be passed to the |
| 567 // NavigationHandle, and informed to expect a navigation to the redirected |
| 568 // URL. |
| 569 // Note: calling GetProcess on the SiteInstance can lead to the creation of a |
| 570 // new process if it doesn't have one. In this case, it should only be called |
| 571 // on a SiteInstance that already has a process. |
| 572 RenderProcessHost* expected_process = |
| 573 site_instance->HasProcess() ? site_instance->GetProcess() : nullptr; |
| 574 |
| 556 // It's safe to use base::Unretained because this NavigationRequest owns the | 575 // It's safe to use base::Unretained because this NavigationRequest owns the |
| 557 // NavigationHandle where the callback will be stored. | 576 // NavigationHandle where the callback will be stored. |
| 558 bool is_external_protocol = | 577 bool is_external_protocol = |
| 559 !GetContentClient()->browser()->IsHandledURL(common_params_.url); | 578 !GetContentClient()->browser()->IsHandledURL(common_params_.url); |
| 560 navigation_handle_->WillRedirectRequest( | 579 navigation_handle_->WillRedirectRequest( |
| 561 common_params_.url, common_params_.method, common_params_.referrer.url, | 580 common_params_.url, common_params_.method, common_params_.referrer.url, |
| 562 is_external_protocol, response->head.headers, | 581 is_external_protocol, response->head.headers, |
| 563 response->head.connection_info, | 582 response->head.connection_info, expected_process, |
| 564 base::Bind(&NavigationRequest::OnRedirectChecksComplete, | 583 base::Bind(&NavigationRequest::OnRedirectChecksComplete, |
| 565 base::Unretained(this))); | 584 base::Unretained(this))); |
| 566 } | 585 } |
| 567 | 586 |
| 568 void NavigationRequest::OnResponseStarted( | 587 void NavigationRequest::OnResponseStarted( |
| 569 const scoped_refptr<ResourceResponse>& response, | 588 const scoped_refptr<ResourceResponse>& response, |
| 570 std::unique_ptr<StreamHandle> body, | 589 std::unique_ptr<StreamHandle> body, |
| 571 mojo::ScopedDataPipeConsumerHandle consumer_handle, | 590 mojo::ScopedDataPipeConsumerHandle consumer_handle, |
| 572 const SSLStatus& ssl_status, | 591 const SSLStatus& ssl_status, |
| 573 std::unique_ptr<NavigationData> navigation_data, | 592 std::unique_ptr<NavigationData> navigation_data, |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 CSPDirective::FrameSrc, common_params_.url, is_redirect, | 1008 CSPDirective::FrameSrc, common_params_.url, is_redirect, |
| 990 common_params_.source_location.value_or(SourceLocation()), | 1009 common_params_.source_location.value_or(SourceLocation()), |
| 991 CSPContext::CHECK_ENFORCED_CSP)) { | 1010 CSPContext::CHECK_ENFORCED_CSP)) { |
| 992 return CONTENT_SECURITY_POLICY_CHECK_PASSED; | 1011 return CONTENT_SECURITY_POLICY_CHECK_PASSED; |
| 993 } | 1012 } |
| 994 | 1013 |
| 995 return CONTENT_SECURITY_POLICY_CHECK_FAILED; | 1014 return CONTENT_SECURITY_POLICY_CHECK_FAILED; |
| 996 } | 1015 } |
| 997 | 1016 |
| 998 } // namespace content | 1017 } // namespace content |
| OLD | NEW |