Skip to content

Truly independent web browser

1.9 KB
Raw Blame
/*
 * Copyright (c) 2024, Jamie Mansfield <[email protected]>
 * Copyright (c) 2025, Luke Wilde <[email protected]>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/Optional.h>
#include <AK/Utf16String.h>
#include <AK/Utf16View.h>
#include <LibHTTP/Forward.h>
#include <LibIPC/Forward.h>
#include <LibWebCommon/Export.h>

namespace Web::HTML {

// https://html.spec.whatwg.org/multipage/browsers.html#embedder-policy-value
enum class EmbedderPolicyValue : u8 {
    UnsafeNone,
    RequireCorp,
    Credentialless,
};

WEBCOMMON_API bool is_compatible_with_cross_origin_isolation(EmbedderPolicyValue);

// 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-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-reporting-endpoint
    // A reporting endpoint string, initially the empty string.
    Utf16String reporting_endpoint;

    // https://html.spec.whatwg.org/multipage/browsers.html#embedder-policy-report-only-reporting-endpoint
    // A report only reporting endpoint string, initially the empty string.
    Utf16String report_only_reporting_endpoint;
};

WEBCOMMON_API EmbedderPolicy obtain_an_embedder_policy(HTTP::HeaderList const&, bool environment_is_a_non_secure_context);

}

namespace IPC {

template<>
WEBCOMMON_API ErrorOr<void> encode(Encoder&, Web::HTML::EmbedderPolicy const&);

template<>
WEBCOMMON_API ErrorOr<Web::HTML::EmbedderPolicy> decode(Decoder&);

}