2024-11-25 16:17:17 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2025, Luke Wilde <luke@ladybird.org>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <LibJS/Runtime/Realm.h>
|
2024-11-28 16:35:12 +00:00
|
|
|
#include <LibWeb/ContentSecurityPolicy/Directives/ConnectSourceDirective.h>
|
2024-11-25 16:17:17 +00:00
|
|
|
#include <LibWeb/ContentSecurityPolicy/Directives/Directive.h>
|
|
|
|
|
#include <LibWeb/ContentSecurityPolicy/Directives/DirectiveFactory.h>
|
2024-11-29 10:54:29 +00:00
|
|
|
#include <LibWeb/ContentSecurityPolicy/Directives/FontSourceDirective.h>
|
2024-11-29 11:08:12 +00:00
|
|
|
#include <LibWeb/ContentSecurityPolicy/Directives/FrameSourceDirective.h>
|
2024-11-29 11:21:17 +00:00
|
|
|
#include <LibWeb/ContentSecurityPolicy/Directives/ImageSourceDirective.h>
|
2024-11-28 16:35:12 +00:00
|
|
|
#include <LibWeb/ContentSecurityPolicy/Directives/Names.h>
|
2024-11-25 16:17:17 +00:00
|
|
|
|
|
|
|
|
namespace Web::ContentSecurityPolicy::Directives {
|
|
|
|
|
|
2025-04-26 11:35:51 +12:00
|
|
|
GC::Ref<Directive> create_directive(GC::Heap& heap, String name, Vector<String> value)
|
2024-11-25 16:17:17 +00:00
|
|
|
{
|
2024-11-28 16:35:12 +00:00
|
|
|
if (name == Names::ConnectSrc)
|
|
|
|
|
return heap.allocate<ConnectSourceDirective>(move(name), move(value));
|
|
|
|
|
|
2024-11-29 10:54:29 +00:00
|
|
|
if (name == Names::FontSrc)
|
|
|
|
|
return heap.allocate<FontSourceDirective>(move(name), move(value));
|
|
|
|
|
|
2024-11-29 11:08:12 +00:00
|
|
|
if (name == Names::FrameSrc)
|
|
|
|
|
return heap.allocate<FrameSourceDirective>(move(name), move(value));
|
|
|
|
|
|
2024-11-29 11:21:17 +00:00
|
|
|
if (name == Names::ImgSrc)
|
|
|
|
|
return heap.allocate<ImageSourceDirective>(move(name), move(value));
|
|
|
|
|
|
2025-04-26 11:35:51 +12:00
|
|
|
return heap.allocate<Directive>(move(name), move(value));
|
2024-11-25 16:17:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|