| 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 "base/time/time.h" |
| 10 #include "components/link_header_util/link_header_util.h" | 11 #include "components/link_header_util/link_header_util.h" |
| 11 #include "content/browser/loader/resource_message_filter.h" | 12 #include "content/browser/loader/resource_message_filter.h" |
| 12 #include "content/browser/loader/resource_request_info_impl.h" | 13 #include "content/browser/loader/resource_request_info_impl.h" |
| 13 #include "content/browser/service_worker/service_worker_context_wrapper.h" | 14 #include "content/browser/service_worker/service_worker_context_wrapper.h" |
| 14 #include "content/browser/service_worker/service_worker_request_handler.h" | 15 #include "content/browser/service_worker/service_worker_request_handler.h" |
| 15 #include "content/common/origin_trials/trial_token_validator.h" | 16 #include "content/common/origin_trials/trial_token_validator.h" |
| 16 #include "content/common/service_worker/service_worker_utils.h" | 17 #include "content/common/service_worker/service_worker_utils.h" |
| 17 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/content_browser_client.h" | 19 #include "content/public/browser/content_browser_client.h" |
| 19 #include "content/public/common/browser_side_navigation_policy.h" | 20 #include "content/public/common/browser_side_navigation_policy.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 35 | 36 |
| 36 void HandleServiceWorkerLink( | 37 void HandleServiceWorkerLink( |
| 37 net::URLRequest* request, | 38 net::URLRequest* request, |
| 38 const std::string& url, | 39 const std::string& url, |
| 39 const std::unordered_map<std::string, base::Optional<std::string>>& params, | 40 const std::unordered_map<std::string, base::Optional<std::string>>& params, |
| 40 ServiceWorkerContextWrapper* service_worker_context_for_testing) { | 41 ServiceWorkerContextWrapper* service_worker_context_for_testing) { |
| 41 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 42 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 42 | 43 |
| 43 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 44 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 44 switches::kEnableExperimentalWebPlatformFeatures) && | 45 switches::kEnableExperimentalWebPlatformFeatures) && |
| 45 !TrialTokenValidator::RequestEnablesFeature(request, "ForeignFetch")) { | 46 !TrialTokenValidator::RequestEnablesFeature(request, "ForeignFetch", |
| 47 base::Time::Now())) { |
| 46 // TODO(mek): Log attempt to use without having correct token? | 48 // TODO(mek): Log attempt to use without having correct token? |
| 47 return; | 49 return; |
| 48 } | 50 } |
| 49 | 51 |
| 50 if (ContainsKey(params, "anchor")) | 52 if (ContainsKey(params, "anchor")) |
| 51 return; | 53 return; |
| 52 | 54 |
| 53 ResourceRequestInfoImpl* request_info = | 55 ResourceRequestInfoImpl* request_info = |
| 54 ResourceRequestInfoImpl::ForRequest(request); | 56 ResourceRequestInfoImpl::ForRequest(request); |
| 55 ServiceWorkerContext* service_worker_context = | 57 ServiceWorkerContext* service_worker_context = |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 net::URLRequest* request, | 165 net::URLRequest* request, |
| 164 const std::string& link_header, | 166 const std::string& link_header, |
| 165 ServiceWorkerContextWrapper* service_worker_context_for_testing) { | 167 ServiceWorkerContextWrapper* service_worker_context_for_testing) { |
| 166 for (const auto& value : link_header_util::SplitLinkHeader(link_header)) { | 168 for (const auto& value : link_header_util::SplitLinkHeader(link_header)) { |
| 167 ProcessLinkHeaderValueForRequest(request, value.first, value.second, | 169 ProcessLinkHeaderValueForRequest(request, value.first, value.second, |
| 168 service_worker_context_for_testing); | 170 service_worker_context_for_testing); |
| 169 } | 171 } |
| 170 } | 172 } |
| 171 | 173 |
| 172 } // namespace content | 174 } // namespace content |
| OLD | NEW |