2020-06-17 15:31:42 +00:00
|
|
|
/*
|
2024-10-04 11:19:50 +00:00
|
|
|
* Copyright (c) 2020-2023, Andreas Kling <andreas@ladybird.org>
|
2023-01-12 14:34:12 +00:00
|
|
|
* Copyright (c) 2021-2023, Linus Groh <linusg@serenityos.org>
|
2023-11-29 16:34:38 +00:00
|
|
|
* Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org>
|
2020-06-17 15:31:42 +00:00
|
|
|
*
|
2021-04-22 08:24:48 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-06-17 15:31:42 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-12-01 20:17:31 +00:00
|
|
|
#include <AK/Function.h>
|
|
|
|
#include <AK/HashMap.h>
|
|
|
|
#include <AK/NonnullOwnPtr.h>
|
2023-12-04 08:40:33 +00:00
|
|
|
#include <LibJS/Heap/Handle.h>
|
2022-11-08 15:03:07 +00:00
|
|
|
#include <WebContent/Forward.h>
|
2020-06-17 15:31:42 +00:00
|
|
|
|
|
|
|
namespace WebContent {
|
|
|
|
|
2023-11-29 16:34:38 +00:00
|
|
|
class PageHost {
|
2020-06-17 15:31:42 +00:00
|
|
|
AK_MAKE_NONCOPYABLE(PageHost);
|
|
|
|
AK_MAKE_NONMOVABLE(PageHost);
|
|
|
|
|
|
|
|
public:
|
2022-02-25 10:18:30 +00:00
|
|
|
static NonnullOwnPtr<PageHost> create(ConnectionFromClient& client) { return adopt_own(*new PageHost(client)); }
|
2022-11-08 15:03:07 +00:00
|
|
|
virtual ~PageHost();
|
2020-06-17 15:31:42 +00:00
|
|
|
|
2024-02-13 00:39:20 +00:00
|
|
|
Optional<PageClient&> page(u64 index);
|
2023-11-29 16:34:38 +00:00
|
|
|
PageClient& create_page();
|
2024-02-03 01:00:48 +00:00
|
|
|
void remove_page(Badge<PageClient>, u64 index);
|
2023-05-15 15:17:58 +00:00
|
|
|
|
2023-11-29 16:34:38 +00:00
|
|
|
ConnectionFromClient& client() const { return m_client; }
|
2023-08-21 14:50:31 +00:00
|
|
|
|
2020-06-17 15:31:42 +00:00
|
|
|
private:
|
2022-02-25 10:18:30 +00:00
|
|
|
explicit PageHost(ConnectionFromClient&);
|
2020-06-17 15:31:42 +00:00
|
|
|
|
2022-02-25 10:18:30 +00:00
|
|
|
ConnectionFromClient& m_client;
|
2023-12-04 08:40:33 +00:00
|
|
|
HashMap<u64, JS::Handle<PageClient>> m_pages;
|
2023-11-29 16:34:38 +00:00
|
|
|
u64 m_next_id { 0 };
|
2020-06-17 15:31:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|