diff --git a/Userland/Libraries/LibWebView/ProcessInfo.h b/Userland/Libraries/LibWebView/ProcessInfo.h index 5cf5c62479..55f25edb6b 100644 --- a/Userland/Libraries/LibWebView/ProcessInfo.h +++ b/Userland/Libraries/LibWebView/ProcessInfo.h @@ -6,6 +6,8 @@ #pragma once +#include +#include #include #include @@ -34,6 +36,7 @@ struct ProcessInfo : public Core::Platform::ProcessInfo { } ProcessType type { ProcessType::WebContent }; + Optional title; }; } diff --git a/Userland/Libraries/LibWebView/ProcessManager.cpp b/Userland/Libraries/LibWebView/ProcessManager.cpp index 2881499369..9a50b28cf9 100644 --- a/Userland/Libraries/LibWebView/ProcessManager.cpp +++ b/Userland/Libraries/LibWebView/ProcessManager.cpp @@ -197,7 +197,7 @@ String ProcessManager::generate_html() - + @@ -210,6 +210,8 @@ String ProcessManager::generate_html() builder.append(""sv); builder.append(""sv); builder.append("
TypeName PID Memory Usage CPU %
"sv); builder.append(WebView::process_name_from_type(process.type)); + if (process.title.has_value()) + builder.appendff(" - {}", *process.title); builder.append(""sv); builder.append(MUST(String::number(process.pid))); diff --git a/Userland/Libraries/LibWebView/WebContentClient.cpp b/Userland/Libraries/LibWebView/WebContentClient.cpp index 5d91e516b2..03c55aff7b 100644 --- a/Userland/Libraries/LibWebView/WebContentClient.cpp +++ b/Userland/Libraries/LibWebView/WebContentClient.cpp @@ -38,6 +38,7 @@ void WebContentClient::notify_process_information(WebView::ProcessHandle const& { dbgln_if(SPAM_DEBUG, "handle: WebContentClient::NotifyProcessInformation! pid={}", handle.pid); ProcessManager::the().add_process(ProcessType::WebContent, handle.pid); + m_process_handle = handle; } void WebContentClient::did_paint(u64 page_id, Gfx::IntRect const& rect, i32 bitmap_id) @@ -48,6 +49,9 @@ void WebContentClient::did_paint(u64 page_id, Gfx::IntRect const& rect, i32 bitm void WebContentClient::did_start_loading(u64 page_id, URL::URL const& url, bool is_redirect) { + if (auto* process = WebView::ProcessManager::the().find_process(m_process_handle.pid)) + process->title.clear(); + if (auto view = view_for_page_id(page_id); view.has_value()) { view->set_url({}, url); @@ -121,6 +125,9 @@ void WebContentClient::did_layout(u64 page_id, Gfx::IntSize content_size) void WebContentClient::did_change_title(u64 page_id, ByteString const& title) { + if (auto* process = WebView::ProcessManager::the().find_process(m_process_handle.pid)) + process->title = MUST(String::from_byte_string(title)); + if (auto view = view_for_page_id(page_id); view.has_value()) { if (!view->on_title_change) return; diff --git a/Userland/Libraries/LibWebView/WebContentClient.h b/Userland/Libraries/LibWebView/WebContentClient.h index 274d294268..36752692a7 100644 --- a/Userland/Libraries/LibWebView/WebContentClient.h +++ b/Userland/Libraries/LibWebView/WebContentClient.h @@ -115,6 +115,8 @@ private: // FIXME: Does a HashMap holding references make sense? HashMap m_views; + + ProcessHandle m_process_handle; }; }