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