/* * Copyright (c) 2025, Idan Horowitz * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include namespace Web::CookieStore { // https://cookiestore.spec.whatwg.org/#dictdef-cookielistitem struct CookieListItem { Optional name; Optional value; }; // https://cookiestore.spec.whatwg.org/#dictdef-cookiestoregetoptions struct CookieStoreGetOptions { Optional name; Optional url; }; // https://cookiestore.spec.whatwg.org/#dictdef-cookieinit struct CookieInit { String name; String value; Optional expires; Optional domain; String path; Bindings::CookieSameSite same_site; bool partitioned { false }; }; // https://cookiestore.spec.whatwg.org/#dictdef-cookiestoredeleteoptions struct CookieStoreDeleteOptions { String name; Optional domain; String path; bool partitioned { false }; }; // https://cookiestore.spec.whatwg.org/#cookiestore class WEB_API CookieStore final : public DOM::EventTarget { WEB_PLATFORM_OBJECT(CookieStore, DOM::EventTarget); GC_DECLARE_ALLOCATOR(CookieStore); public: GC::Ref get(String name); GC::Ref get(CookieStoreGetOptions const&); GC::Ref get_all(String name); GC::Ref get_all(CookieStoreGetOptions const&); GC::Ref set(String name, String value); GC::Ref set(CookieInit const&); GC::Ref delete_(String name); GC::Ref delete_(CookieStoreDeleteOptions const&); void set_onchange(WebIDL::CallbackType*); WebIDL::CallbackType* onchange(); void process_cookie_changes(Vector const&); private: CookieStore(JS::Realm&, PageClient&); virtual void initialize(JS::Realm&) override; virtual void visit_edges(Cell::Visitor&) override; GC::Ref m_client; }; } namespace Web::Bindings { JS::Value cookie_list_item_to_value(JS::Realm&, CookieStore::CookieListItem const&); }