feat: add protocol.handle (#36674)

This commit is contained in:
Jeremy Rose 2023-03-27 10:00:55 -07:00 committed by GitHub
parent 6a6908c4c8
commit fda8ea9277
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 1254 additions and 89 deletions

View file

@ -806,18 +806,23 @@ void ProxyingURLLoaderFactory::CreateLoaderAndStart(
}
// Check if user has intercepted this scheme.
auto it = intercepted_handlers_.find(request.url.scheme());
if (it != intercepted_handlers_.end()) {
mojo::PendingRemote<network::mojom::URLLoaderFactory> loader_remote;
this->Clone(loader_remote.InitWithNewPipeAndPassReceiver());
bool bypass_custom_protocol_handlers =
options & kBypassCustomProtocolHandlers;
if (!bypass_custom_protocol_handlers) {
auto it = intercepted_handlers_.find(request.url.scheme());
if (it != intercepted_handlers_.end()) {
mojo::PendingRemote<network::mojom::URLLoaderFactory> loader_remote;
this->Clone(loader_remote.InitWithNewPipeAndPassReceiver());
// <scheme, <type, handler>>
it->second.second.Run(
request, base::BindOnce(&ElectronURLLoaderFactory::StartLoading,
std::move(loader), request_id, options, request,
std::move(client), traffic_annotation,
std::move(loader_remote), it->second.first));
return;
// <scheme, <type, handler>>
it->second.second.Run(
request,
base::BindOnce(&ElectronURLLoaderFactory::StartLoading,
std::move(loader), request_id, options, request,
std::move(client), traffic_annotation,
std::move(loader_remote), it->second.first));
return;
}
}
// The loader of ServiceWorker forbids loading scripts from file:// URLs, and