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-12-03 18:29:41 +00:00
|
|
|
#include <LibWeb/ContentSecurityPolicy/Directives/ChildSourceDirective.h>
|
2024-11-28 16:35:12 +00:00
|
|
|
#include <LibWeb/ContentSecurityPolicy/Directives/ConnectSourceDirective.h>
|
2024-12-03 18:18:50 +00:00
|
|
|
#include <LibWeb/ContentSecurityPolicy/Directives/DefaultSourceDirective.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-29 11:45:38 +00:00
|
|
|
#include <LibWeb/ContentSecurityPolicy/Directives/ManifestSourceDirective.h>
|
2024-11-29 12:04:15 +00:00
|
|
|
#include <LibWeb/ContentSecurityPolicy/Directives/MediaSourceDirective.h>
|
2024-11-28 16:35:12 +00:00
|
|
|
#include <LibWeb/ContentSecurityPolicy/Directives/Names.h>
|
2024-11-29 12:10:14 +00:00
|
|
|
#include <LibWeb/ContentSecurityPolicy/Directives/ObjectSourceDirective.h>
|
2024-12-03 15:33:32 +00:00
|
|
|
#include <LibWeb/ContentSecurityPolicy/Directives/ScriptSourceAttributeDirective.h>
|
2024-12-02 16:01:19 +00:00
|
|
|
#include <LibWeb/ContentSecurityPolicy/Directives/ScriptSourceDirective.h>
|
2024-12-03 15:24:07 +00:00
|
|
|
#include <LibWeb/ContentSecurityPolicy/Directives/ScriptSourceElementDirective.h>
|
2024-12-03 17:27:12 +00:00
|
|
|
#include <LibWeb/ContentSecurityPolicy/Directives/StyleSourceAttributeDirective.h>
|
2024-12-03 16:57:18 +00:00
|
|
|
#include <LibWeb/ContentSecurityPolicy/Directives/StyleSourceDirective.h>
|
2024-12-03 17:16:27 +00:00
|
|
|
#include <LibWeb/ContentSecurityPolicy/Directives/StyleSourceElementDirective.h>
|
2024-12-03 17:54:51 +00:00
|
|
|
#include <LibWeb/ContentSecurityPolicy/Directives/WorkerSourceDirective.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-12-03 18:29:41 +00:00
|
|
|
if (name == Names::ChildSrc)
|
|
|
|
|
return heap.allocate<ChildSourceDirective>(move(name), move(value));
|
|
|
|
|
|
2024-11-28 16:35:12 +00:00
|
|
|
if (name == Names::ConnectSrc)
|
|
|
|
|
return heap.allocate<ConnectSourceDirective>(move(name), move(value));
|
|
|
|
|
|
2024-12-03 18:18:50 +00:00
|
|
|
if (name == Names::DefaultSrc)
|
|
|
|
|
return heap.allocate<DefaultSourceDirective>(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));
|
|
|
|
|
|
2024-11-29 11:45:38 +00:00
|
|
|
if (name == Names::ManifestSrc)
|
|
|
|
|
return heap.allocate<ManifestSourceDirective>(move(name), move(value));
|
|
|
|
|
|
2024-11-29 12:04:15 +00:00
|
|
|
if (name == Names::MediaSrc)
|
|
|
|
|
return heap.allocate<MediaSourceDirective>(move(name), move(value));
|
|
|
|
|
|
2024-11-29 12:10:14 +00:00
|
|
|
if (name == Names::ObjectSrc)
|
|
|
|
|
return heap.allocate<ObjectSourceDirective>(move(name), move(value));
|
|
|
|
|
|
2024-12-03 15:33:32 +00:00
|
|
|
if (name == Names::ScriptSrcAttr)
|
|
|
|
|
return heap.allocate<ScriptSourceAttributeDirective>(move(name), move(value));
|
|
|
|
|
|
2024-12-02 16:01:19 +00:00
|
|
|
if (name == Names::ScriptSrc)
|
|
|
|
|
return heap.allocate<ScriptSourceDirective>(move(name), move(value));
|
|
|
|
|
|
2024-12-03 15:24:07 +00:00
|
|
|
if (name == Names::ScriptSrcElem)
|
|
|
|
|
return heap.allocate<ScriptSourceElementDirective>(move(name), move(value));
|
|
|
|
|
|
2024-12-03 17:27:12 +00:00
|
|
|
if (name == Names::StyleSrcAttr)
|
|
|
|
|
return heap.allocate<StyleSourceAttributeDirective>(move(name), move(value));
|
|
|
|
|
|
2024-12-03 16:57:18 +00:00
|
|
|
if (name == Names::StyleSrc)
|
|
|
|
|
return heap.allocate<StyleSourceDirective>(move(name), move(value));
|
|
|
|
|
|
2024-12-03 17:16:27 +00:00
|
|
|
if (name == Names::StyleSrcElem)
|
|
|
|
|
return heap.allocate<StyleSourceElementDirective>(move(name), move(value));
|
|
|
|
|
|
2024-12-03 17:54:51 +00:00
|
|
|
if (name == Names::WorkerSrc)
|
|
|
|
|
return heap.allocate<WorkerSourceDirective>(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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|