ladybird/Userland/Libraries/LibWeb/HTML/PolicyContainers.cpp
Andrew Kaster 4d22358e05 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.
2024-03-06 07:19:10 +01:00

30 lines
668 B
C++

/*
* 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/PolicyContainers.h>
namespace IPC {
template<>
ErrorOr<void> encode(IPC::Encoder& encoder, Web::HTML::PolicyContainer const& policy_container)
{
TRY(encode(encoder, policy_container.referrer_policy));
return {};
}
template<>
ErrorOr<Web::HTML::PolicyContainer> decode(IPC::Decoder& decoder)
{
auto referrer_policy = TRY(decoder.decode<Web::ReferrerPolicy::ReferrerPolicy>());
return Web::HTML::PolicyContainer { .referrer_policy = referrer_policy };
}
}