| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/renderer_host/resource_dispatcher_host.h" | 7 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 RendererSecurityPolicy* policy = RendererSecurityPolicy::GetInstance(); | 109 RendererSecurityPolicy* policy = RendererSecurityPolicy::GetInstance(); |
| 110 | 110 |
| 111 // Check if the renderer is permitted to request the requested URL. | 111 // Check if the renderer is permitted to request the requested URL. |
| 112 if (!policy->CanRequestURL(process_id, request_data.url)) { | 112 if (!policy->CanRequestURL(process_id, request_data.url)) { |
| 113 LOG(INFO) << "Denied unauthorized request for " << | 113 LOG(INFO) << "Denied unauthorized request for " << |
| 114 request_data.url.possibly_invalid_spec(); | 114 request_data.url.possibly_invalid_spec(); |
| 115 return false; | 115 return false; |
| 116 } | 116 } |
| 117 | 117 |
| 118 // Check if the renderer is permitted to upload the requested files. | 118 // Check if the renderer is permitted to upload the requested files. |
| 119 const std::vector<net::UploadData::Element>& uploads = | 119 if (request_data.upload_data) { |
| 120 request_data.upload_content; | 120 const std::vector<net::UploadData::Element>& uploads = |
| 121 std::vector<net::UploadData::Element>::const_iterator iter; | 121 request_data.upload_data->elements(); |
| 122 for (iter = uploads.begin(); iter != uploads.end(); ++iter) { | 122 std::vector<net::UploadData::Element>::const_iterator iter; |
| 123 if (iter->type() == net::UploadData::TYPE_FILE && | 123 for (iter = uploads.begin(); iter != uploads.end(); ++iter) { |
| 124 !policy->CanUploadFile(process_id, iter->file_path())) { | 124 if (iter->type() == net::UploadData::TYPE_FILE && |
| 125 NOTREACHED() << "Denied unauthorized upload of " << iter->file_path(); | 125 !policy->CanUploadFile(process_id, iter->file_path())) { |
| 126 return false; | 126 NOTREACHED() << "Denied unauthorized upload of " << iter->file_path(); |
| 127 return false; |
| 128 } |
| 127 } | 129 } |
| 128 } | 130 } |
| 129 | 131 |
| 130 return true; | 132 return true; |
| 131 } | 133 } |
| 132 | 134 |
| 133 } // namespace | 135 } // namespace |
| 134 | 136 |
| 135 ResourceDispatcherHost::ResourceDispatcherHost(MessageLoop* io_loop) | 137 ResourceDispatcherHost::ResourceDispatcherHost(MessageLoop* io_loop) |
| 136 : ui_loop_(MessageLoop::current()), | 138 : ui_loop_(MessageLoop::current()), |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 323 request->set_method(request_data.method); | 325 request->set_method(request_data.method); |
| 324 request->set_policy_url(request_data.policy_url); | 326 request->set_policy_url(request_data.policy_url); |
| 325 request->set_referrer(request_data.referrer.spec()); | 327 request->set_referrer(request_data.referrer.spec()); |
| 326 request->SetExtraRequestHeaders(request_data.headers); | 328 request->SetExtraRequestHeaders(request_data.headers); |
| 327 request->set_load_flags(request_data.load_flags); | 329 request->set_load_flags(request_data.load_flags); |
| 328 request->set_context(context); | 330 request->set_context(context); |
| 329 request->set_origin_pid(request_data.origin_pid); | 331 request->set_origin_pid(request_data.origin_pid); |
| 330 | 332 |
| 331 // Set upload data. | 333 // Set upload data. |
| 332 uint64 upload_size = 0; | 334 uint64 upload_size = 0; |
| 333 if (!request_data.upload_content.empty()) { | 335 if (request_data.upload_data) { |
| 334 scoped_refptr<net::UploadData> upload = new net::UploadData(); | 336 request->set_upload(request_data.upload_data); |
| 335 upload->set_elements(request_data.upload_content); // Deep copy. | 337 upload_size = request_data.upload_data->GetContentLength(); |
| 336 request->set_upload(upload); | |
| 337 upload_size = upload->GetContentLength(); | |
| 338 } | 338 } |
| 339 | 339 |
| 340 // Install a CrossSiteResourceHandler if this request is coming from a | 340 // Install a CrossSiteResourceHandler if this request is coming from a |
| 341 // RenderViewHost with a pending cross-site request. We only check this for | 341 // RenderViewHost with a pending cross-site request. We only check this for |
| 342 // MAIN_FRAME requests. | 342 // MAIN_FRAME requests. |
| 343 if (request_data.resource_type == ResourceType::MAIN_FRAME && | 343 if (request_data.resource_type == ResourceType::MAIN_FRAME && |
| 344 process_type == ChildProcessInfo::RENDER_PROCESS && | 344 process_type == ChildProcessInfo::RENDER_PROCESS && |
| 345 Singleton<CrossSiteRequestManager>::get()-> | 345 Singleton<CrossSiteRequestManager>::get()-> |
| 346 HasPendingCrossSiteRequest(process_id, route_id)) { | 346 HasPendingCrossSiteRequest(process_id, route_id)) { |
| 347 // Wrap the event handler to be sure the current page's onunload handler | 347 // Wrap the event handler to be sure the current page's onunload handler |
| (...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1526 case ViewHostMsg_UploadProgress_ACK::ID: | 1526 case ViewHostMsg_UploadProgress_ACK::ID: |
| 1527 case ViewHostMsg_SyncLoad::ID: | 1527 case ViewHostMsg_SyncLoad::ID: |
| 1528 return true; | 1528 return true; |
| 1529 | 1529 |
| 1530 default: | 1530 default: |
| 1531 break; | 1531 break; |
| 1532 } | 1532 } |
| 1533 | 1533 |
| 1534 return false; | 1534 return false; |
| 1535 } | 1535 } |
| OLD | NEW |