ladybird/Libraries/LibWeb/ContentSecurityPolicy/Directives/Directive.cpp
Shannon Booth 8a3c66d8a6 LibWeb: Make a bunch of CSP classes not realm associated
These are not associated with a javascript realm, so to avoid
confusion about which realm these need to be created in, make
all of these objects a GC::Cell, and deal with the fallout.
2025-04-28 12:41:28 +02:00

35 lines
805 B
C++

/*
* Copyright (c) 2025, Luke Wilde <luke@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Runtime/Realm.h>
#include <LibWeb/ContentSecurityPolicy/Directives/Directive.h>
#include <LibWeb/ContentSecurityPolicy/Directives/DirectiveFactory.h>
#include <LibWeb/ContentSecurityPolicy/Directives/SerializedDirective.h>
namespace Web::ContentSecurityPolicy::Directives {
GC_DEFINE_ALLOCATOR(Directive);
Directive::Directive(String name, Vector<String> value)
: m_name(move(name))
, m_value(move(value))
{
}
GC::Ref<Directive> Directive::clone(GC::Heap& heap) const
{
return create_directive(heap, m_name, m_value);
}
SerializedDirective Directive::serialize() const
{
return SerializedDirective {
.name = m_name,
.value = m_value,
};
}
}