| 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/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 return origin_trial_policy && | 63 return origin_trial_policy && |
| 64 !origin_trial_policy->IsFeatureDisabled("ForeignFetch"); | 64 !origin_trial_policy->IsFeatureDisabled("ForeignFetch"); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void ForeignFetchRequestHandler::InitializeHandler( | 67 void ForeignFetchRequestHandler::InitializeHandler( |
| 68 net::URLRequest* request, | 68 net::URLRequest* request, |
| 69 ServiceWorkerContextWrapper* context_wrapper, | 69 ServiceWorkerContextWrapper* context_wrapper, |
| 70 storage::BlobStorageContext* blob_storage_context, | 70 storage::BlobStorageContext* blob_storage_context, |
| 71 int process_id, | 71 int process_id, |
| 72 int provider_id, | 72 int provider_id, |
| 73 SkipServiceWorker skip_service_worker, | 73 ServiceWorkerMode service_worker_mode, |
| 74 FetchRequestMode request_mode, | 74 FetchRequestMode request_mode, |
| 75 FetchCredentialsMode credentials_mode, | 75 FetchCredentialsMode credentials_mode, |
| 76 FetchRedirectMode redirect_mode, | 76 FetchRedirectMode redirect_mode, |
| 77 ResourceType resource_type, | 77 ResourceType resource_type, |
| 78 RequestContextType request_context_type, | 78 RequestContextType request_context_type, |
| 79 RequestContextFrameType frame_type, | 79 RequestContextFrameType frame_type, |
| 80 scoped_refptr<ResourceRequestBodyImpl> body, | 80 scoped_refptr<ResourceRequestBodyImpl> body, |
| 81 bool initiated_in_secure_context) { | 81 bool initiated_in_secure_context) { |
| 82 if (!IsForeignFetchEnabled()) | 82 if (!IsForeignFetchEnabled()) |
| 83 return; | 83 return; |
| 84 | 84 |
| 85 if (!context_wrapper || !context_wrapper->context() || | 85 if (!context_wrapper || !context_wrapper->context() || |
| 86 provider_id == kInvalidServiceWorkerProviderId) { | 86 provider_id == kInvalidServiceWorkerProviderId) { |
| 87 return; | 87 return; |
| 88 } | 88 } |
| 89 | 89 |
| 90 if (skip_service_worker == SkipServiceWorker::ALL) | 90 if (service_worker_mode == ServiceWorkerMode::NONE) |
| 91 return; | 91 return; |
| 92 | 92 |
| 93 if (!initiated_in_secure_context) | 93 if (!initiated_in_secure_context) |
| 94 return; | 94 return; |
| 95 | 95 |
| 96 // ServiceWorkerUtils::IsMainResource doesn't consider all worker types to | 96 // ServiceWorkerUtils::IsMainResource doesn't consider all worker types to |
| 97 // be main resources. This code shouldn't handle any main resource requests | 97 // be main resources. This code shouldn't handle any main resource requests |
| 98 // though, so explicitly exclude the extra worker types. | 98 // though, so explicitly exclude the extra worker types. |
| 99 if (ServiceWorkerUtils::IsMainResourceType(resource_type) || | 99 if (ServiceWorkerUtils::IsMainResourceType(resource_type) || |
| 100 resource_type == RESOURCE_TYPE_WORKER || | 100 resource_type == RESOURCE_TYPE_WORKER || |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 // The worker entry in the database was written by old version Chrome (< M56) | 303 // The worker entry in the database was written by old version Chrome (< M56) |
| 304 // and the main script was not loaded yet. In this case, we can't check the | 304 // and the main script was not loaded yet. In this case, we can't check the |
| 305 // origin trial token. | 305 // origin trial token. |
| 306 if (!active_version->origin_trial_tokens()) | 306 if (!active_version->origin_trial_tokens()) |
| 307 return true; | 307 return true; |
| 308 const auto& token_map = *active_version->origin_trial_tokens(); | 308 const auto& token_map = *active_version->origin_trial_tokens(); |
| 309 return base::ContainsKey(token_map, "ForeignFetch"); | 309 return base::ContainsKey(token_map, "ForeignFetch"); |
| 310 } | 310 } |
| 311 | 311 |
| 312 } // namespace content | 312 } // namespace content |
| OLD | NEW |