LibWeb+LibWebView+WebContent: Introduce a WebUI framework

When we build internal pages (e.g. about:settings), there is currently
quite a lot of boilerplate needed to communicate between the browser and
the page. This includes creating IDL for the page and the IPC for every
message sent between the processes.

These internal pages are also special in that they have privileged
access to and control over the browser process.

The framework introduced here serves to ease the setup of new internal
pages and to reduce the access that WebContent processes have to the
browser process. WebUI pages can send requests to the browser process
via a `ladybird.sendMessage` API. Responses from the browser are passed
through a WebUIMessage event. So, for example, an internal page may:

    ladybird.sendMessage("getDataFor", { id: 123 });

    document.addEventListener("WebUIMessage", event => {
        if (event.name === "gotData") {
            console.assert(event.data.id === 123);
        }
    });

To handle these messages, we set up a new IPC connection between the
browser and WebContent processes. This connection is torn down when
the user navigates away from the internal page.
This commit is contained in:
Timothy Flynn 2025-03-24 09:27:36 -04:00 committed by Tim Flynn
commit 41aeb9e63a
Notes: github-actions[bot] 2025-03-28 11:32:17 +00:00
25 changed files with 416 additions and 3 deletions

View file

@ -61,6 +61,7 @@ private:
virtual Messages::WebContentServer::GetWindowHandleResponse get_window_handle(u64 page_id) override;
virtual void set_window_handle(u64 page_id, String handle) override;
virtual void connect_to_webdriver(u64 page_id, ByteString webdriver_ipc_path) override;
virtual void connect_to_web_ui(u64 page_id, IPC::File web_ui_socket) override;
virtual void connect_to_image_decoder(IPC::File image_decoder_socket) override;
virtual void update_system_theme(u64 page_id, Core::AnonymousBuffer) override;
virtual void update_screen_rects(u64 page_id, Vector<Web::DevicePixelRect>, u32) override;