| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "content/browser/service_worker/foreign_fetch_request_handler.h" | 5 #include "content/browser/service_worker/foreign_fetch_request_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 10 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 storage::BlobStorageContext* blob_storage_context, | 51 storage::BlobStorageContext* blob_storage_context, |
| 52 int process_id, | 52 int process_id, |
| 53 int provider_id, | 53 int provider_id, |
| 54 bool skip_service_worker, | 54 bool skip_service_worker, |
| 55 FetchRequestMode request_mode, | 55 FetchRequestMode request_mode, |
| 56 FetchCredentialsMode credentials_mode, | 56 FetchCredentialsMode credentials_mode, |
| 57 FetchRedirectMode redirect_mode, | 57 FetchRedirectMode redirect_mode, |
| 58 ResourceType resource_type, | 58 ResourceType resource_type, |
| 59 RequestContextType request_context_type, | 59 RequestContextType request_context_type, |
| 60 RequestContextFrameType frame_type, | 60 RequestContextFrameType frame_type, |
| 61 scoped_refptr<ResourceRequestBody> body) { | 61 scoped_refptr<ResourceRequestBody> body, |
| 62 bool initiated_in_secure_context) { |
| 62 if (!context_wrapper) { | 63 if (!context_wrapper) { |
| 63 return; | 64 return; |
| 64 } | 65 } |
| 65 | 66 |
| 67 if (!initiated_in_secure_context) |
| 68 return; |
| 69 |
| 66 if (!context_wrapper->OriginHasForeignFetchRegistrations( | 70 if (!context_wrapper->OriginHasForeignFetchRegistrations( |
| 67 request->url().GetOrigin())) { | 71 request->url().GetOrigin())) { |
| 68 return; | 72 return; |
| 69 } | 73 } |
| 70 | 74 |
| 71 if (request->initiator().IsSameOriginWith(url::Origin(request->url()))) | 75 if (request->initiator().IsSameOriginWith(url::Origin(request->url()))) |
| 72 return; | 76 return; |
| 77 |
| 73 if (ServiceWorkerUtils::IsMainResourceType(resource_type)) | 78 if (ServiceWorkerUtils::IsMainResourceType(resource_type)) |
| 74 return; | 79 return; |
| 75 | 80 |
| 76 // Any more precise checks to see if the request should be intercepted are | 81 // Any more precise checks to see if the request should be intercepted are |
| 77 // asynchronous, so just create our handler in all cases. | 82 // asynchronous, so just create our handler in all cases. |
| 78 std::unique_ptr<ForeignFetchRequestHandler> handler( | 83 std::unique_ptr<ForeignFetchRequestHandler> handler( |
| 79 new ForeignFetchRequestHandler( | 84 new ForeignFetchRequestHandler( |
| 80 context_wrapper, blob_storage_context->AsWeakPtr(), request_mode, | 85 context_wrapper, blob_storage_context->AsWeakPtr(), request_mode, |
| 81 credentials_mode, redirect_mode, resource_type, request_context_type, | 86 credentials_mode, redirect_mode, resource_type, request_context_type, |
| 82 frame_type, body)); | 87 frame_type, body)); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 } | 226 } |
| 222 return target_worker_.get(); | 227 return target_worker_.get(); |
| 223 } | 228 } |
| 224 | 229 |
| 225 void ForeignFetchRequestHandler::ClearJob() { | 230 void ForeignFetchRequestHandler::ClearJob() { |
| 226 job_.reset(); | 231 job_.reset(); |
| 227 target_worker_ = nullptr; | 232 target_worker_ = nullptr; |
| 228 } | 233 } |
| 229 | 234 |
| 230 } // namespace content | 235 } // namespace content |
| OLD | NEW |