electron/patches/chromium/custom_protocols_plzserviceworker.patch
electron-roller[bot] a841d6484c
chore: bump node to v22.14.0 (main) (#45578)
* chore: bump node in DEPS to v22.14.0

* src: move more crypto impl detail to ncrypto dep

https://github.com/nodejs/node/pull/56421

* test: move crypto related common utilities in common/crypto

https://github.com/nodejs/node/pull/56714

* module: add findPackageJSON util

https://github.com/nodejs/node/pull/55412

* module: mark evaluation rejection in require(esm) as handled

https://github.com/nodejs/node/pull/56122

* chore: fixup patch indices

* deps: move inspector_protocol to deps

https://github.com/nodejs/node/pull/56649

* fixup! src: move more crypto impl detail to ncrypto dep

* fixup! deps: move inspector_protocol to deps

* fixup! src: move more crypto impl detail to ncrypto dep

* crypto: fix checkPrime crash with large buffers

https://github.com/nodejs/node/pull/56559

* tls: fix error stack conversion in cryptoErrorListToException()

https://github.com/nodejs/node/pull/56554

* module: add findPackageJSON util

https://github.com/nodejs/node/pull/55412

Our revert of native legacyMainResolve makes this very difficult to make
work, so disable for now.

* lib: add typescript support to STDIN eval

https://github.com/nodejs/node/pull/56359

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2025-02-14 11:05:01 +01:00

62 lines
3.4 KiB
Diff

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
index ff25eb3670d2391c6fb41b7c612c30ee8798983f..116763b520713a5c61462b2e048a7358486831a2 100644
--- a/content/browser/service_worker/service_worker_context_wrapper.cc
+++ b/content/browser/service_worker/service_worker_context_wrapper.cc
@@ -1969,6 +1969,26 @@ ServiceWorkerContextWrapper::GetLoaderFactoryForBrowserInitiatedRequest(
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.
+ auto& pending_scheme_specific_factories =
+ static_cast<blink::PendingURLLoaderFactoryBundle*>(
+ loader_factory_bundle_info.get())
+ ->pending_scheme_specific_factories();
+ ContentBrowserClient::NonNetworkURLLoaderFactoryMap non_network_factories;
+ GetContentClient()
+ ->browser()
+ ->RegisterNonNetworkServiceWorkerUpdateURLLoaderFactories(
+ storage_partition_->browser_context(), &non_network_factories);
+ for (auto& [scheme, factory_remote] : non_network_factories) {
+ pending_scheme_specific_factories.emplace(
+ scheme, std::move(factory_remote));
+ }
+
if (auto* config = content::WebUIConfigMap::GetInstance().GetConfig(
browser_context(), scope)) {
// If this is a Service Worker for a WebUI, the WebUI's URLDataSource
@@ -1988,9 +2008,7 @@ ServiceWorkerContextWrapper::GetLoaderFactoryForBrowserInitiatedRequest(
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>()));
@@ -1998,9 +2016,7 @@ ServiceWorkerContextWrapper::GetLoaderFactoryForBrowserInitiatedRequest(
features::kEnableServiceWorkersForChromeUntrusted) &&
scope.scheme_piece() == kChromeUIUntrustedScheme) {
config->RegisterURLDataSource(browser_context());
- static_cast<blink::PendingURLLoaderFactoryBundle*>(
- loader_factory_bundle_info.get())
- ->pending_scheme_specific_factories()
+ pending_scheme_specific_factories
.emplace(kChromeUIUntrustedScheme,
CreateWebUIServiceWorkerLoaderFactory(
browser_context(), kChromeUIUntrustedScheme,