1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 01:37:34 +00:00

LibWeb: Add facilities to serialize EnvironmentSettingsObjects

This will be used to transfer information about the parent context to
DedicatedWorkers and future out-of-process Worker/Worklet
implementations for fetching purposes. In order to properly check
same-origin and other policies, we need to know more about the outside
settings than we were previously passing to the WebWorker process.
This commit is contained in:
Andrew Kaster 2024-03-05 09:29:14 -07:00 committed by Andreas Kling
parent c79bac70f4
commit 4d22358e05
11 changed files with 198 additions and 5 deletions

View file

@ -0,0 +1,32 @@
/*
* Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibIPC/Decoder.h>
#include <LibIPC/Encoder.h>
#include <LibWeb/HTML/Origin.h>
namespace IPC {
template<>
ErrorOr<void> encode(Encoder& encoder, Web::HTML::Origin const& origin)
{
TRY(encoder.encode<ByteString>(origin.scheme()));
TRY(encoder.encode(origin.host()));
TRY(encoder.encode(origin.port()));
return {};
}
template<>
ErrorOr<Web::HTML::Origin> decode(Decoder& decoder)
{
auto scheme = TRY(decoder.decode<ByteString>());
auto host = TRY(decoder.decode<URL::Host>());
u16 port = TRY(decoder.decode<u16>());
return Web::HTML::Origin { move(scheme), move(host), port };
}
}