2020-06-17 18:31:42 +03:00
|
|
|
/*
|
2021-02-10 10:48:28 +03:00
|
|
|
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
|
2020-06-17 18:31:42 +03:00
|
|
|
*
|
2021-04-22 11:24:48 +03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-06-17 18:31:42 +03:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "WebContentClient.h"
|
2024-03-27 20:53:07 +03:00
|
|
|
#include "ProcessManager.h"
|
2023-05-20 17:52:02 +03:00
|
|
|
#include "ViewImplementation.h"
|
2021-04-15 17:36:20 +03:00
|
|
|
#include <LibWeb/Cookie/ParsedCookie.h>
|
2020-06-17 18:31:42 +03:00
|
|
|
|
2022-04-30 11:46:33 +03:00
|
|
|
namespace WebView {
|
2020-08-24 14:03:18 +03:00
|
|
|
|
2023-02-09 01:05:44 +03:00
|
|
|
WebContentClient::WebContentClient(NonnullOwnPtr<Core::LocalSocket> socket, ViewImplementation& view)
|
2022-02-25 13:27:37 +03:00
|
|
|
: IPC::ConnectionToServer<WebContentClientEndpoint, WebContentServerEndpoint>(*this, move(socket))
|
2020-06-17 18:31:42 +03:00
|
|
|
{
|
2024-02-03 04:00:48 +03:00
|
|
|
m_views.set(0, &view);
|
2020-06-17 18:31:42 +03:00
|
|
|
}
|
|
|
|
|
2021-01-30 20:20:40 +03:00
|
|
|
void WebContentClient::die()
|
|
|
|
{
|
2021-02-23 22:42:32 +03:00
|
|
|
VERIFY(on_web_content_process_crash);
|
2021-01-30 20:20:40 +03:00
|
|
|
on_web_content_process_crash();
|
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::register_view(u64 page_id, ViewImplementation& view)
|
2020-06-17 18:31:42 +03:00
|
|
|
{
|
2024-02-03 04:00:48 +03:00
|
|
|
VERIFY(page_id > 0);
|
|
|
|
m_views.set(page_id, &view);
|
2020-06-17 18:31:42 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::unregister_view(u64 page_id)
|
2023-05-17 19:37:31 +03:00
|
|
|
{
|
2024-02-03 04:00:48 +03:00
|
|
|
m_views.remove(page_id);
|
|
|
|
}
|
2023-05-17 19:37:31 +03:00
|
|
|
|
2024-03-27 20:53:07 +03:00
|
|
|
void WebContentClient::notify_process_information(WebView::ProcessHandle const& handle)
|
|
|
|
{
|
|
|
|
dbgln_if(SPAM_DEBUG, "handle: WebContentClient::NotifyProcessInformation! pid={}", handle.pid);
|
|
|
|
ProcessManager::the().add_process(ProcessType::WebContent, handle.pid);
|
2024-04-22 21:11:46 +03:00
|
|
|
m_process_handle = handle;
|
2024-03-27 20:53:07 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_paint(u64 page_id, Gfx::IntRect const& rect, i32 bitmap_id)
|
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value())
|
|
|
|
view->server_did_paint({}, bitmap_id, rect.size());
|
2023-05-17 19:37:31 +03:00
|
|
|
}
|
|
|
|
|
2024-03-18 06:22:27 +03:00
|
|
|
void WebContentClient::did_start_loading(u64 page_id, URL::URL const& url, bool is_redirect)
|
2020-06-17 18:31:42 +03:00
|
|
|
{
|
2024-04-22 21:11:46 +03:00
|
|
|
if (auto* process = WebView::ProcessManager::the().find_process(m_process_handle.pid))
|
|
|
|
process->title.clear();
|
|
|
|
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
view->set_url({}, url);
|
2023-05-17 19:37:31 +03:00
|
|
|
|
2024-03-29 16:44:49 +03:00
|
|
|
if (view->on_load_start)
|
|
|
|
view->on_load_start(url, is_redirect);
|
|
|
|
}
|
2020-06-17 18:31:42 +03:00
|
|
|
}
|
2020-06-17 19:00:18 +03:00
|
|
|
|
2024-03-18 06:22:27 +03:00
|
|
|
void WebContentClient::did_finish_loading(u64 page_id, URL::URL const& url)
|
2023-09-14 20:17:32 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
view->set_url({}, url);
|
2024-02-03 04:00:48 +03:00
|
|
|
|
2024-03-29 16:44:49 +03:00
|
|
|
if (view->on_load_finish)
|
|
|
|
view->on_load_finish(url);
|
|
|
|
}
|
2023-09-14 20:17:32 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_finish_text_test(u64 page_id)
|
2022-11-11 21:33:11 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_text_test_finish)
|
|
|
|
view->on_text_test_finish();
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-06-09 20:35:32 +03:00
|
|
|
void WebContentClient::did_find_in_page(u64 page_id, size_t current_match_index, Optional<size_t> const& total_match_count)
|
|
|
|
{
|
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_find_in_page)
|
|
|
|
view->on_find_in_page(current_match_index, total_match_count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_request_navigate_back(u64 page_id)
|
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_navigate_back)
|
|
|
|
view->on_navigate_back();
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2022-11-11 21:33:11 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_request_navigate_forward(u64 page_id)
|
2022-11-11 21:33:11 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_navigate_forward)
|
|
|
|
view->on_navigate_forward();
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2022-11-11 21:33:11 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_request_refresh(u64 page_id)
|
2022-11-11 21:33:11 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_refresh)
|
|
|
|
view->on_refresh();
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2022-11-11 21:33:11 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_request_cursor_change(u64 page_id, i32 cursor_type)
|
2021-02-28 00:12:12 +03:00
|
|
|
{
|
2021-05-02 20:54:34 +03:00
|
|
|
if (cursor_type < 0 || cursor_type >= (i32)Gfx::StandardCursor::__Count) {
|
2021-02-28 00:12:12 +03:00
|
|
|
dbgln("DidRequestCursorChange: Bad cursor type");
|
|
|
|
return;
|
|
|
|
}
|
2023-08-23 17:43:27 +03:00
|
|
|
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_cursor_change)
|
|
|
|
view->on_cursor_change(static_cast<Gfx::StandardCursor>(cursor_type));
|
|
|
|
}
|
2021-02-28 00:12:12 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_layout(u64 page_id, Gfx::IntSize content_size)
|
2020-07-05 00:19:32 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_did_layout)
|
|
|
|
view->on_did_layout(content_size);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2020-07-05 00:19:32 +03:00
|
|
|
}
|
2020-07-05 00:40:17 +03:00
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_change_title(u64 page_id, ByteString const& title)
|
2020-07-05 00:40:17 +03:00
|
|
|
{
|
2024-04-22 21:11:46 +03:00
|
|
|
if (auto* process = WebView::ProcessManager::the().find_process(m_process_handle.pid))
|
|
|
|
process->title = MUST(String::from_byte_string(title));
|
|
|
|
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (!view->on_title_change)
|
|
|
|
return;
|
2023-06-07 23:37:30 +03:00
|
|
|
|
2024-03-29 16:44:49 +03:00
|
|
|
if (title.is_empty())
|
|
|
|
view->on_title_change(view->url().to_byte_string());
|
|
|
|
else
|
|
|
|
view->on_title_change(title);
|
|
|
|
}
|
2020-07-05 00:40:17 +03:00
|
|
|
}
|
2020-07-05 16:43:43 +03:00
|
|
|
|
2024-04-14 11:27:20 +03:00
|
|
|
void WebContentClient::did_change_url(u64 page_id, URL::URL const& url)
|
|
|
|
{
|
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
2024-04-14 23:59:59 +03:00
|
|
|
view->set_url({}, url);
|
|
|
|
|
2024-04-14 11:27:20 +03:00
|
|
|
if (view->on_url_change)
|
|
|
|
view->on_url_change(url);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_enter_tooltip_area(u64 page_id, Gfx::IntPoint content_position, ByteString const& title)
|
2021-03-30 19:10:06 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_enter_tooltip_area)
|
|
|
|
view->on_enter_tooltip_area(view->to_widget_position(content_position), title);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2021-03-30 19:10:06 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_leave_tooltip_area(u64 page_id)
|
2021-03-30 19:10:06 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_leave_tooltip_area)
|
|
|
|
view->on_leave_tooltip_area();
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2021-03-30 19:10:06 +03:00
|
|
|
}
|
|
|
|
|
2024-03-18 06:22:27 +03:00
|
|
|
void WebContentClient::did_hover_link(u64 page_id, URL::URL const& url)
|
2020-07-05 17:59:20 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_link_hover)
|
|
|
|
view->on_link_hover(url);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2020-07-05 17:59:20 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_unhover_link(u64 page_id)
|
2020-07-05 17:59:20 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_link_unhover)
|
|
|
|
view->on_link_unhover();
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2020-07-05 17:59:20 +03:00
|
|
|
}
|
2020-07-06 21:01:46 +03:00
|
|
|
|
2024-03-18 06:22:27 +03:00
|
|
|
void WebContentClient::did_click_link(u64 page_id, URL::URL const& url, ByteString const& target, unsigned modifiers)
|
2020-07-06 21:01:46 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_link_click)
|
|
|
|
view->on_link_click(url, target, modifiers);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2020-07-06 21:01:46 +03:00
|
|
|
}
|
|
|
|
|
2024-03-18 06:22:27 +03:00
|
|
|
void WebContentClient::did_middle_click_link(u64 page_id, URL::URL const& url, ByteString const& target, unsigned modifiers)
|
2020-07-06 21:01:46 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_link_middle_click)
|
|
|
|
view->on_link_middle_click(url, target, modifiers);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2020-07-06 22:58:16 +03:00
|
|
|
}
|
2020-07-07 13:24:29 +03:00
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_request_context_menu(u64 page_id, Gfx::IntPoint content_position)
|
2020-07-07 13:24:29 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_context_menu_request)
|
|
|
|
view->on_context_menu_request(view->to_widget_position(content_position));
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2020-07-07 13:24:29 +03:00
|
|
|
}
|
|
|
|
|
2024-03-18 06:22:27 +03:00
|
|
|
void WebContentClient::did_request_link_context_menu(u64 page_id, Gfx::IntPoint content_position, URL::URL const& url, ByteString const&, unsigned)
|
2020-07-07 13:24:29 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_link_context_menu_request)
|
|
|
|
view->on_link_context_menu_request(url, view->to_widget_position(content_position));
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2020-07-07 13:24:29 +03:00
|
|
|
}
|
2020-08-24 14:03:18 +03:00
|
|
|
|
2024-03-18 06:22:27 +03:00
|
|
|
void WebContentClient::did_request_image_context_menu(u64 page_id, Gfx::IntPoint content_position, URL::URL const& url, ByteString const&, unsigned, Gfx::ShareableBitmap const& bitmap)
|
2021-04-11 17:49:25 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_image_context_menu_request)
|
|
|
|
view->on_image_context_menu_request(url, view->to_widget_position(content_position), bitmap);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2021-04-11 17:49:25 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_request_media_context_menu(u64 page_id, Gfx::IntPoint content_position, ByteString const&, unsigned, Web::Page::MediaContextMenu const& menu)
|
2023-05-15 16:42:56 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_media_context_menu_request)
|
|
|
|
view->on_media_context_menu_request(view->to_widget_position(content_position), menu);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2023-05-15 16:42:56 +03:00
|
|
|
}
|
|
|
|
|
2024-03-18 06:22:27 +03:00
|
|
|
void WebContentClient::did_get_source(u64 page_id, URL::URL const& url, ByteString const& source)
|
2021-02-23 15:17:23 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_received_source)
|
|
|
|
view->on_received_source(url, source);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2021-02-23 15:17:23 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_inspect_dom_tree(u64 page_id, ByteString const& dom_tree)
|
2021-06-07 18:35:10 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_received_dom_tree)
|
|
|
|
view->on_received_dom_tree(dom_tree);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2021-06-07 18:35:10 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_inspect_dom_node(u64 page_id, bool has_style, ByteString const& computed_style, ByteString const& resolved_style, ByteString const& custom_properties, ByteString const& node_box_sizing, ByteString const& aria_properties_state)
|
2023-12-30 17:30:27 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
auto view = view_for_page_id(page_id);
|
|
|
|
if (!view.has_value() || !view->on_received_dom_node_properties)
|
2023-12-30 17:30:27 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
Optional<ViewImplementation::DOMNodeProperties> properties;
|
|
|
|
|
|
|
|
if (has_style) {
|
|
|
|
properties = ViewImplementation::DOMNodeProperties {
|
|
|
|
.computed_style_json = MUST(String::from_byte_string(computed_style)),
|
|
|
|
.resolved_style_json = MUST(String::from_byte_string(resolved_style)),
|
|
|
|
.custom_properties_json = MUST(String::from_byte_string(custom_properties)),
|
|
|
|
.node_box_sizing_json = MUST(String::from_byte_string(node_box_sizing)),
|
|
|
|
.aria_properties_state_json = MUST(String::from_byte_string(aria_properties_state)),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2024-03-29 16:44:49 +03:00
|
|
|
view->on_received_dom_node_properties(move(properties));
|
2023-12-30 17:30:27 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_inspect_accessibility_tree(u64 page_id, ByteString const& accessibility_tree)
|
2023-05-17 19:37:31 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_received_accessibility_tree)
|
|
|
|
view->on_received_accessibility_tree(accessibility_tree);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2021-08-27 14:47:30 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_get_hovered_node_id(u64 page_id, i32 node_id)
|
2023-12-30 17:42:24 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_received_hovered_node_id)
|
|
|
|
view->on_received_hovered_node_id(node_id);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2023-12-30 17:42:24 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_finish_editing_dom_node(u64 page_id, Optional<i32> const& node_id)
|
2023-12-30 18:08:33 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_finshed_editing_dom_node)
|
|
|
|
view->on_finshed_editing_dom_node(node_id);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2023-12-30 18:08:33 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_get_dom_node_html(u64 page_id, String const& html)
|
2023-12-30 22:32:50 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_received_dom_node_html)
|
|
|
|
view->on_received_dom_node_html(html);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2023-12-30 22:32:50 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_take_screenshot(u64 page_id, Gfx::ShareableBitmap const& screenshot)
|
2023-12-31 17:51:02 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value())
|
|
|
|
view->did_receive_screenshot({}, screenshot);
|
2023-12-31 17:51:02 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_output_js_console_message(u64 page_id, i32 message_index)
|
2021-09-04 13:14:25 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_received_console_message)
|
|
|
|
view->on_received_console_message(message_index);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2021-09-04 13:14:25 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_get_js_console_messages(u64 page_id, i32 start_index, Vector<ByteString> const& message_types, Vector<ByteString> const& messages)
|
2021-09-04 13:14:25 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_received_console_messages)
|
|
|
|
view->on_received_console_messages(start_index, message_types, messages);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2021-09-04 13:14:25 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_request_alert(u64 page_id, String const& message)
|
2020-09-12 12:56:13 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_request_alert)
|
|
|
|
view->on_request_alert(message);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2020-09-12 12:56:13 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_request_confirm(u64 page_id, String const& message)
|
2021-02-10 10:48:28 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_request_confirm)
|
|
|
|
view->on_request_confirm(message);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2021-02-10 10:48:28 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_request_prompt(u64 page_id, String const& message, String const& default_)
|
2021-02-20 14:05:18 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_request_prompt)
|
|
|
|
view->on_request_prompt(message, default_);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2021-02-20 14:05:18 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_request_set_prompt_text(u64 page_id, String const& message)
|
2022-11-16 16:57:05 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_request_set_prompt_text)
|
|
|
|
view->on_request_set_prompt_text(message);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2022-11-16 16:57:05 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_request_accept_dialog(u64 page_id)
|
2022-11-16 14:58:14 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_request_accept_dialog)
|
|
|
|
view->on_request_accept_dialog();
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2022-11-16 14:58:14 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_request_dismiss_dialog(u64 page_id)
|
2022-11-16 14:58:14 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_request_dismiss_dialog)
|
|
|
|
view->on_request_dismiss_dialog();
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2022-11-16 14:58:14 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_change_favicon(u64 page_id, Gfx::ShareableBitmap const& favicon)
|
2021-03-26 17:41:25 +03:00
|
|
|
{
|
2021-05-02 20:54:34 +03:00
|
|
|
if (!favicon.is_valid()) {
|
2021-03-26 17:41:25 +03:00
|
|
|
dbgln("DidChangeFavicon: Received invalid favicon");
|
|
|
|
return;
|
|
|
|
}
|
2023-05-17 19:37:31 +03:00
|
|
|
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_favicon_change)
|
|
|
|
view->on_favicon_change(*favicon.bitmap());
|
|
|
|
}
|
2021-03-26 17:41:25 +03:00
|
|
|
}
|
|
|
|
|
2024-03-18 06:22:27 +03:00
|
|
|
Messages::WebContentClient::DidRequestAllCookiesResponse WebContentClient::did_request_all_cookies(u64 page_id, URL::URL const& url)
|
2022-11-11 17:23:24 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_get_all_cookies)
|
|
|
|
return view->on_get_all_cookies(url);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
|
|
|
|
2023-05-17 19:37:31 +03:00
|
|
|
return Vector<Web::Cookie::Cookie> {};
|
2022-11-11 17:23:24 +03:00
|
|
|
}
|
|
|
|
|
2024-03-18 06:22:27 +03:00
|
|
|
Messages::WebContentClient::DidRequestNamedCookieResponse WebContentClient::did_request_named_cookie(u64 page_id, URL::URL const& url, String const& name)
|
2022-11-11 17:46:56 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_get_named_cookie)
|
|
|
|
return view->on_get_named_cookie(url, name);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
|
|
|
|
2023-05-17 19:37:31 +03:00
|
|
|
return OptionalNone {};
|
2022-11-11 17:46:56 +03:00
|
|
|
}
|
|
|
|
|
2024-03-18 06:22:27 +03:00
|
|
|
Messages::WebContentClient::DidRequestCookieResponse WebContentClient::did_request_cookie(u64 page_id, URL::URL const& url, Web::Cookie::Source source)
|
2021-04-11 17:54:11 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_get_cookie)
|
|
|
|
return view->on_get_cookie(url, source);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
|
|
|
|
2024-01-26 19:10:15 +03:00
|
|
|
return String {};
|
2021-04-11 17:54:11 +03:00
|
|
|
}
|
|
|
|
|
2024-03-18 06:22:27 +03:00
|
|
|
void WebContentClient::did_set_cookie(u64 page_id, URL::URL const& url, Web::Cookie::ParsedCookie const& cookie, Web::Cookie::Source source)
|
2021-04-11 17:54:11 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_set_cookie)
|
|
|
|
view->on_set_cookie(url, cookie, source);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2021-04-11 17:54:11 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_update_cookie(u64 page_id, Web::Cookie::Cookie const& cookie)
|
2022-11-11 19:18:40 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_update_cookie)
|
|
|
|
view->on_update_cookie(cookie);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2022-11-11 19:18:40 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
Messages::WebContentClient::DidRequestNewWebViewResponse WebContentClient::did_request_new_web_view(u64 page_id, Web::HTML::ActivateTab const& activate_tab, Web::HTML::WebViewHints const& hints, Optional<u64> const& page_index)
|
2023-03-14 17:12:09 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_new_web_view)
|
|
|
|
return view->on_new_web_view(activate_tab, hints, page_index);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
|
|
|
|
2023-05-17 19:37:31 +03:00
|
|
|
return String {};
|
2023-03-14 17:12:09 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_request_activate_tab(u64 page_id)
|
2023-03-21 02:52:00 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_activate_tab)
|
|
|
|
view->on_activate_tab();
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2023-03-21 02:52:00 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_close_browsing_context(u64 page_id)
|
2023-03-07 06:10:26 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_close)
|
|
|
|
view->on_close();
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2023-03-07 06:10:26 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_update_resource_count(u64 page_id, i32 count_waiting)
|
2022-02-21 01:03:39 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_resource_status_change)
|
|
|
|
view->on_resource_status_change(count_waiting);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2022-02-21 01:03:39 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_request_restore_window(u64 page_id)
|
2022-11-09 17:51:39 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_restore_window)
|
|
|
|
view->on_restore_window();
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2022-11-09 17:51:39 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
Messages::WebContentClient::DidRequestRepositionWindowResponse WebContentClient::did_request_reposition_window(u64 page_id, Gfx::IntPoint position)
|
2022-11-09 17:51:39 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_reposition_window)
|
|
|
|
return view->on_reposition_window(position);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
|
|
|
|
2023-05-17 19:37:31 +03:00
|
|
|
return Gfx::IntPoint {};
|
2022-11-09 17:51:39 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
Messages::WebContentClient::DidRequestResizeWindowResponse WebContentClient::did_request_resize_window(u64 page_id, Gfx::IntSize size)
|
2022-11-09 17:51:39 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_resize_window)
|
|
|
|
return view->on_resize_window(size);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
|
|
|
|
2023-05-17 19:37:31 +03:00
|
|
|
return Gfx::IntSize {};
|
2022-11-09 17:51:39 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
Messages::WebContentClient::DidRequestMaximizeWindowResponse WebContentClient::did_request_maximize_window(u64 page_id)
|
2022-11-09 18:04:09 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_maximize_window)
|
|
|
|
return view->on_maximize_window();
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
|
|
|
|
2023-05-17 19:37:31 +03:00
|
|
|
return Gfx::IntRect {};
|
2022-11-09 18:04:09 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
Messages::WebContentClient::DidRequestMinimizeWindowResponse WebContentClient::did_request_minimize_window(u64 page_id)
|
2022-11-09 18:04:09 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_minimize_window)
|
|
|
|
return view->on_minimize_window();
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
|
|
|
|
2023-05-17 19:37:31 +03:00
|
|
|
return Gfx::IntRect {};
|
2022-11-09 18:04:09 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
Messages::WebContentClient::DidRequestFullscreenWindowResponse WebContentClient::did_request_fullscreen_window(u64 page_id)
|
2022-11-09 21:09:17 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_fullscreen_window)
|
|
|
|
return view->on_fullscreen_window();
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
|
|
|
|
2023-05-17 19:37:31 +03:00
|
|
|
return Gfx::IntRect {};
|
2022-11-09 21:09:17 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_request_file(u64 page_id, ByteString const& path, i32 request_id)
|
2022-02-26 19:50:31 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_request_file)
|
|
|
|
view->on_request_file(path, request_id);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2022-02-26 19:50:31 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_request_color_picker(u64 page_id, Color const& current_color)
|
2023-09-04 12:32:40 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_request_color_picker)
|
|
|
|
view->on_request_color_picker(current_color);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2023-09-04 12:32:40 +03:00
|
|
|
}
|
|
|
|
|
2024-03-14 19:26:00 +03:00
|
|
|
void WebContentClient::did_request_file_picker(u64 page_id, Web::HTML::FileFilter const& accepted_file_types, Web::HTML::AllowMultipleFiles allow_multiple_files)
|
2024-02-25 21:02:47 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_request_file_picker)
|
|
|
|
view->on_request_file_picker(accepted_file_types, allow_multiple_files);
|
2024-02-25 21:02:47 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_request_select_dropdown(u64 page_id, Gfx::IntPoint content_position, i32 minimum_width, Vector<Web::HTML::SelectItem> const& items)
|
2023-12-07 17:53:49 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_request_select_dropdown)
|
|
|
|
view->on_request_select_dropdown(content_position, minimum_width, items);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2023-12-07 17:53:49 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_finish_handling_input_event(u64 page_id, bool event_was_accepted)
|
2022-11-21 19:07:47 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value())
|
|
|
|
view->did_finish_handling_input_event({}, event_was_accepted);
|
2022-11-21 19:07:47 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_change_theme_color(u64 page_id, Gfx::Color color)
|
2023-09-19 02:51:48 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_theme_color_change)
|
|
|
|
view->on_theme_color_change(color);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2023-09-19 02:51:48 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::did_insert_clipboard_entry(u64 page_id, String const& data, String const& presentation_style, String const& mime_type)
|
2023-11-10 21:35:41 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_insert_clipboard_entry)
|
|
|
|
view->on_insert_clipboard_entry(data, presentation_style, mime_type);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2023-11-10 21:35:41 +03:00
|
|
|
}
|
|
|
|
|
2024-03-27 02:27:06 +03:00
|
|
|
void WebContentClient::did_change_audio_play_state(u64 page_id, Web::HTML::AudioPlayState play_state)
|
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value())
|
|
|
|
view->did_change_audio_play_state({}, play_state);
|
2024-03-27 02:27:06 +03:00
|
|
|
}
|
|
|
|
|
2024-04-14 00:12:55 +03:00
|
|
|
void WebContentClient::did_update_navigation_buttons_state(u64 page_id, bool back_enabled, bool forward_enabled)
|
|
|
|
{
|
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value())
|
|
|
|
view->did_update_navigation_buttons_state({}, back_enabled, forward_enabled);
|
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::inspector_did_load(u64 page_id)
|
2023-11-23 20:22:23 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_inspector_loaded)
|
|
|
|
view->on_inspector_loaded();
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2023-11-23 20:22:23 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::inspector_did_select_dom_node(u64 page_id, i32 node_id, Optional<Web::CSS::Selector::PseudoElement::Type> const& pseudo_element)
|
2023-11-23 20:22:23 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_inspector_selected_dom_node)
|
|
|
|
view->on_inspector_selected_dom_node(node_id, pseudo_element);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2023-11-23 20:22:23 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::inspector_did_set_dom_node_text(u64 page_id, i32 node_id, String const& text)
|
2023-12-03 19:49:08 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_inspector_set_dom_node_text)
|
|
|
|
view->on_inspector_set_dom_node_text(node_id, text);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2023-12-03 19:49:08 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::inspector_did_set_dom_node_tag(u64 page_id, i32 node_id, String const& tag)
|
2023-12-03 19:49:08 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_inspector_set_dom_node_tag)
|
|
|
|
view->on_inspector_set_dom_node_tag(node_id, tag);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2023-12-03 19:49:08 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::inspector_did_add_dom_node_attributes(u64 page_id, i32 node_id, Vector<Attribute> const& attributes)
|
2023-12-06 00:43:14 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_inspector_added_dom_node_attributes)
|
|
|
|
view->on_inspector_added_dom_node_attributes(node_id, attributes);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2023-12-06 00:43:14 +03:00
|
|
|
}
|
|
|
|
|
2024-02-18 21:59:28 +03:00
|
|
|
void WebContentClient::inspector_did_replace_dom_node_attribute(u64 page_id, i32 node_id, size_t attribute_index, Vector<Attribute> const& replacement_attributes)
|
2023-12-03 19:49:08 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_inspector_replaced_dom_node_attribute)
|
|
|
|
view->on_inspector_replaced_dom_node_attribute(node_id, attribute_index, replacement_attributes);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2023-12-03 19:49:08 +03:00
|
|
|
}
|
|
|
|
|
2024-02-18 21:59:28 +03:00
|
|
|
void WebContentClient::inspector_did_request_dom_tree_context_menu(u64 page_id, i32 node_id, Gfx::IntPoint position, String const& type, Optional<String> const& tag, Optional<size_t> const& attribute_index)
|
2023-12-05 22:47:56 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_inspector_requested_dom_tree_context_menu)
|
|
|
|
view->on_inspector_requested_dom_tree_context_menu(node_id, view->to_widget_position(position), type, tag, attribute_index);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2023-12-05 22:47:56 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
void WebContentClient::inspector_did_execute_console_script(u64 page_id, String const& script)
|
2023-12-01 03:27:32 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_inspector_executed_console_script)
|
|
|
|
view->on_inspector_executed_console_script(script);
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
2023-12-01 03:27:32 +03:00
|
|
|
}
|
|
|
|
|
2024-02-03 04:00:48 +03:00
|
|
|
Messages::WebContentClient::RequestWorkerAgentResponse WebContentClient::request_worker_agent(u64 page_id)
|
2024-01-06 23:13:59 +03:00
|
|
|
{
|
2024-03-29 16:44:49 +03:00
|
|
|
if (auto view = view_for_page_id(page_id); view.has_value()) {
|
|
|
|
if (view->on_request_worker_agent)
|
|
|
|
return view->on_request_worker_agent();
|
2024-02-03 04:00:48 +03:00
|
|
|
}
|
|
|
|
|
2024-04-18 03:44:39 +03:00
|
|
|
return IPC::File {};
|
2024-03-29 16:44:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
Optional<ViewImplementation&> WebContentClient::view_for_page_id(u64 page_id, SourceLocation location)
|
|
|
|
{
|
|
|
|
if (auto view = m_views.get(page_id); view.has_value())
|
|
|
|
return *view.value();
|
2024-01-06 23:13:59 +03:00
|
|
|
|
2024-03-29 16:44:49 +03:00
|
|
|
dbgln("WebContentClient::{}: Did not find a page with ID {}", location.function_name(), page_id);
|
|
|
|
return {};
|
2024-01-06 23:13:59 +03:00
|
|
|
}
|
|
|
|
|
2020-08-24 14:03:18 +03:00
|
|
|
}
|