ladybird/Libraries/LibWeb/HTML/WorkerAgentParent.h
Luke Wilde 6d3fd2b543
Some checks are pending
CI / macOS, arm64, Sanitizer, Clang (push) Waiting to run
CI / Linux, x86_64, Fuzzers, Clang (push) Waiting to run
CI / Linux, x86_64, Sanitizer, GNU (push) Waiting to run
CI / Linux, x86_64, Sanitizer, Clang (push) Waiting to run
Package the js repl as a binary artifact / Linux, arm64 (push) Waiting to run
Package the js repl as a binary artifact / macOS, arm64 (push) Waiting to run
Package the js repl as a binary artifact / Linux, x86_64 (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
LibWeb: Implement cookie fetching for Workers
Allows formulas to update on Google Sheets, which uses a Worker to
update them and makes cookie authenticated requests, which was failing
before this commit.

This has the limitation that it has to proxy through the WebContent
process, but that's how the current infrastructure is, which is outside
the scope of this commit.
2025-09-09 15:28:38 +02:00

47 lines
1.4 KiB
C++

/*
* Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/Bindings/AgentType.h>
#include <LibWeb/Bindings/RequestPrototype.h>
#include <LibWeb/Bindings/WorkerPrototype.h>
#include <LibWeb/Forward.h>
#include <LibWeb/Worker/WebWorkerClient.h>
namespace Web::HTML {
struct WorkerOptions {
Bindings::WorkerType type { Bindings::WorkerType::Classic };
Bindings::RequestCredentials credentials { Bindings::RequestCredentials::SameOrigin };
String name { String {} };
};
// FIXME: Figure out a better naming convention for this type of parent/child process pattern.
class WorkerAgentParent : public JS::Cell {
GC_CELL(WorkerAgentParent, JS::Cell);
GC_DECLARE_ALLOCATOR(WorkerAgentParent);
protected:
WorkerAgentParent(URL::URL url, WorkerOptions const& options, GC::Ptr<MessagePort> outside_port, GC::Ref<EnvironmentSettingsObject> outside_settings, Bindings::AgentType);
virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
private:
void setup_worker_ipc_callbacks(JS::Realm&);
WorkerOptions m_worker_options;
Bindings::AgentType m_agent_type { Bindings::AgentType::DedicatedWorker };
URL::URL m_url;
GC::Ptr<MessagePort> m_message_port;
GC::Ptr<MessagePort> m_outside_port;
GC::Ref<EnvironmentSettingsObject> m_outside_settings;
RefPtr<Web::HTML::WebWorkerClient> m_worker_ipc;
};
}