2020-06-17 15:31:42 +00:00
|
|
|
/*
|
2023-02-20 18:03:06 +00:00
|
|
|
* Copyright (c) 2020-2023, Andreas Kling <kling@serenityos.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
|
|
|
|
2023-03-16 12:50:22 +00:00
|
|
|
Function<void(WebDriverConnection&)> on_webdriver_connection;
|
2022-11-08 15:03:07 +00:00
|
|
|
|
2023-11-29 16:34:38 +00:00
|
|
|
PageClient& page(u64 index) { return *m_pages.find(index)->value; }
|
|
|
|
PageClient& create_page();
|
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
|
|
|
};
|
|
|
|
|
|
|
|
}
|