2022-05-23 07:42:37 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: deepak1556 <hop2deep@gmail.com>
|
|
|
|
Date: Fri, 20 May 2022 00:29:34 +0900
|
|
|
|
Subject: custom_protocols_plzserviceworker.patch
|
|
|
|
|
|
|
|
Allow registering custom protocols to handle service worker main script fetching with PlzServiceWorker.
|
|
|
|
|
|
|
|
Refs https://bugs.chromium.org/p/chromium/issues/detail?id=996511
|
|
|
|
|
|
|
|
diff --git a/content/browser/service_worker/service_worker_context_wrapper.cc b/content/browser/service_worker/service_worker_context_wrapper.cc
|
2024-09-18 01:12:11 +00:00
|
|
|
index 452e62f3ca8be4a7f519019854a83aae86fb523e..5e9ddf37003ea8d4ee1a1039e911890dfe9f0678 100644
|
2022-05-23 07:42:37 +00:00
|
|
|
--- a/content/browser/service_worker/service_worker_context_wrapper.cc
|
|
|
|
+++ b/content/browser/service_worker/service_worker_context_wrapper.cc
|
2024-09-18 01:12:11 +00:00
|
|
|
@@ -1978,6 +1978,26 @@ ServiceWorkerContextWrapper::GetLoaderFactoryForBrowserInitiatedRequest(
|
2022-05-23 07:42:37 +00:00
|
|
|
loader_factory_bundle_info =
|
|
|
|
context()->loader_factory_bundle_for_update_check()->Clone();
|
|
|
|
|
|
|
|
+ // Give the embedder a chance to register custom schemes that can
|
|
|
|
+ // handle loading the service worker main script.
|
|
|
|
+ // Previous registration triggered by
|
|
|
|
+ // ServiceWorkerContextWrapper::CreateNonNetworkPendingURLLoaderFactoryBundleForUpdateCheck
|
|
|
|
+ // happens early on browser startup before the JS in the main process
|
|
|
|
+ // is run by the embedder.
|
2022-12-05 22:59:19 +00:00
|
|
|
+ auto& pending_scheme_specific_factories =
|
|
|
|
+ static_cast<blink::PendingURLLoaderFactoryBundle*>(
|
|
|
|
+ loader_factory_bundle_info.get())
|
|
|
|
+ ->pending_scheme_specific_factories();
|
2022-05-23 07:42:37 +00:00
|
|
|
+ ContentBrowserClient::NonNetworkURLLoaderFactoryMap non_network_factories;
|
|
|
|
+ GetContentClient()
|
|
|
|
+ ->browser()
|
|
|
|
+ ->RegisterNonNetworkServiceWorkerUpdateURLLoaderFactories(
|
|
|
|
+ storage_partition_->browser_context(), &non_network_factories);
|
2022-12-05 22:59:19 +00:00
|
|
|
+ for (auto& [scheme, factory_remote] : non_network_factories) {
|
|
|
|
+ pending_scheme_specific_factories.emplace(
|
2022-05-23 07:42:37 +00:00
|
|
|
+ scheme, std::move(factory_remote));
|
|
|
|
+ }
|
|
|
|
+
|
2022-12-05 22:59:19 +00:00
|
|
|
if (auto* config = content::WebUIConfigMap::GetInstance().GetConfig(
|
2023-07-31 17:47:32 +00:00
|
|
|
browser_context(), scope)) {
|
2022-12-05 22:59:19 +00:00
|
|
|
// If this is a Service Worker for a WebUI, the WebUI's URLDataSource
|
2024-09-18 01:12:11 +00:00
|
|
|
@@ -1997,9 +2017,7 @@ ServiceWorkerContextWrapper::GetLoaderFactoryForBrowserInitiatedRequest(
|
2022-12-05 22:59:19 +00:00
|
|
|
features::kEnableServiceWorkersForChromeScheme) &&
|
|
|
|
scope.scheme_piece() == kChromeUIScheme) {
|
|
|
|
config->RegisterURLDataSource(browser_context());
|
|
|
|
- static_cast<blink::PendingURLLoaderFactoryBundle*>(
|
|
|
|
- loader_factory_bundle_info.get())
|
|
|
|
- ->pending_scheme_specific_factories()
|
|
|
|
+ pending_scheme_specific_factories
|
|
|
|
.emplace(kChromeUIScheme, CreateWebUIServiceWorkerLoaderFactory(
|
|
|
|
browser_context(), kChromeUIScheme,
|
|
|
|
base::flat_set<std::string>()));
|
2024-09-18 01:12:11 +00:00
|
|
|
@@ -2007,9 +2025,7 @@ ServiceWorkerContextWrapper::GetLoaderFactoryForBrowserInitiatedRequest(
|
2022-12-05 22:59:19 +00:00
|
|
|
features::kEnableServiceWorkersForChromeUntrusted) &&
|
|
|
|
scope.scheme_piece() == kChromeUIUntrustedScheme) {
|
2022-05-23 07:42:37 +00:00
|
|
|
config->RegisterURLDataSource(browser_context());
|
|
|
|
- static_cast<blink::PendingURLLoaderFactoryBundle*>(
|
|
|
|
- loader_factory_bundle_info.get())
|
|
|
|
- ->pending_scheme_specific_factories()
|
2022-12-05 22:59:19 +00:00
|
|
|
+ pending_scheme_specific_factories
|
2022-05-23 07:42:37 +00:00
|
|
|
.emplace(kChromeUIUntrustedScheme,
|
|
|
|
CreateWebUIServiceWorkerLoaderFactory(
|
|
|
|
browser_context(), kChromeUIUntrustedScheme,
|