fix: load source maps from custom protocols and asar bundles (#28573)
* fix: load source maps from custom protocols and asar bundles * chore: fix lint
This commit is contained in:
parent
ef4954fa1f
commit
6bd13cc98f
6 changed files with 99 additions and 44 deletions
|
@ -2,55 +2,17 @@
|
|||
// Use of this source code is governed by the MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "shell/browser/protocol_registry.h"
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
|
||||
#include "content/public/browser/web_contents.h"
|
||||
#include "services/network/public/cpp/self_deleting_url_loader_factory.h"
|
||||
#include "shell/browser/electron_browser_context.h"
|
||||
#include "shell/browser/net/asar/asar_url_loader.h"
|
||||
#include "shell/browser/protocol_registry.h"
|
||||
#include "shell/browser/net/asar/asar_url_loader_factory.h"
|
||||
|
||||
namespace electron {
|
||||
|
||||
namespace {
|
||||
|
||||
// Provide support for accessing asar archives in file:// protocol.
|
||||
class AsarURLLoaderFactory : public network::SelfDeletingURLLoaderFactory {
|
||||
public:
|
||||
static mojo::PendingRemote<network::mojom::URLLoaderFactory> Create() {
|
||||
mojo::PendingRemote<network::mojom::URLLoaderFactory> pending_remote;
|
||||
|
||||
// The AsarURLLoaderFactory will delete itself when there are no more
|
||||
// receivers - see the SelfDeletingURLLoaderFactory::OnDisconnect method.
|
||||
new AsarURLLoaderFactory(pending_remote.InitWithNewPipeAndPassReceiver());
|
||||
|
||||
return pending_remote;
|
||||
}
|
||||
|
||||
private:
|
||||
AsarURLLoaderFactory(
|
||||
mojo::PendingReceiver<network::mojom::URLLoaderFactory> factory_receiver)
|
||||
: network::SelfDeletingURLLoaderFactory(std::move(factory_receiver)) {}
|
||||
~AsarURLLoaderFactory() override = default;
|
||||
|
||||
// network::mojom::URLLoaderFactory:
|
||||
void CreateLoaderAndStart(
|
||||
mojo::PendingReceiver<network::mojom::URLLoader> loader,
|
||||
int32_t routing_id,
|
||||
int32_t request_id,
|
||||
uint32_t options,
|
||||
const network::ResourceRequest& request,
|
||||
mojo::PendingRemote<network::mojom::URLLoaderClient> client,
|
||||
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation)
|
||||
override {
|
||||
asar::CreateAsarURLLoader(request, std::move(loader), std::move(client),
|
||||
new net::HttpResponseHeaders(""));
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
// static
|
||||
ProtocolRegistry* ProtocolRegistry::FromBrowserContext(
|
||||
content::BrowserContext* context) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue