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