ladybird/Libraries/LibWeb/HTML/EmbedderPolicy.h
Luke Wilde cae0ab2139 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.
2025-02-21 12:43:48 +00:00

56 lines
1.8 KiB
C++

/*
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
* Copyright (c) 2025, Luke Wilde <luke@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Optional.h>
#include <AK/String.h>
#include <AK/StringView.h>
#include <LibIPC/Forward.h>
namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/browsers.html#embedder-policy-value
enum class EmbedderPolicyValue {
UnsafeNone,
RequireCorp,
Credentialless,
};
StringView embedder_policy_value_to_string(EmbedderPolicyValue);
Optional<EmbedderPolicyValue> embedder_policy_value_from_string(StringView);
// https://html.spec.whatwg.org/multipage/browsers.html#embedder-policy
struct EmbedderPolicy {
// https://html.spec.whatwg.org/multipage/browsers.html#embedder-policy-value-2
// A value, which is an embedder policy value, initially "unsafe-none".
EmbedderPolicyValue value { EmbedderPolicyValue::UnsafeNone };
// https://html.spec.whatwg.org/multipage/browsers.html#embedder-policy-reporting-endpoint
// A reporting endpoint string, initially the empty string.
String reporting_endpoint;
// https://html.spec.whatwg.org/multipage/browsers.html#embedder-policy-report-only-value
// A report only value, which is an embedder policy value, initially "unsafe-none".
EmbedderPolicyValue report_only_value { EmbedderPolicyValue::UnsafeNone };
// https://html.spec.whatwg.org/multipage/browsers.html#embedder-policy-report-only-reporting-endpoint
// A report only reporting endpoint string, initially the empty string.
String report_only_reporting_endpoint;
};
}
namespace IPC {
template<>
ErrorOr<void> encode(Encoder&, Web::HTML::EmbedderPolicy const&);
template<>
ErrorOr<Web::HTML::EmbedderPolicy> decode(Decoder&);
}