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 2645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2656 GURL origin(origin_string); | 2656 GURL origin(origin_string); |
2657 if (!policy->CanSetAsOriginHeader(child_id, origin)) { | 2657 if (!policy->CanSetAsOriginHeader(child_id, origin)) { |
2658 VLOG(1) << "Killed renderer for illegal origin: " << origin_string; | 2658 VLOG(1) << "Killed renderer for illegal origin: " << origin_string; |
2659 bad_message::ReceivedBadMessage(requester_info->filter(), | 2659 bad_message::ReceivedBadMessage(requester_info->filter(), |
2660 bad_message::RDH_ILLEGAL_ORIGIN); | 2660 bad_message::RDH_ILLEGAL_ORIGIN); |
2661 return false; | 2661 return false; |
2662 } | 2662 } |
2663 } | 2663 } |
2664 | 2664 |
2665 // Check if the renderer is permitted to upload the requested files. | 2665 // Check if the renderer is permitted to upload the requested files. |
2666 if (request_data.request_body.get()) { | 2666 if (!policy->CanReadRequestBody(child_id, |
2667 const std::vector<ResourceRequestBodyImpl::Element>* uploads = | 2667 requester_info->file_system_context(), |
2668 request_data.request_body->elements(); | 2668 request_data.request_body)) { |
2669 std::vector<ResourceRequestBodyImpl::Element>::const_iterator iter; | 2669 NOTREACHED() << "Denied unauthorized upload"; |
2670 for (iter = uploads->begin(); iter != uploads->end(); ++iter) { | 2670 return false; |
2671 if (iter->type() == ResourceRequestBodyImpl::Element::TYPE_FILE && | |
2672 !policy->CanReadFile(child_id, iter->path())) { | |
2673 NOTREACHED() << "Denied unauthorized upload of " | |
2674 << iter->path().value(); | |
2675 return false; | |
2676 } | |
2677 if (iter->type() == | |
2678 ResourceRequestBodyImpl::Element::TYPE_FILE_FILESYSTEM) { | |
2679 storage::FileSystemURL url = | |
2680 requester_info->file_system_context()->CrackURL( | |
2681 iter->filesystem_url()); | |
2682 if (!policy->CanReadFileSystemFile(child_id, url)) { | |
2683 NOTREACHED() << "Denied unauthorized upload of " | |
2684 << iter->filesystem_url().spec(); | |
2685 return false; | |
2686 } | |
2687 } | |
2688 } | |
2689 } | 2671 } |
| 2672 |
2690 return true; | 2673 return true; |
2691 } | 2674 } |
2692 | 2675 |
2693 std::unique_ptr<ResourceHandler> | 2676 std::unique_ptr<ResourceHandler> |
2694 ResourceDispatcherHostImpl::HandleDownloadStarted( | 2677 ResourceDispatcherHostImpl::HandleDownloadStarted( |
2695 net::URLRequest* request, | 2678 net::URLRequest* request, |
2696 std::unique_ptr<ResourceHandler> handler, | 2679 std::unique_ptr<ResourceHandler> handler, |
2697 bool is_content_initiated, | 2680 bool is_content_initiated, |
2698 bool must_download, | 2681 bool must_download, |
2699 bool is_new_request) { | 2682 bool is_new_request) { |
2700 if (delegate()) { | 2683 if (delegate()) { |
2701 const ResourceRequestInfoImpl* request_info( | 2684 const ResourceRequestInfoImpl* request_info( |
2702 ResourceRequestInfoImpl::ForRequest(request)); | 2685 ResourceRequestInfoImpl::ForRequest(request)); |
2703 std::vector<std::unique_ptr<ResourceThrottle>> throttles; | 2686 std::vector<std::unique_ptr<ResourceThrottle>> throttles; |
2704 delegate()->DownloadStarting(request, request_info->GetContext(), | 2687 delegate()->DownloadStarting(request, request_info->GetContext(), |
2705 is_content_initiated, true, is_new_request, | 2688 is_content_initiated, true, is_new_request, |
2706 &throttles); | 2689 &throttles); |
2707 if (!throttles.empty()) { | 2690 if (!throttles.empty()) { |
2708 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, | 2691 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, |
2709 std::move(throttles))); | 2692 std::move(throttles))); |
2710 } | 2693 } |
2711 } | 2694 } |
2712 return handler; | 2695 return handler; |
2713 } | 2696 } |
2714 | 2697 |
2715 } // namespace content | 2698 } // namespace content |
OLD | NEW |