| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/link_header_support.h" | 5 #include "content/browser/service_worker/link_header_support.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/string_split.h" | 8 #include "base/strings/string_split.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "components/link_header_util/link_header_util.h" | 10 #include "components/link_header_util/link_header_util.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 !TrialTokenValidator::RequestEnablesFeature(request, "ForeignFetch")) { | 45 !TrialTokenValidator::RequestEnablesFeature(request, "ForeignFetch")) { |
| 46 // TODO(mek): Log attempt to use without having correct token? | 46 // TODO(mek): Log attempt to use without having correct token? |
| 47 return; | 47 return; |
| 48 } | 48 } |
| 49 | 49 |
| 50 if (ContainsKey(params, "anchor")) | 50 if (ContainsKey(params, "anchor")) |
| 51 return; | 51 return; |
| 52 | 52 |
| 53 const ResourceRequestInfoImpl* request_info = | 53 const ResourceRequestInfoImpl* request_info = |
| 54 ResourceRequestInfoImpl::ForRequest(request); | 54 ResourceRequestInfoImpl::ForRequest(request); |
| 55 ResourceMessageFilter* filter = request_info->filter(); | |
| 56 ServiceWorkerContext* service_worker_context = | 55 ServiceWorkerContext* service_worker_context = |
| 57 filter ? filter->service_worker_context() | 56 service_worker_context_for_testing |
| 58 : service_worker_context_for_testing; | 57 ? service_worker_context_for_testing |
| 59 if (IsBrowserSideNavigationEnabled() && | 58 : request_info->requester_info().service_worker_context(); |
| 60 ServiceWorkerUtils::IsMainResourceType(request_info->GetResourceType()) && | |
| 61 !service_worker_context) { | |
| 62 service_worker_context = request_info->service_worker_context(); | |
| 63 } | |
| 64 | 59 |
| 65 if (!service_worker_context) | 60 if (!service_worker_context) |
| 66 return; | 61 return; |
| 67 | 62 |
| 68 if (ServiceWorkerUtils::IsMainResourceType(request_info->GetResourceType())) { | 63 if (ServiceWorkerUtils::IsMainResourceType(request_info->GetResourceType())) { |
| 69 // In case of navigations, make sure the navigation will actually result in | 64 // In case of navigations, make sure the navigation will actually result in |
| 70 // a secure context. | 65 // a secure context. |
| 71 ServiceWorkerProviderHost* provider_host = | 66 ServiceWorkerProviderHost* provider_host = |
| 72 ServiceWorkerRequestHandler::GetProviderHost(request); | 67 ServiceWorkerRequestHandler::GetProviderHost(request); |
| 73 if (!provider_host || !provider_host->IsContextSecureForServiceWorker()) | 68 if (!provider_host || !provider_host->IsContextSecureForServiceWorker()) |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 const net::URLRequest* request, | 158 const net::URLRequest* request, |
| 164 const std::string& link_header, | 159 const std::string& link_header, |
| 165 ServiceWorkerContextWrapper* service_worker_context_for_testing) { | 160 ServiceWorkerContextWrapper* service_worker_context_for_testing) { |
| 166 for (const auto& value : link_header_util::SplitLinkHeader(link_header)) { | 161 for (const auto& value : link_header_util::SplitLinkHeader(link_header)) { |
| 167 ProcessLinkHeaderValueForRequest(request, value.first, value.second, | 162 ProcessLinkHeaderValueForRequest(request, value.first, value.second, |
| 168 service_worker_context_for_testing); | 163 service_worker_context_for_testing); |
| 169 } | 164 } |
| 170 } | 165 } |
| 171 | 166 |
| 172 } // namespace content | 167 } // namespace content |
| OLD | NEW |