LegacyCustomProtocolManager.cpp [plain text]
#include "config.h"
#include "LegacyCustomProtocolManager.h"
#include "LegacyCustomProtocolManagerMessages.h"
#include "LegacyCustomProtocolManagerProxyMessages.h"
#include "NetworkProcess.h"
#include "NetworkProcessCreationParameters.h"
#include "WebCoreArgumentCoders.h"
#include <WebCore/ResourceRequest.h>
namespace WebKit {
const char* LegacyCustomProtocolManager::supplementName()
{
return "LegacyCustomProtocolManager";
}
LegacyCustomProtocolManager::LegacyCustomProtocolManager(NetworkProcess& networkProcess)
: m_networkProcess(networkProcess)
{
m_networkProcess.addMessageReceiver(Messages::LegacyCustomProtocolManager::messageReceiverName(), *this);
}
void LegacyCustomProtocolManager::initialize(const NetworkProcessCreationParameters& parameters)
{
registerProtocolClass();
for (const auto& scheme : parameters.urlSchemesRegisteredForCustomProtocols)
registerScheme(scheme);
}
LegacyCustomProtocolID LegacyCustomProtocolManager::addCustomProtocol(CustomProtocol&& customProtocol)
{
LockHolder locker(m_customProtocolMapMutex);
auto customProtocolID = LegacyCustomProtocolID::generate();
m_customProtocolMap.add(customProtocolID, WTFMove(customProtocol));
return customProtocolID;
}
void LegacyCustomProtocolManager::removeCustomProtocol(LegacyCustomProtocolID customProtocolID)
{
LockHolder locker(m_customProtocolMapMutex);
m_customProtocolMap.remove(customProtocolID);
}
void LegacyCustomProtocolManager::startLoading(LegacyCustomProtocolID customProtocolID, const WebCore::ResourceRequest& request)
{
m_networkProcess.send(Messages::LegacyCustomProtocolManagerProxy::StartLoading(customProtocolID, request));
}
void LegacyCustomProtocolManager::stopLoading(LegacyCustomProtocolID customProtocolID)
{
m_networkProcess.send(Messages::LegacyCustomProtocolManagerProxy::StopLoading(customProtocolID), 0);
}
}