mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-20 09:11:53 +00:00
LibWeb: Make PolicyContainer GC allocated
This is required to store Content Security Policies, as their Directives are implemented as subclasses with overridden virtual functions. Thus, they cannot be stored as generic Directive classes, as it'll lose the ability to call overridden functions when they are copied.
This commit is contained in:
parent
2e27ffab6c
commit
cae0ab2139
Notes:
github-actions[bot]
2025-02-21 12:55:13 +00:00
Author: https://github.com/Lubrsi
Commit: cae0ab2139
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3627
Reviewed-by: https://github.com/AtkinsSJ ✅
43 changed files with 381 additions and 130 deletions
33
Libraries/LibWeb/HTML/SerializedPolicyContainer.cpp
Normal file
33
Libraries/LibWeb/HTML/SerializedPolicyContainer.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (c) 2025, Luke Wilde <luke@ladybird.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibIPC/Decoder.h>
|
||||
#include <LibIPC/Encoder.h>
|
||||
#include <LibWeb/HTML/SerializedPolicyContainer.h>
|
||||
|
||||
namespace IPC {
|
||||
|
||||
template<>
|
||||
ErrorOr<void> encode(Encoder& encoder, Web::HTML::SerializedPolicyContainer const& serialized_policy_container)
|
||||
{
|
||||
TRY(encoder.encode(serialized_policy_container.embedder_policy));
|
||||
TRY(encoder.encode(serialized_policy_container.referrer_policy));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
template<>
|
||||
ErrorOr<Web::HTML::SerializedPolicyContainer> decode(Decoder& decoder)
|
||||
{
|
||||
Web::HTML::SerializedPolicyContainer serialized_policy_container {};
|
||||
|
||||
serialized_policy_container.embedder_policy = TRY(decoder.decode<Web::HTML::EmbedderPolicy>());
|
||||
serialized_policy_container.referrer_policy = TRY(decoder.decode<Web::ReferrerPolicy::ReferrerPolicy>());
|
||||
|
||||
return serialized_policy_container;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue