2022-02-17 13:31:09 +01:00
/*
* Copyright ( c ) 2022 , Ben Abraham < ben . d . abraham @ gmail . com >
*
* SPDX - License - Identifier : BSD - 2 - Clause
*/
# pragma once
# include <AK/URL.h>
2022-10-08 17:32:03 -06:00
# include <LibWeb/Bindings/DedicatedWorkerExposedInterfaces.h>
2022-02-17 13:31:09 +01:00
# include <LibWeb/DOM/Document.h>
# include <LibWeb/Forward.h>
namespace Web : : HTML {
class WorkerEnvironmentSettingsObject final
2022-09-24 15:39:23 -06:00
: public EnvironmentSettingsObject {
JS_CELL ( WindowEnvironmentSettingsObject , EnvironmentSettingsObject ) ;
2022-02-17 13:31:09 +01:00
public :
2022-09-05 12:19:41 +02:00
WorkerEnvironmentSettingsObject ( NonnullOwnPtr < JS : : ExecutionContext > execution_context )
2022-08-04 21:30:33 +02:00
: EnvironmentSettingsObject ( move ( execution_context ) )
2022-02-17 13:31:09 +01:00
{
}
2022-09-24 15:39:23 -06:00
static JS : : NonnullGCPtr < WorkerEnvironmentSettingsObject > setup ( NonnullOwnPtr < JS : : ExecutionContext > execution_context /* FIXME: null or an environment reservedEnvironment, a URL topLevelCreationURL, and an origin topLevelOrigin */ )
2022-02-17 13:31:09 +01:00
{
2023-02-26 16:09:02 -07:00
auto realm = execution_context - > realm ;
2022-02-17 13:31:09 +01:00
VERIFY ( realm ) ;
2023-08-13 13:05:26 +02:00
auto settings_object = realm - > heap ( ) . allocate < WorkerEnvironmentSettingsObject > ( * realm , move ( execution_context ) ) ;
2022-02-17 13:31:09 +01:00
settings_object - > target_browsing_context = nullptr ;
2023-08-13 13:05:26 +02:00
auto intrinsics = realm - > heap ( ) . allocate < Bindings : : Intrinsics > ( * realm , * realm ) ;
2022-12-14 17:40:33 +00:00
auto host_defined = make < Bindings : : HostDefined > ( settings_object , intrinsics ) ;
2022-09-24 15:39:23 -06:00
realm - > set_host_defined ( move ( host_defined ) ) ;
2022-10-08 17:32:03 -06:00
// FIXME: Shared workers should use the shared worker method
2023-01-10 07:32:24 -05:00
Bindings : : add_dedicated_worker_exposed_interfaces ( realm - > global_object ( ) ) ;
2022-10-08 17:32:03 -06:00
2022-12-14 17:40:33 +00:00
return settings_object ;
2022-02-17 13:31:09 +01:00
}
virtual ~ WorkerEnvironmentSettingsObject ( ) override = default ;
2022-09-05 12:19:41 +02:00
JS : : GCPtr < DOM : : Document > responsible_document ( ) override { return nullptr ; }
2022-12-04 18:02:33 +00:00
DeprecatedString api_url_character_encoding ( ) override { return m_api_url_character_encoding ; }
2022-09-05 12:19:41 +02:00
AK : : URL api_base_url ( ) override { return m_url ; }
Origin origin ( ) override { return m_origin ; }
2022-10-13 18:22:11 +02:00
PolicyContainer policy_container ( ) override { return m_policy_container ; }
2022-02-17 13:31:09 +01:00
CanUseCrossOriginIsolatedAPIs cross_origin_isolated_capability ( ) override { TODO ( ) ; }
private :
2022-12-04 18:02:33 +00:00
DeprecatedString m_api_url_character_encoding ;
2022-09-05 12:19:41 +02:00
AK : : URL m_url ;
HTML : : Origin m_origin ;
2022-10-13 18:22:11 +02:00
HTML : : PolicyContainer m_policy_container ;
2022-02-17 13:31:09 +01:00
} ;
}