2020-03-26 17:34:32 +00:00
|
|
|
// Copyright (c) 2020 Slack Technologies, Inc.
|
|
|
|
// Use of this source code is governed by the MIT license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#ifndef ELECTRON_SHELL_BROWSER_PROTOCOL_REGISTRY_H_
|
|
|
|
#define ELECTRON_SHELL_BROWSER_PROTOCOL_REGISTRY_H_
|
2020-03-26 17:34:32 +00:00
|
|
|
|
|
|
|
#include <string>
|
2024-08-24 01:58:59 +00:00
|
|
|
#include <string_view>
|
2020-03-26 17:34:32 +00:00
|
|
|
|
|
|
|
#include "content/public/browser/content_browser_client.h"
|
|
|
|
#include "shell/browser/net/electron_url_loader_factory.h"
|
|
|
|
|
|
|
|
namespace content {
|
|
|
|
class BrowserContext;
|
2021-07-02 00:51:37 +00:00
|
|
|
}
|
2020-03-26 17:34:32 +00:00
|
|
|
|
|
|
|
namespace electron {
|
|
|
|
|
|
|
|
class ProtocolRegistry {
|
|
|
|
public:
|
|
|
|
~ProtocolRegistry();
|
|
|
|
|
|
|
|
static ProtocolRegistry* FromBrowserContext(content::BrowserContext*);
|
|
|
|
|
2020-04-01 07:38:40 +00:00
|
|
|
using URLLoaderFactoryType =
|
|
|
|
content::ContentBrowserClient::URLLoaderFactoryType;
|
|
|
|
|
2020-03-26 17:34:32 +00:00
|
|
|
void RegisterURLLoaderFactories(
|
2021-04-07 01:46:23 +00:00
|
|
|
content::ContentBrowserClient::NonNetworkURLLoaderFactoryMap* factories,
|
|
|
|
bool allow_file_access);
|
2020-03-26 17:34:32 +00:00
|
|
|
|
2024-02-29 09:31:13 +00:00
|
|
|
mojo::PendingRemote<network::mojom::URLLoaderFactory>
|
|
|
|
CreateNonNetworkNavigationURLLoaderFactory(const std::string& scheme);
|
|
|
|
|
2020-03-26 17:34:32 +00:00
|
|
|
const HandlersMap& intercept_handlers() const { return intercept_handlers_; }
|
|
|
|
|
|
|
|
bool RegisterProtocol(ProtocolType type,
|
|
|
|
const std::string& scheme,
|
|
|
|
const ProtocolHandler& handler);
|
|
|
|
bool UnregisterProtocol(const std::string& scheme);
|
2024-05-09 13:53:09 +00:00
|
|
|
|
|
|
|
[[nodiscard]] const HandlersMap::mapped_type* FindRegistered(
|
2024-08-24 01:58:59 +00:00
|
|
|
std::string_view scheme) const;
|
2020-03-26 17:34:32 +00:00
|
|
|
|
|
|
|
bool InterceptProtocol(ProtocolType type,
|
|
|
|
const std::string& scheme,
|
|
|
|
const ProtocolHandler& handler);
|
|
|
|
bool UninterceptProtocol(const std::string& scheme);
|
2024-05-09 13:53:09 +00:00
|
|
|
|
|
|
|
[[nodiscard]] const HandlersMap::mapped_type* FindIntercepted(
|
2024-08-24 01:58:59 +00:00
|
|
|
std::string_view scheme) const;
|
2020-03-26 17:34:32 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
friend class ElectronBrowserContext;
|
|
|
|
|
|
|
|
ProtocolRegistry();
|
|
|
|
|
|
|
|
HandlersMap handlers_;
|
|
|
|
HandlersMap intercept_handlers_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace electron
|
|
|
|
|
2021-11-22 07:34:31 +00:00
|
|
|
#endif // ELECTRON_SHELL_BROWSER_PROTOCOL_REGISTRY_H_
|