dymokomi/luce-browser-engine
Source of release 0.6.1
0.6.1 / src / web / content_security_policy / directives / web_rtc_directive.lucb
#==============================================================================================
#
# web_rtc_directive - ContentSecurityPolicy::Directives::WebRTCDirective
# (the webrtc directive): its WebRTC pre-connect check
#
# DESCRIPTION:
# Port of Libraries/LibWeb/ContentSecurityPolicy/Directives/WebRTCDirective.cpp
# (lines 1-31).
#
# Copyright (c) 2024, Luke Wilde <luke@ladybird.org>
# SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================
## Ported from Libraries/LibWeb/ContentSecurityPolicy/Directives/WebRTCDirective.cpp:14 Web::ContentSecurityPolicy::Directives::WebRTCDirective::WebRTCDirective.
func content_security_policy_web_rtc_directive_construct(this: ContentSecurityPolicyWebRtcDirective*, name: ak.String, value: ak.Vector[ak.String]):
content_security_policy_directive_construct(this.content_security_policy_directive(), name, value)
## Ported from Libraries/LibWeb/ContentSecurityPolicy/Directives/WebRTCDirective.cpp:20 Web::ContentSecurityPolicy::Directives::WebRTCDirective::webrtc_pre_connect_check (override).
# https://w3c.github.io/webappsec-csp/#webrtc-pre-connect
pub func content_security_policy_web_rtc_directive_webrtc_pre_connect_check_impl(base: ContentSecurityPolicyDirective*, arg0: ContentSecurityPolicyPolicy*) -> ContentSecurityPolicyResult:
# 1. If this directive’s value contains a single item which is an ASCII case-insensitive match for the string
# "'allow'", return "Allowed".
if ak.vector_size(&base.m_value) == 1 and ak.string_equals_ignoring_ascii_case_string_view(ak.vector_first(&base.m_value), ak.sv("'allow'")):
return ContentSecurityPolicyResult.allowed
# 2. Return "Blocked".
return ContentSecurityPolicyResult.blocked