| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/service_worker_request_handler.h" | 5 #include "content/browser/service_worker/service_worker_request_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "content/browser/loader/url_loader_request_handler.h" | 12 #include "content/browser/loader/url_loader_request_handler.h" |
| 13 #include "content/browser/service_worker/service_worker_context_core.h" | 13 #include "content/browser/service_worker/service_worker_context_core.h" |
| 14 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 14 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 15 #include "content/browser/service_worker/service_worker_navigation_handle_core.h
" | 15 #include "content/browser/service_worker/service_worker_navigation_handle_core.h
" |
| 16 #include "content/browser/service_worker/service_worker_provider_host.h" | 16 #include "content/browser/service_worker/service_worker_provider_host.h" |
| 17 #include "content/browser/service_worker/service_worker_registration.h" | 17 #include "content/browser/service_worker/service_worker_registration.h" |
| 18 #include "content/browser/service_worker/service_worker_url_request_job.h" | 18 #include "content/browser/service_worker/service_worker_url_request_job.h" |
| 19 #include "content/common/resource_request_body_impl.h" | |
| 20 #include "content/common/service_worker/service_worker_types.h" | 19 #include "content/common/service_worker/service_worker_types.h" |
| 21 #include "content/common/service_worker/service_worker_utils.h" | 20 #include "content/common/service_worker/service_worker_utils.h" |
| 22 #include "content/public/browser/resource_context.h" | 21 #include "content/public/browser/resource_context.h" |
| 23 #include "content/public/common/browser_side_navigation_policy.h" | 22 #include "content/public/common/browser_side_navigation_policy.h" |
| 24 #include "content/public/common/child_process_host.h" | 23 #include "content/public/common/child_process_host.h" |
| 25 #include "content/public/common/content_switches.h" | 24 #include "content/public/common/content_switches.h" |
| 26 #include "content/public/common/origin_util.h" | 25 #include "content/public/common/origin_util.h" |
| 26 #include "content/public/common/resource_request_body.h" |
| 27 #include "ipc/ipc_message.h" | 27 #include "ipc/ipc_message.h" |
| 28 #include "net/base/url_util.h" | 28 #include "net/base/url_util.h" |
| 29 #include "net/url_request/url_request.h" | 29 #include "net/url_request/url_request.h" |
| 30 #include "net/url_request/url_request_interceptor.h" | 30 #include "net/url_request/url_request_interceptor.h" |
| 31 #include "storage/browser/blob/blob_storage_context.h" | 31 #include "storage/browser/blob/blob_storage_context.h" |
| 32 | 32 |
| 33 namespace content { | 33 namespace content { |
| 34 | 34 |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 63 // PlzNavigate | 63 // PlzNavigate |
| 64 void ServiceWorkerRequestHandler::InitializeForNavigation( | 64 void ServiceWorkerRequestHandler::InitializeForNavigation( |
| 65 net::URLRequest* request, | 65 net::URLRequest* request, |
| 66 ServiceWorkerNavigationHandleCore* navigation_handle_core, | 66 ServiceWorkerNavigationHandleCore* navigation_handle_core, |
| 67 storage::BlobStorageContext* blob_storage_context, | 67 storage::BlobStorageContext* blob_storage_context, |
| 68 bool skip_service_worker, | 68 bool skip_service_worker, |
| 69 ResourceType resource_type, | 69 ResourceType resource_type, |
| 70 RequestContextType request_context_type, | 70 RequestContextType request_context_type, |
| 71 RequestContextFrameType frame_type, | 71 RequestContextFrameType frame_type, |
| 72 bool is_parent_frame_secure, | 72 bool is_parent_frame_secure, |
| 73 scoped_refptr<ResourceRequestBodyImpl> body, | 73 scoped_refptr<ResourceRequestBody> body, |
| 74 const base::Callback<WebContents*(void)>& web_contents_getter) { | 74 const base::Callback<WebContents*(void)>& web_contents_getter) { |
| 75 CHECK(IsBrowserSideNavigationEnabled()); | 75 CHECK(IsBrowserSideNavigationEnabled()); |
| 76 | 76 |
| 77 // Only create a handler when there is a ServiceWorkerNavigationHandlerCore | 77 // Only create a handler when there is a ServiceWorkerNavigationHandlerCore |
| 78 // to take ownership of a pre-created SeviceWorkerProviderHost. | 78 // to take ownership of a pre-created SeviceWorkerProviderHost. |
| 79 if (!navigation_handle_core) | 79 if (!navigation_handle_core) |
| 80 return; | 80 return; |
| 81 | 81 |
| 82 // Create the handler even for insecure HTTP since it's used in the | 82 // Create the handler even for insecure HTTP since it's used in the |
| 83 // case of redirect to HTTPS. | 83 // case of redirect to HTTPS. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 ServiceWorkerRequestHandler::InitializeForNavigationNetworkService( | 120 ServiceWorkerRequestHandler::InitializeForNavigationNetworkService( |
| 121 const ResourceRequest& resource_request, | 121 const ResourceRequest& resource_request, |
| 122 ResourceContext* resource_context, | 122 ResourceContext* resource_context, |
| 123 ServiceWorkerNavigationHandleCore* navigation_handle_core, | 123 ServiceWorkerNavigationHandleCore* navigation_handle_core, |
| 124 storage::BlobStorageContext* blob_storage_context, | 124 storage::BlobStorageContext* blob_storage_context, |
| 125 bool skip_service_worker, | 125 bool skip_service_worker, |
| 126 ResourceType resource_type, | 126 ResourceType resource_type, |
| 127 RequestContextType request_context_type, | 127 RequestContextType request_context_type, |
| 128 RequestContextFrameType frame_type, | 128 RequestContextFrameType frame_type, |
| 129 bool is_parent_frame_secure, | 129 bool is_parent_frame_secure, |
| 130 scoped_refptr<ResourceRequestBodyImpl> body, | 130 scoped_refptr<ResourceRequestBody> body, |
| 131 const base::Callback<WebContents*(void)>& web_contents_getter) { | 131 const base::Callback<WebContents*(void)>& web_contents_getter) { |
| 132 DCHECK(IsBrowserSideNavigationEnabled() && | 132 DCHECK(IsBrowserSideNavigationEnabled() && |
| 133 base::CommandLine::ForCurrentProcess()->HasSwitch( | 133 base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 134 switches::kEnableNetworkService)); | 134 switches::kEnableNetworkService)); |
| 135 DCHECK(navigation_handle_core); | 135 DCHECK(navigation_handle_core); |
| 136 | 136 |
| 137 // Create the handler even for insecure HTTP since it's used in the | 137 // Create the handler even for insecure HTTP since it's used in the |
| 138 // case of redirect to HTTPS. | 138 // case of redirect to HTTPS. |
| 139 if (!resource_request.url.SchemeIsHTTPOrHTTPS() && | 139 if (!resource_request.url.SchemeIsHTTPOrHTTPS() && |
| 140 !OriginCanAccessServiceWorkers(resource_request.url)) { | 140 !OriginCanAccessServiceWorkers(resource_request.url)) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 storage::BlobStorageContext* blob_storage_context, | 175 storage::BlobStorageContext* blob_storage_context, |
| 176 int process_id, | 176 int process_id, |
| 177 int provider_id, | 177 int provider_id, |
| 178 bool skip_service_worker, | 178 bool skip_service_worker, |
| 179 FetchRequestMode request_mode, | 179 FetchRequestMode request_mode, |
| 180 FetchCredentialsMode credentials_mode, | 180 FetchCredentialsMode credentials_mode, |
| 181 FetchRedirectMode redirect_mode, | 181 FetchRedirectMode redirect_mode, |
| 182 ResourceType resource_type, | 182 ResourceType resource_type, |
| 183 RequestContextType request_context_type, | 183 RequestContextType request_context_type, |
| 184 RequestContextFrameType frame_type, | 184 RequestContextFrameType frame_type, |
| 185 scoped_refptr<ResourceRequestBodyImpl> body) { | 185 scoped_refptr<ResourceRequestBody> body) { |
| 186 // Create the handler even for insecure HTTP since it's used in the | 186 // Create the handler even for insecure HTTP since it's used in the |
| 187 // case of redirect to HTTPS. | 187 // case of redirect to HTTPS. |
| 188 if (!request->url().SchemeIsHTTPOrHTTPS() && | 188 if (!request->url().SchemeIsHTTPOrHTTPS() && |
| 189 !OriginCanAccessServiceWorkers(request->url())) { | 189 !OriginCanAccessServiceWorkers(request->url())) { |
| 190 return; | 190 return; |
| 191 } | 191 } |
| 192 | 192 |
| 193 if (!context_wrapper || !context_wrapper->context() || | 193 if (!context_wrapper || !context_wrapper->context() || |
| 194 provider_id == kInvalidServiceWorkerProviderId) { | 194 provider_id == kInvalidServiceWorkerProviderId) { |
| 195 return; | 195 return; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 ResourceType resource_type) | 295 ResourceType resource_type) |
| 296 : context_(context), | 296 : context_(context), |
| 297 provider_host_(provider_host), | 297 provider_host_(provider_host), |
| 298 blob_storage_context_(blob_storage_context), | 298 blob_storage_context_(blob_storage_context), |
| 299 resource_type_(resource_type), | 299 resource_type_(resource_type), |
| 300 old_process_id_(0), | 300 old_process_id_(0), |
| 301 old_provider_id_(kInvalidServiceWorkerProviderId) { | 301 old_provider_id_(kInvalidServiceWorkerProviderId) { |
| 302 } | 302 } |
| 303 | 303 |
| 304 } // namespace content | 304 } // namespace content |
| OLD | NEW |