Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Unified Diff: content/browser/service_worker/link_header_support.cc

Issue 2512103003: Limit Link header based SW installations for fetches made by SW. (Closed)
Patch Set: address comments Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/service_worker/link_header_support_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/link_header_support.cc
diff --git a/content/browser/service_worker/link_header_support.cc b/content/browser/service_worker/link_header_support.cc
index 0cb2f29d8a3ded4bf92279cd0a4a75ced503447d..b2364d8518e914b7bef72b45ac46fba6e154a532 100644
--- a/content/browser/service_worker/link_header_support.cc
+++ b/content/browser/service_worker/link_header_support.cc
@@ -65,11 +65,20 @@ void HandleServiceWorkerLink(
if (!service_worker_context)
return;
+ ServiceWorkerProviderHost* provider_host =
+ ServiceWorkerRequestHandler::GetProviderHost(request);
+
+ // If fetched from a service worker, make sure fetching service worker is
+ // controlling at least one client to prevent a service worker from spawning
+ // new service workers in the background.
+ if (provider_host && provider_host->IsHostToRunningServiceWorker()) {
+ if (!provider_host->running_hosted_version()->HasControllee())
+ return;
+ }
+
if (ServiceWorkerUtils::IsMainResourceType(request_info->GetResourceType())) {
// In case of navigations, make sure the navigation will actually result in
// a secure context.
- ServiceWorkerProviderHost* provider_host =
- ServiceWorkerRequestHandler::GetProviderHost(request);
if (!provider_host || !provider_host->IsContextSecureForServiceWorker())
return;
} else {
« no previous file with comments | « no previous file | content/browser/service_worker/link_header_support_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698