libaura-webview: Web pages in AURA

libs/aura-webview provides the AURA element WebView: a full Chromium page in the scene graph, using the Chromium Embedded Framework (CEF). The page supports touch interaction and communicates with C++ code through a WebChannel. Custom JavaScript can be injected into any page.

qml
WebView {
    id: page
    url: "https://example.org"
    script: "document.addEventListener('DOMContentLoaded', () => { ... })"
    size: parent.width - 48, parent.height - 104
}

Example and tests: tests/ui-webview/webview.aura and tests/test_webview.cpp.

Building

Option Meaning
-DAURA_WITH_WEBVIEW=ON Builds libaura-webview and links it into aura-view and aura_webview_tests (preset webview). Default: OFF.
-DAURA_CEF_ROOT=<dir> Uses an unpacked CEF distribution instead of downloading it
AURA_CEF_VERSION CEF version (default 156.0.14, Chromium 156.0.8078.48)

Architecture

Part Responsibility
WebViewNode (aura/webview/webview.h) The node: renders the page, forwards touch input, WebChannel, scripts
aura-webview-helper CEF subprocesses (renderer, GPU, network). In the renderer, it sets up window.aura and executes scripts. The application's main() remains free of CEF.
aura::ui::registerElementType (aura/ui/elements.h) Element types from other libraries for the loader. This keeps aura-ui independent of CEF.
aura::post() (aura/core/tasks.h) Transfers work to the UI thread safely. The loop processes it before each frame; the aura-view server does so on every request (aura::runPosted()).

WebChannel and scripts

Every page has window.aura before its own scripts run.

js
const sum = await aura.call("add", 2, 3);   // JavaScript -> C++, Promise
aura.on("cart", (value) => render(value));  // C++ -> JavaScript
cpp
#include "aura/webview/webview.h"

dialog->page->handle("add", [](const auto& args) {
	return AuraJson(args[0].toInt() + args[1].toInt());
});
dialog->page->emit("cart", {{"items", 3}});
dialog->page->runJavaScript("document.body.style.zoom = 1.2");
dialog->page->addUserScript("window.kiosk = true;");

Application integration

cpp
int main(int argc, char** argv)
{
	// Before building the first UI: register WebView for the loader;
	// locale: Chromium language (default en-US)
	aura::webview::setup(argc, argv, {.locale = "de"});
	...
	aura::webview::shutdown();  // closes all browsers and stops CEF
}

aura-view initializes CEF when built with WebView (aura::webview then defines the preprocessor symbol AURA_WITH_WEBVIEW). Without the library, the loader reports “element type 'WebView' is not part of this program” and uses the compiled version. A file containing WebView can only be compiled if the program links aura::webview.

Preview (aura-view, VS Code)

Tests

aura_webview_tests (tests/test_webview.cpp, tests/ui-webview/webview.aura) builds a dialog containing a WebView once through compiled code and once through the loader. It loads a data: page without network access and checks:

Runtime and integration

Documentation source: docs/aura-webview.md · Download Markdown

Search for topics, widgets or APIs.