OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading | 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading |
6 | 6 |
7 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 7 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
8 | 8 |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 CHECK_NE(info->GetContext(), context); | 740 CHECK_NE(info->GetContext(), context); |
741 } | 741 } |
742 } | 742 } |
743 } | 743 } |
744 | 744 |
745 DownloadInterruptReason ResourceDispatcherHostImpl::BeginDownload( | 745 DownloadInterruptReason ResourceDispatcherHostImpl::BeginDownload( |
746 std::unique_ptr<net::URLRequest> request, | 746 std::unique_ptr<net::URLRequest> request, |
747 const Referrer& referrer, | 747 const Referrer& referrer, |
748 bool is_content_initiated, | 748 bool is_content_initiated, |
749 ResourceContext* context, | 749 ResourceContext* context, |
750 int child_id, | 750 int render_process_id, |
751 int render_view_route_id, | 751 int render_view_route_id, |
752 int render_frame_route_id, | 752 int render_frame_route_id, |
753 bool do_not_prompt_for_login) { | 753 bool do_not_prompt_for_login) { |
754 if (is_shutdown_) | 754 if (is_shutdown_) |
755 return DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN; | 755 return DOWNLOAD_INTERRUPT_REASON_USER_SHUTDOWN; |
756 | 756 |
757 const GURL& url = request->original_url(); | 757 const GURL& url = request->original_url(); |
758 | 758 |
759 // http://crbug.com/90971 | 759 // http://crbug.com/90971 |
760 char url_buf[128]; | 760 char url_buf[128]; |
761 base::strlcpy(url_buf, url.spec().c_str(), arraysize(url_buf)); | 761 base::strlcpy(url_buf, url.spec().c_str(), arraysize(url_buf)); |
762 base::debug::Alias(url_buf); | 762 base::debug::Alias(url_buf); |
763 CHECK(ContainsKey(active_resource_contexts_, context)); | 763 CHECK(ContainsKey(active_resource_contexts_, context)); |
764 | 764 |
765 SetReferrerForRequest(request.get(), referrer); | 765 SetReferrerForRequest(request.get(), referrer); |
766 | 766 |
767 // We treat a download as a main frame load, and thus update the policy URL on | 767 // We treat a download as a main frame load, and thus update the policy URL on |
768 // redirects. | 768 // redirects. |
769 // | 769 // |
770 // TODO(davidben): Is this correct? If this came from a | 770 // TODO(davidben): Is this correct? If this came from a |
771 // ViewHostMsg_DownloadUrl in a frame, should it have first-party URL set | 771 // ViewHostMsg_DownloadUrl in a frame, should it have first-party URL set |
772 // appropriately? | 772 // appropriately? |
773 request->set_first_party_url_policy( | 773 request->set_first_party_url_policy( |
774 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); | 774 net::URLRequest::UPDATE_FIRST_PARTY_URL_ON_REDIRECT); |
775 | 775 |
776 // Check if the renderer is permitted to request the requested URL. | 776 // Check if the renderer is permitted to request the requested URL. |
777 if (!ChildProcessSecurityPolicyImpl::GetInstance()-> | 777 if (!ChildProcessSecurityPolicyImpl::GetInstance()-> |
778 CanRequestURL(child_id, url)) { | 778 CanRequestURL(render_process_id, url)) { |
779 DVLOG(1) << "Denied unauthorized download request for " | 779 DVLOG(1) << "Denied unauthorized download request for " |
780 << url.possibly_invalid_spec(); | 780 << url.possibly_invalid_spec(); |
781 return DOWNLOAD_INTERRUPT_REASON_NETWORK_INVALID_REQUEST; | 781 return DOWNLOAD_INTERRUPT_REASON_NETWORK_INVALID_REQUEST; |
782 } | 782 } |
783 | 783 |
784 request_id_--; | 784 request_id_--; |
785 | 785 |
786 const net::URLRequestContext* request_context = request->context(); | 786 const net::URLRequestContext* request_context = request->context(); |
787 if (!request_context->job_factory()->IsHandledURL(url)) { | 787 if (!request_context->job_factory()->IsHandledURL(url)) { |
788 DVLOG(1) << "Download request for unsupported protocol: " | 788 DVLOG(1) << "Download request for unsupported protocol: " |
789 << url.possibly_invalid_spec(); | 789 << url.possibly_invalid_spec(); |
790 return DOWNLOAD_INTERRUPT_REASON_NETWORK_INVALID_REQUEST; | 790 return DOWNLOAD_INTERRUPT_REASON_NETWORK_INVALID_REQUEST; |
791 } | 791 } |
792 | 792 |
793 ResourceRequestInfoImpl* extra_info = | 793 ResourceRequestInfoImpl* extra_info = |
794 CreateRequestInfo(child_id, render_view_route_id, | 794 CreateRequestInfo(render_process_id, render_view_route_id, |
795 render_frame_route_id, true, context); | 795 render_frame_route_id, true, context); |
796 extra_info->set_do_not_prompt_for_login(do_not_prompt_for_login); | 796 extra_info->set_do_not_prompt_for_login(do_not_prompt_for_login); |
797 extra_info->AssociateWithRequest(request.get()); // Request takes ownership. | 797 extra_info->AssociateWithRequest(request.get()); // Request takes ownership. |
798 | 798 |
799 if (request->url().SchemeIs(url::kBlobScheme) && | 799 if (request->url().SchemeIs(url::kBlobScheme) && |
800 !storage::BlobProtocolHandler::GetRequestBlobDataHandle(request.get())) { | 800 !storage::BlobProtocolHandler::GetRequestBlobDataHandle(request.get())) { |
801 ChromeBlobStorageContext* blob_context = | 801 ChromeBlobStorageContext* blob_context = |
802 GetChromeBlobStorageContextForResourceContext(context); | 802 GetChromeBlobStorageContextForResourceContext(context); |
803 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( | 803 storage::BlobProtocolHandler::SetRequestedBlobDataHandle( |
804 request.get(), | 804 request.get(), |
(...skipping 1885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2690 ssl.cert_id = GetCertStore()->StoreCert(ssl_info.cert.get(), child_id); | 2690 ssl.cert_id = GetCertStore()->StoreCert(ssl_info.cert.get(), child_id); |
2691 response->head.security_info = SerializeSecurityInfo(ssl); | 2691 response->head.security_info = SerializeSecurityInfo(ssl); |
2692 } | 2692 } |
2693 | 2693 |
2694 CertStore* ResourceDispatcherHostImpl::GetCertStore() { | 2694 CertStore* ResourceDispatcherHostImpl::GetCertStore() { |
2695 return cert_store_for_testing_ ? cert_store_for_testing_ | 2695 return cert_store_for_testing_ ? cert_store_for_testing_ |
2696 : CertStore::GetInstance(); | 2696 : CertStore::GetInstance(); |
2697 } | 2697 } |
2698 | 2698 |
2699 } // namespace content | 2699 } // namespace content |
OLD | NEW |