| 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 <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 #include "net/cookies/cookie_monster.h" | 79 #include "net/cookies/cookie_monster.h" |
| 80 #include "net/http/http_cache.h" | 80 #include "net/http/http_cache.h" |
| 81 #include "net/http/http_response_headers.h" | 81 #include "net/http/http_response_headers.h" |
| 82 #include "net/http/http_response_info.h" | 82 #include "net/http/http_response_info.h" |
| 83 #include "net/http/http_transaction_factory.h" | 83 #include "net/http/http_transaction_factory.h" |
| 84 #include "net/ssl/ssl_cert_request_info.h" | 84 #include "net/ssl/ssl_cert_request_info.h" |
| 85 #include "net/url_request/url_request.h" | 85 #include "net/url_request/url_request.h" |
| 86 #include "net/url_request/url_request_context.h" | 86 #include "net/url_request/url_request_context.h" |
| 87 #include "net/url_request/url_request_job_factory.h" | 87 #include "net/url_request/url_request_job_factory.h" |
| 88 #include "webkit/browser/appcache/appcache_interceptor.h" | 88 #include "webkit/browser/appcache/appcache_interceptor.h" |
| 89 #include "webkit/browser/blob/blob_storage_controller.h" | 89 #include "webkit/common/blob/blob_data.h" |
| 90 #include "webkit/browser/blob/blob_data_handle.h" |
| 91 #include "webkit/browser/blob/blob_storage_context.h" |
| 92 #include "webkit/browser/blob/blob_url_request_job_factory.h" |
| 90 #include "webkit/browser/fileapi/file_permission_policy.h" | 93 #include "webkit/browser/fileapi/file_permission_policy.h" |
| 91 #include "webkit/browser/fileapi/file_system_context.h" | 94 #include "webkit/browser/fileapi/file_system_context.h" |
| 92 #include "webkit/common/appcache/appcache_interfaces.h" | 95 #include "webkit/common/appcache/appcache_interfaces.h" |
| 93 #include "webkit/common/blob/shareable_file_reference.h" | 96 #include "webkit/common/blob/shareable_file_reference.h" |
| 94 #include "webkit/common/resource_request_body.h" | 97 #include "webkit/common/resource_request_body.h" |
| 95 | 98 |
| 96 using base::Time; | 99 using base::Time; |
| 97 using base::TimeDelta; | 100 using base::TimeDelta; |
| 98 using base::TimeTicks; | 101 using base::TimeTicks; |
| 99 using webkit_blob::ShareableFileReference; | 102 using webkit_blob::ShareableFileReference; |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 request_data.request_body->elements(); | 209 request_data.request_body->elements(); |
| 207 std::vector<ResourceRequestBody::Element>::const_iterator iter; | 210 std::vector<ResourceRequestBody::Element>::const_iterator iter; |
| 208 for (iter = uploads->begin(); iter != uploads->end(); ++iter) { | 211 for (iter = uploads->begin(); iter != uploads->end(); ++iter) { |
| 209 if (iter->type() == ResourceRequestBody::Element::TYPE_FILE && | 212 if (iter->type() == ResourceRequestBody::Element::TYPE_FILE && |
| 210 !policy->CanReadFile(child_id, iter->path())) { | 213 !policy->CanReadFile(child_id, iter->path())) { |
| 211 NOTREACHED() << "Denied unauthorized upload of " | 214 NOTREACHED() << "Denied unauthorized upload of " |
| 212 << iter->path().value(); | 215 << iter->path().value(); |
| 213 return false; | 216 return false; |
| 214 } | 217 } |
| 215 if (iter->type() == ResourceRequestBody::Element::TYPE_FILE_FILESYSTEM) { | 218 if (iter->type() == ResourceRequestBody::Element::TYPE_FILE_FILESYSTEM) { |
| 216 fileapi::FileSystemURL url = file_system_context->CrackURL(iter->url()); | 219 fileapi::FileSystemURL url = |
| 220 file_system_context->CrackURL(iter->filesystem_url()); |
| 217 if (!policy->HasPermissionsForFileSystemFile( | 221 if (!policy->HasPermissionsForFileSystemFile( |
| 218 child_id, url, fileapi::kReadFilePermissions)) { | 222 child_id, url, fileapi::kReadFilePermissions)) { |
| 219 NOTREACHED() << "Denied unauthorized upload of " | 223 NOTREACHED() << "Denied unauthorized upload of " |
| 220 << iter->url().spec(); | 224 << iter->filesystem_url().spec(); |
| 221 return false; | 225 return false; |
| 222 } | 226 } |
| 223 } | 227 } |
| 224 } | 228 } |
| 225 } | 229 } |
| 226 | 230 |
| 227 return true; | 231 return true; |
| 228 } | 232 } |
| 229 | 233 |
| 230 void RemoveDownloadFileFromChildSecurityPolicy(int child_id, | 234 void RemoveDownloadFileFromChildSecurityPolicy(int child_id, |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 if (!request_context->job_factory()->IsHandledURL(url)) { | 507 if (!request_context->job_factory()->IsHandledURL(url)) { |
| 504 VLOG(1) << "Download request for unsupported protocol: " | 508 VLOG(1) << "Download request for unsupported protocol: " |
| 505 << url.possibly_invalid_spec(); | 509 << url.possibly_invalid_spec(); |
| 506 return CallbackAndReturn(started_callback, net::ERR_ACCESS_DENIED); | 510 return CallbackAndReturn(started_callback, net::ERR_ACCESS_DENIED); |
| 507 } | 511 } |
| 508 | 512 |
| 509 ResourceRequestInfoImpl* extra_info = | 513 ResourceRequestInfoImpl* extra_info = |
| 510 CreateRequestInfo(child_id, route_id, true, context); | 514 CreateRequestInfo(child_id, route_id, true, context); |
| 511 extra_info->AssociateWithRequest(request.get()); // Request takes ownership. | 515 extra_info->AssociateWithRequest(request.get()); // Request takes ownership. |
| 512 | 516 |
| 517 if (request->url().SchemeIs(chrome::kBlobScheme)) { |
| 518 ChromeBlobStorageContext* blob_context = |
| 519 GetChromeBlobStorageContextForResourceContext(context); |
| 520 webkit_blob::BlobProtocolHandler::SetRequestedBlobDataHandle( |
| 521 request.get(), |
| 522 blob_context->context()->GetBlobDataFromPublicURL(request->url())); |
| 523 } |
| 524 |
| 513 // From this point forward, the |DownloadResourceHandler| is responsible for | 525 // From this point forward, the |DownloadResourceHandler| is responsible for |
| 514 // |started_callback|. | 526 // |started_callback|. |
| 515 scoped_ptr<ResourceHandler> handler( | 527 scoped_ptr<ResourceHandler> handler( |
| 516 CreateResourceHandlerForDownload(request.get(), is_content_initiated, | 528 CreateResourceHandlerForDownload(request.get(), is_content_initiated, |
| 517 true, download_id, save_info.Pass(), | 529 true, download_id, save_info.Pass(), |
| 518 started_callback)); | 530 started_callback)); |
| 519 | 531 |
| 520 BeginRequestInternal(request.Pass(), handler.Pass()); | 532 BeginRequestInternal(request.Pass(), handler.Pass()); |
| 521 | 533 |
| 522 return net::OK; | 534 return net::OK; |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 // TODO(darin): Do we really need all of these URLRequest setters in the | 993 // TODO(darin): Do we really need all of these URLRequest setters in the |
| 982 // transferred navigation case? | 994 // transferred navigation case? |
| 983 | 995 |
| 984 request->set_load_flags(load_flags); | 996 request->set_load_flags(load_flags); |
| 985 request->SetPriority(request_data.priority); | 997 request->SetPriority(request_data.priority); |
| 986 | 998 |
| 987 // Resolve elements from request_body and prepare upload data. | 999 // Resolve elements from request_body and prepare upload data. |
| 988 if (request_data.request_body.get()) { | 1000 if (request_data.request_body.get()) { |
| 989 request->set_upload(UploadDataStreamBuilder::Build( | 1001 request->set_upload(UploadDataStreamBuilder::Build( |
| 990 request_data.request_body.get(), | 1002 request_data.request_body.get(), |
| 991 filter_->blob_storage_context()->controller(), | 1003 filter_->blob_storage_context()->context(), |
| 992 filter_->file_system_context(), | 1004 filter_->file_system_context(), |
| 993 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE) | 1005 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE) |
| 994 .get())); | 1006 .get())); |
| 995 } | 1007 } |
| 996 | 1008 |
| 997 bool allow_download = request_data.allow_download && | 1009 bool allow_download = request_data.allow_download && |
| 998 ResourceType::IsFrame(request_data.resource_type); | 1010 ResourceType::IsFrame(request_data.resource_type); |
| 999 | 1011 |
| 1000 // Make extra info and read footer (contains request ID). | 1012 // Make extra info and read footer (contains request ID). |
| 1001 ResourceRequestInfoImpl* extra_info = | 1013 ResourceRequestInfoImpl* extra_info = |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1016 allow_download, | 1028 allow_download, |
| 1017 request_data.has_user_gesture, | 1029 request_data.has_user_gesture, |
| 1018 request_data.referrer_policy, | 1030 request_data.referrer_policy, |
| 1019 resource_context, | 1031 resource_context, |
| 1020 !is_sync_load); | 1032 !is_sync_load); |
| 1021 extra_info->AssociateWithRequest(request); // Request takes ownership. | 1033 extra_info->AssociateWithRequest(request); // Request takes ownership. |
| 1022 | 1034 |
| 1023 if (request->url().SchemeIs(chrome::kBlobScheme)) { | 1035 if (request->url().SchemeIs(chrome::kBlobScheme)) { |
| 1024 // Hang on to a reference to ensure the blob is not released prior | 1036 // Hang on to a reference to ensure the blob is not released prior |
| 1025 // to the job being started. | 1037 // to the job being started. |
| 1026 extra_info->set_requested_blob_data( | 1038 webkit_blob::BlobProtocolHandler::SetRequestedBlobDataHandle( |
| 1027 filter_->blob_storage_context()->controller()-> | 1039 request, |
| 1028 GetBlobDataFromUrl(request->url())); | 1040 filter_->blob_storage_context()->context()-> |
| 1041 GetBlobDataFromPublicURL(request->url())); |
| 1029 } | 1042 } |
| 1030 | 1043 |
| 1031 // Have the appcache associate its extra info with the request. | 1044 // Have the appcache associate its extra info with the request. |
| 1032 appcache::AppCacheInterceptor::SetExtraRequestInfo( | 1045 appcache::AppCacheInterceptor::SetExtraRequestInfo( |
| 1033 request, filter_->appcache_service(), child_id, | 1046 request, filter_->appcache_service(), child_id, |
| 1034 request_data.appcache_host_id, request_data.resource_type); | 1047 request_data.appcache_host_id, request_data.resource_type); |
| 1035 | 1048 |
| 1036 // Construct the IPC resource handler. | 1049 // Construct the IPC resource handler. |
| 1037 scoped_ptr<ResourceHandler> handler; | 1050 scoped_ptr<ResourceHandler> handler; |
| 1038 if (sync_result) { | 1051 if (sync_result) { |
| (...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1876 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) | 1889 if ((load_flags & net::LOAD_REPORT_RAW_HEADERS) |
| 1877 && !policy->CanReadRawCookies(child_id)) { | 1890 && !policy->CanReadRawCookies(child_id)) { |
| 1878 VLOG(1) << "Denied unauthorized request for raw headers"; | 1891 VLOG(1) << "Denied unauthorized request for raw headers"; |
| 1879 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; | 1892 load_flags &= ~net::LOAD_REPORT_RAW_HEADERS; |
| 1880 } | 1893 } |
| 1881 | 1894 |
| 1882 return load_flags; | 1895 return load_flags; |
| 1883 } | 1896 } |
| 1884 | 1897 |
| 1885 } // namespace content | 1898 } // namespace content |
| OLD | NEW |