/* * Copyright (c) 2025, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include namespace Web::HTML { #define ENUMERATE_SHARED_WORKER_GLOBAL_SCOPE_EVENT_HANDLERS(E) \ E(onconnect, HTML::EventNames::connect) class SharedWorkerGlobalScope : public WorkerGlobalScope , public Bindings::SharedWorkerGlobalScopeGlobalMixin { WEB_PLATFORM_OBJECT(SharedWorkerGlobalScope, WorkerGlobalScope); GC_DECLARE_ALLOCATOR(SharedWorkerGlobalScope); public: virtual ~SharedWorkerGlobalScope() override; void set_constructor_origin(URL::Origin origin) { m_constructor_origin = move(origin); } URL::Origin const& constructor_origin() const { return m_constructor_origin.value(); } void set_constructor_url(URL::URL url) { m_constructor_url = move(url); } URL::URL const& constructor_url() const { return m_constructor_url; } Fetch::Infrastructure::Request::CredentialsMode credentials() const { return m_credentials; } void set_credentials(Fetch::Infrastructure::Request::CredentialsMode credentials) { m_credentials = credentials; } void close(); #define __ENUMERATE(attribute_name, event_name) \ void set_##attribute_name(WebIDL::CallbackType*); \ WebIDL::CallbackType* attribute_name(); ENUMERATE_SHARED_WORKER_GLOBAL_SCOPE_EVENT_HANDLERS(__ENUMERATE) #undef __ENUMERATE private: SharedWorkerGlobalScope(JS::Realm&, GC::Ref); virtual void initialize_web_interfaces_impl() override; virtual void finalize() override; Optional m_constructor_origin; URL::URL m_constructor_url; Fetch::Infrastructure::Request::CredentialsMode m_credentials; }; HashTable>& all_shared_worker_global_scopes(); }