| 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" |
| 11 #include "content/browser/loader/resource_message_filter.h" | 11 #include "content/browser/loader/resource_message_filter.h" |
| 12 #include "content/browser/loader/resource_request_info_impl.h" | 12 #include "content/browser/loader/resource_request_info_impl.h" |
| 13 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 13 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 14 #include "content/browser/service_worker/service_worker_request_handler.h" | 14 #include "content/browser/service_worker/service_worker_request_handler.h" |
| 15 #include "content/common/origin_trials/trial_token_validator.h" | 15 #include "content/common/origin_trials/trial_token_validator.h" |
| 16 #include "content/common/service_worker/service_worker_utils.h" | 16 #include "content/common/service_worker/service_worker_utils.h" |
| 17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/content_browser_client.h" | 18 #include "content/public/browser/content_browser_client.h" |
| 19 #include "content/public/common/browser_side_navigation_policy.h" |
| 19 #include "content/public/common/content_client.h" | 20 #include "content/public/common/content_client.h" |
| 20 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
| 21 #include "content/public/common/origin_util.h" | 22 #include "content/public/common/origin_util.h" |
| 22 #include "net/http/http_util.h" | 23 #include "net/http/http_util.h" |
| 23 #include "net/url_request/url_request.h" | 24 #include "net/url_request/url_request.h" |
| 24 | 25 |
| 25 namespace content { | 26 namespace content { |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 48 | 49 |
| 49 if (ContainsKey(params, "anchor")) | 50 if (ContainsKey(params, "anchor")) |
| 50 return; | 51 return; |
| 51 | 52 |
| 52 const ResourceRequestInfoImpl* request_info = | 53 const ResourceRequestInfoImpl* request_info = |
| 53 ResourceRequestInfoImpl::ForRequest(request); | 54 ResourceRequestInfoImpl::ForRequest(request); |
| 54 ResourceMessageFilter* filter = request_info->filter(); | 55 ResourceMessageFilter* filter = request_info->filter(); |
| 55 ServiceWorkerContext* service_worker_context = | 56 ServiceWorkerContext* service_worker_context = |
| 56 filter ? filter->service_worker_context() | 57 filter ? filter->service_worker_context() |
| 57 : service_worker_context_for_testing; | 58 : service_worker_context_for_testing; |
| 59 if (IsBrowserSideNavigationEnabled() && |
| 60 ServiceWorkerUtils::IsMainResourceType(request_info->GetResourceType()) && |
| 61 !service_worker_context) { |
| 62 service_worker_context = request_info->service_worker_context(); |
| 63 } |
| 64 |
| 58 if (!service_worker_context) | 65 if (!service_worker_context) |
| 59 return; | 66 return; |
| 60 | 67 |
| 61 if (ServiceWorkerUtils::IsMainResourceType(request_info->GetResourceType())) { | 68 if (ServiceWorkerUtils::IsMainResourceType(request_info->GetResourceType())) { |
| 62 // In case of navigations, make sure the navigation will actually result in | 69 // In case of navigations, make sure the navigation will actually result in |
| 63 // a secure context. | 70 // a secure context. |
| 64 ServiceWorkerProviderHost* provider_host = | 71 ServiceWorkerProviderHost* provider_host = |
| 65 ServiceWorkerRequestHandler::GetProviderHost(request); | 72 ServiceWorkerRequestHandler::GetProviderHost(request); |
| 66 if (!provider_host || !provider_host->IsContextSecureForServiceWorker()) | 73 if (!provider_host || !provider_host->IsContextSecureForServiceWorker()) |
| 67 return; | 74 return; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 const net::URLRequest* request, | 162 const net::URLRequest* request, |
| 156 const std::string& link_header, | 163 const std::string& link_header, |
| 157 ServiceWorkerContextWrapper* service_worker_context_for_testing) { | 164 ServiceWorkerContextWrapper* service_worker_context_for_testing) { |
| 158 for (const auto& value : link_header_util::SplitLinkHeader(link_header)) { | 165 for (const auto& value : link_header_util::SplitLinkHeader(link_header)) { |
| 159 ProcessLinkHeaderValueForRequest(request, value.first, value.second, | 166 ProcessLinkHeaderValueForRequest(request, value.first, value.second, |
| 160 service_worker_context_for_testing); | 167 service_worker_context_for_testing); |
| 161 } | 168 } |
| 162 } | 169 } |
| 163 | 170 |
| 164 } // namespace content | 171 } // namespace content |
| OLD | NEW |