| 
									
										
										
										
											2020-06-17 17:31:42 +02:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2024-10-04 13:19:50 +02:00
										 |  |  |  * Copyright (c) 2020-2021, Andreas Kling <andreas@ladybird.org> | 
					
						
							| 
									
										
										
										
											2020-06-17 17:31:42 +02:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2021-04-22 01:24:48 -07:00
										 |  |  |  * SPDX-License-Identifier: BSD-2-Clause | 
					
						
							| 
									
										
										
										
											2020-06-17 17:31:42 +02:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-04-15 10:36:20 -04:00
										 |  |  | #include <LibWeb/Cookie/ParsedCookie.h>
 | 
					
						
							| 
									
										
										
										
											2025-03-24 09:27:36 -04:00
										 |  |  | #include <LibWebView/Application.h>
 | 
					
						
							| 
									
										
										
										
											2024-09-22 13:25:18 -04:00
										 |  |  | #include <LibWebView/CookieJar.h>
 | 
					
						
							| 
									
										
										
										
											2024-11-13 16:08:08 -05:00
										 |  |  | #include <LibWebView/HelperProcess.h>
 | 
					
						
							| 
									
										
										
										
											2025-09-13 09:08:24 -04:00
										 |  |  | #include <LibWebView/SourceHighlighter.h>
 | 
					
						
							| 
									
										
										
										
											2025-03-24 09:27:36 -04:00
										 |  |  | #include <LibWebView/ViewImplementation.h>
 | 
					
						
							|  |  |  | #include <LibWebView/WebContentClient.h>
 | 
					
						
							|  |  |  | #include <LibWebView/WebUI.h>
 | 
					
						
							| 
									
										
										
										
											2020-06-17 17:31:42 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-30 10:46:33 +02:00
										 |  |  | namespace WebView { | 
					
						
							| 
									
										
										
										
											2020-08-24 15:33:18 +04:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-26 13:43:45 -06:00
										 |  |  | HashTable<WebContentClient*> WebContentClient::s_clients; | 
					
						
							| 
									
										
										
										
											2024-06-20 21:34:51 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | Optional<ViewImplementation&> WebContentClient::view_for_pid_and_page_id(pid_t pid, u64 page_id) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     for (auto* client : s_clients) { | 
					
						
							|  |  |  |         if (client->m_process_handle.pid == pid) | 
					
						
							|  |  |  |             return client->view_for_page_id(page_id); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     return {}; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-08 22:01:46 +02:00
										 |  |  | WebContentClient::WebContentClient(NonnullOwnPtr<IPC::Transport> transport, ViewImplementation& view) | 
					
						
							| 
									
										
										
										
											2024-10-22 15:47:33 -06:00
										 |  |  |     : IPC::ConnectionToServer<WebContentClientEndpoint, WebContentServerEndpoint>(*this, move(transport)) | 
					
						
							| 
									
										
										
										
											2020-06-17 17:31:42 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-06-20 21:34:51 +03:00
										 |  |  |     s_clients.set(this); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     m_views.set(0, &view); | 
					
						
							| 
									
										
										
										
											2020-06-17 17:31:42 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-08 22:01:46 +02:00
										 |  |  | WebContentClient::WebContentClient(NonnullOwnPtr<IPC::Transport> transport) | 
					
						
							| 
									
										
										
										
											2025-03-09 18:01:25 -04:00
										 |  |  |     : IPC::ConnectionToServer<WebContentClientEndpoint, WebContentServerEndpoint>(*this, move(transport)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     s_clients.set(this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-20 21:34:51 +03:00
										 |  |  | WebContentClient::~WebContentClient() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     s_clients.remove(this); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-30 18:20:40 +01:00
										 |  |  | void WebContentClient::die() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2024-06-29 22:24:01 -06:00
										 |  |  |     // Intentionally empty. Restart is handled at another level.
 | 
					
						
							| 
									
										
										
										
											2021-01-30 18:20:40 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-09 18:01:25 -04:00
										 |  |  | void WebContentClient::assign_view(Badge<Application>, ViewImplementation& view) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     VERIFY(m_views.is_empty()); | 
					
						
							|  |  |  |     m_views.set(0, &view); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  | void WebContentClient::register_view(u64 page_id, ViewImplementation& view) | 
					
						
							| 
									
										
										
										
											2020-06-17 17:31:42 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     VERIFY(page_id > 0); | 
					
						
							|  |  |  |     m_views.set(page_id, &view); | 
					
						
							| 
									
										
										
										
											2020-06-17 17:31:42 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  | void WebContentClient::unregister_view(u64 page_id) | 
					
						
							| 
									
										
										
										
											2023-05-17 12:37:31 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     m_views.remove(page_id); | 
					
						
							| 
									
										
										
										
											2024-06-29 22:24:01 -06:00
										 |  |  |     if (m_views.is_empty()) { | 
					
						
							|  |  |  |         on_web_content_process_crash = nullptr; | 
					
						
							| 
									
										
										
										
											2024-06-30 19:12:22 -06:00
										 |  |  |         async_close_server(); | 
					
						
							| 
									
										
										
										
											2024-06-29 22:24:01 -06:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2023-05-17 12:37:31 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-24 09:27:36 -04:00
										 |  |  | void WebContentClient::web_ui_disconnected(Badge<WebUI>) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     m_web_ui.clear(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_paint(u64 page_id, Gfx::IntRect rect, i32 bitmap_id) | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) | 
					
						
							|  |  |  |         view->server_did_paint({}, bitmap_id, rect.size()); | 
					
						
							| 
									
										
										
										
											2023-05-17 12:37:31 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-09 11:40:34 -04:00
										 |  |  | void WebContentClient::did_request_new_process_for_navigation(u64 page_id, URL::URL url) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) | 
					
						
							|  |  |  |         view->create_new_process_for_cross_site_navigation(url); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_start_loading(u64 page_id, URL::URL url, bool is_redirect) | 
					
						
							| 
									
										
										
										
											2020-06-17 17:31:42 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-06-29 22:24:01 -06:00
										 |  |  |     if (auto process = WebView::Application::the().find_process(m_process_handle.pid); process.has_value()) | 
					
						
							|  |  |  |         process->set_title(OptionalNone {}); | 
					
						
							| 
									
										
										
										
											2024-04-22 14:11:46 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         view->set_url({}, url); | 
					
						
							| 
									
										
										
										
											2023-05-17 12:37:31 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |         if (view->on_load_start) | 
					
						
							|  |  |  |             view->on_load_start(url, is_redirect); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-06-17 17:31:42 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-06-17 18:00:18 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_finish_loading(u64 page_id, URL::URL url) | 
					
						
							| 
									
										
										
										
											2023-09-14 19:17:32 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2025-03-24 09:27:36 -04:00
										 |  |  |     if (url.scheme() == "about"sv && url.paths().size() == 1) { | 
					
						
							|  |  |  |         if (auto web_ui = WebUI::create(*this, url.paths().first()); web_ui.is_error()) | 
					
						
							|  |  |  |             warnln("Could not create WebUI for {}: {}", url, web_ui.error()); | 
					
						
							|  |  |  |         else | 
					
						
							|  |  |  |             m_web_ui = web_ui.release_value(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         view->set_url({}, url); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |         if (view->on_load_finish) | 
					
						
							|  |  |  |             view->on_load_finish(url); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-09-14 19:17:32 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-18 17:37:32 +01:00
										 |  |  | void WebContentClient::did_finish_test(u64 page_id, String text) | 
					
						
							| 
									
										
										
										
											2022-11-11 13:33:11 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							| 
									
										
										
										
											2025-03-18 17:37:32 +01:00
										 |  |  |         if (view->on_test_finish) | 
					
						
							|  |  |  |             view->on_test_finish(text); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-19 14:16:05 +00:00
										 |  |  | void WebContentClient::did_set_test_timeout(u64 page_id, double milliseconds) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         if (view->on_set_test_timeout) | 
					
						
							|  |  |  |             view->on_set_test_timeout(milliseconds); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-16 10:24:15 +02:00
										 |  |  | void WebContentClient::did_receive_reference_test_metadata(u64 page_id, JsonValue metadata) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         if (view->on_reference_test_metadata) | 
					
						
							|  |  |  |             view->on_reference_test_metadata(metadata); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-12-23 22:15:06 +01:00
										 |  |  | void WebContentClient::did_set_browser_zoom(u64 page_id, double factor) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2025-09-10 07:23:15 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) | 
					
						
							|  |  |  |         view->set_zoom(factor); | 
					
						
							| 
									
										
										
										
											2024-12-23 22:15:06 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_find_in_page(u64 page_id, size_t current_match_index, Optional<size_t> total_match_count) | 
					
						
							| 
									
										
										
										
											2024-06-09 18:35:32 +01:00
										 |  |  | { | 
					
						
							|  |  |  |     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-02 18:00:48 -07:00
										 |  |  | void WebContentClient::did_request_refresh(u64 page_id) | 
					
						
							| 
									
										
										
										
											2022-11-11 13:33:11 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-09-22 13:29:27 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) | 
					
						
							|  |  |  |         view->reload(); | 
					
						
							| 
									
										
										
										
											2022-11-11 13:33:11 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_request_cursor_change(u64 page_id, Gfx::Cursor cursor) | 
					
						
							| 
									
										
										
										
											2021-02-27 21:12:12 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         if (view->on_cursor_change) | 
					
						
							| 
									
										
										
										
											2025-02-20 12:17:29 +00:00
										 |  |  |             view->on_cursor_change(cursor); | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-02-27 21:12:12 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-07-28 16:51:01 -04:00
										 |  |  | void WebContentClient::did_change_title(u64 page_id, Utf16String title) | 
					
						
							| 
									
										
										
										
											2020-07-04 23:40:17 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-06-29 22:24:01 -06:00
										 |  |  |     if (auto process = WebView::Application::the().find_process(m_process_handle.pid); process.has_value()) | 
					
						
							| 
									
										
										
										
											2025-07-28 16:51:01 -04:00
										 |  |  |         process->set_title(title); | 
					
						
							| 
									
										
										
										
											2024-04-22 14:11:46 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							| 
									
										
										
										
											2025-07-28 16:51:01 -04:00
										 |  |  |         if (title.is_empty()) | 
					
						
							|  |  |  |             title = Utf16String::from_utf8(view->url().serialize()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         view->set_title({}, title); | 
					
						
							| 
									
										
										
										
											2023-06-07 16:37:30 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-02-17 06:43:06 -05:00
										 |  |  |         if (view->on_title_change) | 
					
						
							| 
									
										
										
										
											2025-07-28 16:51:01 -04:00
										 |  |  |             view->on_title_change(title); | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-07-04 23:40:17 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-07-05 15:43:43 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_change_url(u64 page_id, URL::URL url) | 
					
						
							| 
									
										
										
										
											2024-04-14 10:27:20 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							| 
									
										
										
										
											2024-04-14 16:59:59 -04:00
										 |  |  |         view->set_url({}, url); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-14 10:27:20 +02:00
										 |  |  |         if (view->on_url_change) | 
					
						
							|  |  |  |             view->on_url_change(url); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_request_tooltip_override(u64 page_id, Gfx::IntPoint position, ByteString title) | 
					
						
							| 
									
										
										
										
											2024-07-02 16:48:57 +02:00
										 |  |  | { | 
					
						
							|  |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         if (view->on_request_tooltip_override) | 
					
						
							|  |  |  |             view->on_request_tooltip_override(view->to_widget_position(position), title); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebContentClient::did_stop_tooltip_override(u64 page_id) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         if (view->on_stop_tooltip_override) | 
					
						
							|  |  |  |             view->on_stop_tooltip_override(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_enter_tooltip_area(u64 page_id, ByteString title) | 
					
						
							| 
									
										
										
										
											2021-03-30 12:10:06 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         if (view->on_enter_tooltip_area) | 
					
						
							| 
									
										
										
										
											2024-07-02 14:16:24 +02:00
										 |  |  |             view->on_enter_tooltip_area(title); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-03-30 12:10:06 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  | void WebContentClient::did_leave_tooltip_area(u64 page_id) | 
					
						
							| 
									
										
										
										
											2021-03-30 12:10:06 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04: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-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-03-30 12:10:06 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_hover_link(u64 page_id, URL::URL url) | 
					
						
							| 
									
										
										
										
											2020-07-05 16:59:20 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04: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-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-07-05 16:59:20 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  | void WebContentClient::did_unhover_link(u64 page_id) | 
					
						
							| 
									
										
										
										
											2020-07-05 16:59:20 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         if (view->on_link_unhover) | 
					
						
							|  |  |  |             view->on_link_unhover(); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-07-05 16:59:20 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-07-06 20:01:46 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_click_link(u64 page_id, URL::URL url, ByteString target, unsigned modifiers) | 
					
						
							| 
									
										
										
										
											2020-07-06 20:01:46 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2025-09-13 09:08:24 -04:00
										 |  |  |     if (modifiers == Web::UIEvents::Mod_PlatformCtrl) | 
					
						
							|  |  |  |         Application::the().open_url_in_new_tab(url, Web::HTML::ActivateTab::No); | 
					
						
							|  |  |  |     else if (target == "_blank"sv) | 
					
						
							|  |  |  |         Application::the().open_url_in_new_tab(url, Web::HTML::ActivateTab::Yes); | 
					
						
							|  |  |  |     else if (auto view = view_for_page_id(page_id); view.has_value()) | 
					
						
							|  |  |  |         view->load(url); | 
					
						
							| 
									
										
										
										
											2020-07-06 20:01:46 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-13 09:08:24 -04:00
										 |  |  | void WebContentClient::did_middle_click_link(u64, URL::URL url, ByteString, unsigned) | 
					
						
							| 
									
										
										
										
											2020-07-06 20:01:46 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2025-09-13 09:08:24 -04:00
										 |  |  |     Application::the().open_url_in_new_tab(url, Web::HTML::ActivateTab::No); | 
					
						
							| 
									
										
										
										
											2020-07-06 21:58:16 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-07-07 12:24:29 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  | void WebContentClient::did_request_context_menu(u64 page_id, Gfx::IntPoint content_position) | 
					
						
							| 
									
										
										
										
											2020-07-07 12:24:29 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2025-09-01 08:20:14 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) | 
					
						
							|  |  |  |         view->did_request_page_context_menu({}, content_position); | 
					
						
							| 
									
										
										
										
											2020-07-07 12:24:29 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_request_link_context_menu(u64 page_id, Gfx::IntPoint content_position, URL::URL url, ByteString, unsigned) | 
					
						
							| 
									
										
										
										
											2020-07-07 12:24:29 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2025-09-01 08:20:14 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) | 
					
						
							|  |  |  |         view->did_request_link_context_menu({}, content_position, move(url)); | 
					
						
							| 
									
										
										
										
											2020-07-07 12:24:29 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2020-08-24 15:33:18 +04:30
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_request_image_context_menu(u64 page_id, Gfx::IntPoint content_position, URL::URL url, ByteString, unsigned, Optional<Gfx::ShareableBitmap> bitmap) | 
					
						
							| 
									
										
										
										
											2021-04-11 16:49:25 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2025-09-01 08:20:14 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) | 
					
						
							|  |  |  |         view->did_request_image_context_menu({}, content_position, move(url), move(bitmap)); | 
					
						
							| 
									
										
										
										
											2021-04-11 16:49:25 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_request_media_context_menu(u64 page_id, Gfx::IntPoint content_position, ByteString, unsigned, Web::Page::MediaContextMenu menu) | 
					
						
							| 
									
										
										
										
											2023-05-15 09:42:56 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2025-09-01 08:20:14 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) | 
					
						
							|  |  |  |         view->did_request_media_context_menu({}, content_position, move(menu)); | 
					
						
							| 
									
										
										
										
											2023-05-15 09:42:56 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-13 09:08:24 -04:00
										 |  |  | void WebContentClient::did_get_source(u64, URL::URL url, URL::URL base_url, String source) | 
					
						
							| 
									
										
										
										
											2021-02-23 06:17:23 -06:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2025-09-13 09:08:24 -04:00
										 |  |  |     if (auto view = Application::the().open_blank_new_tab(Web::HTML::ActivateTab::Yes); view.has_value()) { | 
					
						
							|  |  |  |         auto html = highlight_source(url, base_url, source, Syntax::Language::HTML, WebView::HighlightOutputMode::FullDocument); | 
					
						
							|  |  |  |         view->load_html(html); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-02-23 06:17:23 -06:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-19 15:50:56 -04:00
										 |  |  | static JsonObject parse_json(StringView json, StringView name) | 
					
						
							| 
									
										
										
										
											2025-02-21 12:39:43 -05:00
										 |  |  | { | 
					
						
							|  |  |  |     auto parsed_tree = JsonValue::from_string(json); | 
					
						
							|  |  |  |     if (parsed_tree.is_error()) { | 
					
						
							|  |  |  |         dbgln("Unable to parse {}: {}", name, parsed_tree.error()); | 
					
						
							|  |  |  |         return {}; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-19 15:50:56 -04:00
										 |  |  |     if (!parsed_tree.value().is_object()) { | 
					
						
							|  |  |  |         dbgln("Expected {} to be an object: {}", name, parsed_tree.value()); | 
					
						
							|  |  |  |         return {}; | 
					
						
							| 
									
										
										
										
											2025-02-21 12:39:43 -05:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2025-03-19 15:50:56 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return move(parsed_tree.release_value().as_object()); | 
					
						
							| 
									
										
										
										
											2025-02-21 12:39:43 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_inspect_dom_tree(u64 page_id, String dom_tree) | 
					
						
							| 
									
										
										
										
											2021-06-07 16:35:10 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         if (view->on_received_dom_tree) | 
					
						
							| 
									
										
										
										
											2025-02-21 12:39:43 -05:00
										 |  |  |             view->on_received_dom_tree(parse_json(dom_tree, "DOM tree"sv)); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-06-07 16:35:10 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-19 15:50:56 -04:00
										 |  |  | void WebContentClient::did_inspect_dom_node(u64 page_id, DOMNodeProperties properties) | 
					
						
							| 
									
										
										
										
											2023-12-30 09:30:27 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2025-03-19 15:50:56 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         if (view->on_received_dom_node_properties) | 
					
						
							|  |  |  |             view->on_received_dom_node_properties(move(properties)); | 
					
						
							| 
									
										
										
										
											2023-12-30 09:30:27 -05:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_inspect_accessibility_tree(u64 page_id, String accessibility_tree) | 
					
						
							| 
									
										
										
										
											2023-05-17 12:37:31 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         if (view->on_received_accessibility_tree) | 
					
						
							| 
									
										
										
										
											2025-02-21 12:39:43 -05:00
										 |  |  |             view->on_received_accessibility_tree(parse_json(accessibility_tree, "accessibility tree"sv)); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-08-27 12:47:30 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_get_hovered_node_id(u64 page_id, Web::UniqueNodeID node_id) | 
					
						
							| 
									
										
										
										
											2023-12-30 09:42:24 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04: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-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-12-30 09:42:24 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_finish_editing_dom_node(u64 page_id, Optional<Web::UniqueNodeID> node_id) | 
					
						
							| 
									
										
										
										
											2023-12-30 10:08:33 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							| 
									
										
										
										
											2025-04-07 10:46:22 +00:00
										 |  |  |         if (view->on_finished_editing_dom_node) | 
					
						
							|  |  |  |             view->on_finished_editing_dom_node(node_id); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-12-30 10:08:33 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_mutate_dom(u64 page_id, Mutation mutation) | 
					
						
							| 
									
										
										
										
											2025-03-06 17:32:43 -05:00
										 |  |  | { | 
					
						
							|  |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         if (view->on_dom_mutation_received) | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  |             view->on_dom_mutation_received(move(mutation)); | 
					
						
							| 
									
										
										
										
											2025-03-06 17:32:43 -05:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_get_dom_node_html(u64 page_id, String html) | 
					
						
							| 
									
										
										
										
											2023-12-30 14:32:50 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         if (view->on_received_dom_node_html) | 
					
						
							| 
									
										
										
										
											2025-03-10 17:36:41 -04:00
										 |  |  |             view->on_received_dom_node_html(move(html)); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-12-30 14:32:50 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-14 16:22:16 -04:00
										 |  |  | void WebContentClient::did_list_style_sheets(u64 page_id, Vector<Web::CSS::StyleSheetIdentifier> stylesheets) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         if (view->on_received_style_sheet_list) | 
					
						
							|  |  |  |             view->on_received_style_sheet_list(stylesheets); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebContentClient::did_get_style_sheet_source(u64 page_id, Web::CSS::StyleSheetIdentifier identifier, URL::URL base_url, String source) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         if (view->on_received_style_sheet_source) | 
					
						
							|  |  |  |             view->on_received_style_sheet_source(identifier, base_url, source); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_take_screenshot(u64 page_id, Gfx::ShareableBitmap screenshot) | 
					
						
							| 
									
										
										
										
											2023-12-31 09:51:02 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) | 
					
						
							|  |  |  |         view->did_receive_screenshot({}, screenshot); | 
					
						
							| 
									
										
										
										
											2023-12-31 09:51:02 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_get_internal_page_info(u64 page_id, WebView::PageInfoType type, String info) | 
					
						
							| 
									
										
										
										
											2024-09-19 10:40:00 -04:00
										 |  |  | { | 
					
						
							|  |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) | 
					
						
							|  |  |  |         view->did_receive_internal_page_info({}, type, info); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_execute_js_console_input(u64 page_id, JsonValue result) | 
					
						
							| 
									
										
										
										
											2025-02-24 11:57:33 -05:00
										 |  |  | { | 
					
						
							|  |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         if (view->on_received_js_console_result) | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  |             view->on_received_js_console_result(move(result)); | 
					
						
							| 
									
										
										
										
											2025-02-24 11:57:33 -05:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  | void WebContentClient::did_output_js_console_message(u64 page_id, i32 message_index) | 
					
						
							| 
									
										
										
										
											2021-09-04 11:14:25 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							| 
									
										
										
										
											2025-03-04 07:56:42 -05:00
										 |  |  |         if (view->on_console_message_available) | 
					
						
							|  |  |  |             view->on_console_message_available(message_index); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-09-04 11:14:25 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-25 10:11:17 -04:00
										 |  |  | void WebContentClient::did_get_js_console_messages(u64 page_id, i32 start_index, Vector<ConsoleOutput> console_output) | 
					
						
							| 
									
										
										
										
											2021-09-04 11:14:25 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							| 
									
										
										
										
											2025-03-25 10:11:17 -04:00
										 |  |  |         if (view->on_received_console_messages) | 
					
						
							|  |  |  |             view->on_received_console_messages(start_index, move(console_output)); | 
					
						
							| 
									
										
										
										
											2025-03-04 08:48:20 -05:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_request_alert(u64 page_id, String message) | 
					
						
							| 
									
										
										
										
											2020-09-12 11:56:13 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04: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-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2020-09-12 11:56:13 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_request_confirm(u64 page_id, String message) | 
					
						
							| 
									
										
										
										
											2021-02-10 08:48:28 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04: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-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-02-10 08:48:28 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_request_prompt(u64 page_id, String message, String default_) | 
					
						
							| 
									
										
										
										
											2021-02-20 12:05:18 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04: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-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2021-02-20 12:05:18 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_request_set_prompt_text(u64 page_id, String message) | 
					
						
							| 
									
										
										
										
											2022-11-16 08:57:05 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04: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-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-11-16 08:57:05 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  | void WebContentClient::did_request_accept_dialog(u64 page_id) | 
					
						
							| 
									
										
										
										
											2022-11-16 06:58:14 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04: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-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-11-16 06:58:14 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  | void WebContentClient::did_request_dismiss_dialog(u64 page_id) | 
					
						
							| 
									
										
										
										
											2022-11-16 06:58:14 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04: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-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-11-16 06:58:14 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_change_favicon(u64 page_id, Gfx::ShareableBitmap favicon) | 
					
						
							| 
									
										
										
										
											2021-03-26 10:41:25 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2021-05-02 19:54:34 +02:00
										 |  |  |     if (!favicon.is_valid()) { | 
					
						
							| 
									
										
										
										
											2021-03-26 10:41:25 -04:00
										 |  |  |         dbgln("DidChangeFavicon: Received invalid favicon"); | 
					
						
							|  |  |  |         return; | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-05-17 12:37:31 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04: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 10:41:25 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-05 23:05:45 +03:00
										 |  |  | Messages::WebContentClient::DidRequestAllCookiesWebdriverResponse WebContentClient::did_request_all_cookies_webdriver(URL::URL url) | 
					
						
							| 
									
										
										
										
											2022-11-11 09:23:24 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2025-08-05 23:05:45 +03:00
										 |  |  |     return Application::cookie_jar().get_all_cookies_webdriver(url); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Messages::WebContentClient::DidRequestAllCookiesCookiestoreResponse WebContentClient::did_request_all_cookies_cookiestore(URL::URL url) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return Application::cookie_jar().get_all_cookies_cookiestore(url); | 
					
						
							| 
									
										
										
										
											2022-11-11 09:23:24 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | Messages::WebContentClient::DidRequestNamedCookieResponse WebContentClient::did_request_named_cookie(URL::URL url, String name) | 
					
						
							| 
									
										
										
										
											2022-11-11 09:46:56 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-09-22 13:25:18 -04:00
										 |  |  |     return Application::cookie_jar().get_named_cookie(url, name); | 
					
						
							| 
									
										
										
										
											2022-11-11 09:46:56 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | Messages::WebContentClient::DidRequestCookieResponse WebContentClient::did_request_cookie(URL::URL url, Web::Cookie::Source source) | 
					
						
							| 
									
										
										
										
											2021-04-11 10:54:11 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-09-22 13:25:18 -04:00
										 |  |  |     return Application::cookie_jar().get_cookie(url, source); | 
					
						
							| 
									
										
										
										
											2021-04-11 10:54:11 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_set_cookie(URL::URL url, Web::Cookie::ParsedCookie cookie, Web::Cookie::Source source) | 
					
						
							| 
									
										
										
										
											2021-04-11 10:54:11 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-09-22 13:25:18 -04:00
										 |  |  |     Application::cookie_jar().set_cookie(url, cookie, source); | 
					
						
							| 
									
										
										
										
											2021-04-11 10:54:11 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_update_cookie(Web::Cookie::Cookie cookie) | 
					
						
							| 
									
										
										
										
											2022-11-11 11:18:40 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-09-22 13:25:18 -04:00
										 |  |  |     Application::cookie_jar().update_cookie(cookie); | 
					
						
							| 
									
										
										
										
											2022-11-11 11:18:40 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-13 08:56:46 -04:00
										 |  |  | void WebContentClient::did_expire_cookies_with_time_offset(AK::Duration offset) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     Application::cookie_jar().expire_cookies_with_time_offset(offset); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-08 23:35:46 +02:00
										 |  |  | Messages::WebContentClient::DidRequestStorageItemResponse WebContentClient::did_request_storage_item(Web::StorageAPI::StorageEndpointType storage_endpoint, String storage_key, String bottle_key) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return Application::storage_jar().get_item(storage_endpoint, storage_key, bottle_key); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Messages::WebContentClient::DidSetStorageItemResponse WebContentClient::did_set_storage_item(Web::StorageAPI::StorageEndpointType storage_endpoint, String storage_key, String bottle_key, String value) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return Application::storage_jar().set_item(storage_endpoint, storage_key, bottle_key, value); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebContentClient::did_remove_storage_item(Web::StorageAPI::StorageEndpointType storage_endpoint, String storage_key, String bottle_key) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     Application::storage_jar().remove_item(storage_endpoint, storage_key, bottle_key); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Messages::WebContentClient::DidRequestStorageKeysResponse WebContentClient::did_request_storage_keys(Web::StorageAPI::StorageEndpointType storage_endpoint, String storage_key) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     return Application::storage_jar().get_all_keys(storage_endpoint, storage_key); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebContentClient::did_clear_storage(Web::StorageAPI::StorageEndpointType storage_endpoint, String storage_key) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     Application::storage_jar().clear_storage_key(storage_endpoint, storage_key); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | Messages::WebContentClient::DidRequestNewWebViewResponse WebContentClient::did_request_new_web_view(u64 page_id, Web::HTML::ActivateTab activate_tab, Web::HTML::WebViewHints hints, Optional<u64> page_index) | 
					
						
							| 
									
										
										
										
											2023-03-14 17:12:09 +03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04: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-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-17 12:37:31 -04:00
										 |  |  |     return String {}; | 
					
						
							| 
									
										
										
										
											2023-03-14 17:12:09 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  | void WebContentClient::did_request_activate_tab(u64 page_id) | 
					
						
							| 
									
										
										
										
											2023-03-20 19:52:00 -04:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         if (view->on_activate_tab) | 
					
						
							|  |  |  |             view->on_activate_tab(); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-03-20 19:52:00 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  | void WebContentClient::did_close_browsing_context(u64 page_id) | 
					
						
							| 
									
										
										
										
											2023-03-07 06:10:26 +03:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         if (view->on_close) | 
					
						
							|  |  |  |             view->on_close(); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-03-07 06:10:26 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  | void WebContentClient::did_update_resource_count(u64 page_id, i32 count_waiting) | 
					
						
							| 
									
										
										
										
											2022-02-20 17:03:39 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04: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-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-02-20 17:03:39 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  | void WebContentClient::did_request_restore_window(u64 page_id) | 
					
						
							| 
									
										
										
										
											2022-11-09 09:51:39 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         if (view->on_restore_window) | 
					
						
							|  |  |  |             view->on_restore_window(); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-11-09 09:51:39 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-28 23:37:11 -04:00
										 |  |  | void WebContentClient::did_request_reposition_window(u64 page_id, Gfx::IntPoint position) | 
					
						
							| 
									
										
										
										
											2022-11-09 09:51:39 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         if (view->on_reposition_window) | 
					
						
							| 
									
										
										
										
											2024-10-28 23:37:11 -04:00
										 |  |  |             view->on_reposition_window(position); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-11-09 09:51:39 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-28 23:37:11 -04:00
										 |  |  | void WebContentClient::did_request_resize_window(u64 page_id, Gfx::IntSize size) | 
					
						
							| 
									
										
										
										
											2022-11-09 09:51:39 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         if (view->on_resize_window) | 
					
						
							| 
									
										
										
										
											2024-10-28 23:37:11 -04:00
										 |  |  |             view->on_resize_window(size); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-11-09 09:51:39 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-28 23:45:18 -04:00
										 |  |  | void WebContentClient::did_request_maximize_window(u64 page_id) | 
					
						
							| 
									
										
										
										
											2022-11-09 10:04:09 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         if (view->on_maximize_window) | 
					
						
							| 
									
										
										
										
											2024-10-28 23:45:18 -04:00
										 |  |  |             view->on_maximize_window(); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-11-09 10:04:09 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-28 23:45:18 -04:00
										 |  |  | void WebContentClient::did_request_minimize_window(u64 page_id) | 
					
						
							| 
									
										
										
										
											2022-11-09 10:04:09 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         if (view->on_minimize_window) | 
					
						
							| 
									
										
										
										
											2024-10-28 23:45:18 -04:00
										 |  |  |             view->on_minimize_window(); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-11-09 10:04:09 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-10-28 23:45:18 -04:00
										 |  |  | void WebContentClient::did_request_fullscreen_window(u64 page_id) | 
					
						
							| 
									
										
										
										
											2022-11-09 19:09:17 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         if (view->on_fullscreen_window) | 
					
						
							| 
									
										
										
										
											2024-10-28 23:45:18 -04:00
										 |  |  |             view->on_fullscreen_window(); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-11-09 19:09:17 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_request_file(u64 page_id, ByteString path, i32 request_id) | 
					
						
							| 
									
										
										
										
											2022-02-26 17:50:31 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04: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-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-02-26 17:50:31 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_request_color_picker(u64 page_id, Color current_color) | 
					
						
							| 
									
										
										
										
											2023-09-04 11:32:40 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04: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-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-09-04 11:32:40 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_request_file_picker(u64 page_id, Web::HTML::FileFilter accepted_file_types, Web::HTML::AllowMultipleFiles allow_multiple_files) | 
					
						
							| 
									
										
										
										
											2024-02-25 13:02:47 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04: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 13:02:47 -05:00
										 |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_request_select_dropdown(u64 page_id, Gfx::IntPoint content_position, i32 minimum_width, Vector<Web::HTML::SelectItem> items) | 
					
						
							| 
									
										
										
										
											2023-12-07 15:53:49 +01:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							|  |  |  |         if (view->on_request_select_dropdown) | 
					
						
							| 
									
										
										
										
											2025-03-21 10:53:59 -04:00
										 |  |  |             view->on_request_select_dropdown(view->to_widget_position(content_position), minimum_width / view->device_pixel_ratio(), items); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-12-07 15:53:49 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-09-12 12:56:31 -04:00
										 |  |  | void WebContentClient::did_finish_handling_input_event(u64 page_id, Web::EventResult event_result) | 
					
						
							| 
									
										
										
										
											2022-11-21 16:07:47 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) | 
					
						
							| 
									
										
										
										
											2024-09-12 12:56:31 -04:00
										 |  |  |         view->did_finish_handling_input_event({}, event_result); | 
					
						
							| 
									
										
										
										
											2022-11-21 16:07:47 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  | void WebContentClient::did_change_theme_color(u64 page_id, Gfx::Color color) | 
					
						
							| 
									
										
										
										
											2023-09-19 01:51:48 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04: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-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-09-19 01:51:48 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-09-18 08:16:36 -04:00
										 |  |  | void WebContentClient::did_insert_clipboard_entry(u64, Web::Clipboard::SystemClipboardRepresentation entry, String) | 
					
						
							| 
									
										
										
										
											2023-11-10 13:35:41 -05:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2025-09-18 08:16:36 -04:00
										 |  |  |     Application::the().insert_clipboard_entry(move(entry)); | 
					
						
							| 
									
										
										
										
											2025-05-01 11:38:31 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void WebContentClient::did_request_clipboard_entries(u64 page_id, u64 request_id) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							| 
									
										
										
										
											2025-09-18 08:16:36 -04:00
										 |  |  |         Vector<Web::Clipboard::SystemClipboardItem> items; | 
					
						
							|  |  |  |         if (auto entries = Application::the().clipboard_entries(); !entries.is_empty()) | 
					
						
							|  |  |  |             items.empend(move(entries)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         view->retrieved_clipboard_entries(request_id, items); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-11-10 13:35:41 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-26 19:27:06 -04:00
										 |  |  | void WebContentClient::did_change_audio_play_state(u64 page_id, Web::HTML::AudioPlayState play_state) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) | 
					
						
							|  |  |  |         view->did_change_audio_play_state({}, play_state); | 
					
						
							| 
									
										
										
										
											2024-03-26 19:27:06 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-13 23:12:55 +02: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); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-03-08 12:22:39 -05:00
										 |  |  | void WebContentClient::did_allocate_backing_stores(u64 page_id, i32 front_bitmap_id, Gfx::ShareableBitmap front_bitmap, i32 back_bitmap_id, Gfx::ShareableBitmap back_bitmap) | 
					
						
							| 
									
										
										
										
											2024-06-17 18:50:57 +03:00
										 |  |  | { | 
					
						
							|  |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) | 
					
						
							|  |  |  |         view->did_allocate_backing_stores({}, front_bitmap_id, front_bitmap, back_bitmap_id, back_bitmap); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-04-24 17:07:09 +12:00
										 |  |  | Messages::WebContentClient::RequestWorkerAgentResponse WebContentClient::request_worker_agent(u64 page_id, Web::Bindings::AgentType worker_type) | 
					
						
							| 
									
										
										
										
											2024-01-06 13:13:59 -07:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = view_for_page_id(page_id); view.has_value()) { | 
					
						
							| 
									
										
										
										
											2025-04-24 17:07:09 +12:00
										 |  |  |         auto worker_client = MUST(WebView::launch_web_worker_process(worker_type)); | 
					
						
							| 
									
										
										
										
											2024-11-13 16:08:08 -05:00
										 |  |  |         return worker_client->clone_transport(); | 
					
						
							| 
									
										
										
										
											2024-02-02 18:00:48 -07:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-17 18:44:39 -06:00
										 |  |  |     return IPC::File {}; | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Optional<ViewImplementation&> WebContentClient::view_for_page_id(u64 page_id, SourceLocation location) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2025-03-09 18:01:25 -04:00
										 |  |  |     // Don't bother logging anything for the spare WebContent process. It will only receive a load notification for about:blank.
 | 
					
						
							|  |  |  |     if (m_views.is_empty()) | 
					
						
							|  |  |  |         return {}; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     if (auto view = m_views.get(page_id); view.has_value()) | 
					
						
							|  |  |  |         return *view.value(); | 
					
						
							| 
									
										
										
										
											2024-01-06 13:13:59 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-29 09:44:49 -04:00
										 |  |  |     dbgln("WebContentClient::{}: Did not find a page with ID {}", location.function_name(), page_id); | 
					
						
							|  |  |  |     return {}; | 
					
						
							| 
									
										
										
										
											2024-01-06 13:13:59 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-24 15:33:18 +04:30
										 |  |  | } |