Sorry, my explanation wasn't very clear. The goal here is to block
all isolated-app: requests that don't come from the app itself, which includes navigations, subresources, and service worker related requests. We register IsolatedWebAppURLLoaderFactory in several places right now because of the different types of isolated-app: requests we need, specifically:
- ContentBrowserClient::CreateNonNetworkNavigationURLLoaderFactory
- ContentBrowserClient::RegisterNonNetworkSubresourceURLLoaderFactories
- ContentBrowserClient::RegisterNonNetworkWorkerMainResourceURLLoaderFactories
- ContentBrowserClient::RegisterNonNetworkServiceWorkerUpdateURLLoaderFactories
- ExtensionsBrowserClient::GetControlledFrameEmbedderURLLoader
All of these except RegisterNonNetworkServiceWorkerUpdateURLLoaderFactories have an RPH id and sometimes an FTN id available (RegisterNonNetworkWorkerMainResourceURLLoaderFactories doesn't but I added one in my
prototype CL).
We currently always create the URLoaderFactory in each of those locations, but you're right that we don't need to universally create it for subresources. We can fix that.
I'd still feel more confident with a CPSP check though. In addition to fixing the subresource loader creation logic, how about the following:
- Add a initiator_process_id argument to CreateNonNetworkNavigationURLLoaderFactory, initialized from request_info.initiator_process_id
- Add a initiator_process_id argument to RegisterNonNetworkWorkerMainResourceURLLoaderFactories, initialized from worker_process_id in WorkerScriptFetcher::CreateFactoryBundle
IsolatedWebAppURLLoaderFactory would then always have an initiator process id (unless it's CreateForBrowser), which it can save and use for a CPSP::HostsOrigin check at the start of each request it handles.