Skip to content

Truly independent web browser

LibWebView+Base+UI: Add about:licenses

Jelle Raaijmakerse7b2ee624107
diff --git a/Base/res/ladybird/about-pages/about.html b/Base/res/ladybird/about-pages/about.html
index 34414dfa27f..c2dbe0d6f03 100644
--- a/Base/res/ladybird/about-pages/about.html
+++ b/Base/res/ladybird/about-pages/about.html
@@ -43,6 +43,7 @@
<li><a href="about:about">about:about</a></li>
<li><a href="about:bookmarks">about:bookmarks</a></li>
<li><a href="about:crashes">about:crashes</a></li>
+ <li><a href="about:licenses">about:licenses</a></li>
<li><a href="about:settings">about:settings</a></li>
<li><a href="about:support">about:support</a></li>
<li><a href="about:version">about:version</a></li>
diff --git a/Base/res/ladybird/about-pages/licenses.html b/Base/res/ladybird/about-pages/licenses.html
new file mode 100644
index 00000000000..1d89fe8285e
--- /dev/null
+++ b/Base/res/ladybird/about-pages/licenses.html
@@ -0,0 +1,57 @@
+<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8" />
+ <meta name="color-scheme" content="light dark" />
+ <title>Licenses</title>
+ <link rel="icon" type="image/png" href="resource://icons/48x48/app-browser.png" />
+ <link rel="stylesheet" type="text/css" href="resource://ladybird/ladybird.css" />
+ <style>
+ body {
+ max-width: 920px;
+ margin: 0 auto;
+ padding: 30px 24px;
+ }
+
+ h1 {
+ margin-bottom: 18px;
+ font-size: 22px;
+ font-weight: 600;
+ }
+
+ pre {
+ font-family: ui-monospace, monospace;
+ font-size: 12px;
+ line-height: 1.45;
+ white-space: pre-wrap;
+ overflow-wrap: anywhere;
+ }
+ </style>
+ </head>
+ <body>
+ <h1>Licenses</h1>
+ <pre id="licenses">Loading…</pre>
+ <script type="module">
+ const LICENSES_URL = "resource://ladybird/LICENSES.txt";
+
+ async function loadLicenses() {
+ try {
+ const response = await fetch(`${LICENSES_URL}.br`);
+ const decompressed = response.body.pipeThrough(new DecompressionStream("brotli"));
+ return await new Response(decompressed).text();
+ } catch {
+ // A build without a brotli tool installs the licenses uncompressed.
+ const response = await fetch(LICENSES_URL);
+ return await response.text();
+ }
+ }
+
+ const licenses = document.querySelector("#licenses");
+ try {
+ licenses.textContent = await loadLicenses();
+ } catch {
+ licenses.textContent = "The licenses could not be loaded.";
+ }
+ </script>
+ </body>
+</html>
diff --git a/Libraries/LibWebView/WebUI.cpp b/Libraries/LibWebView/WebUI.cpp
index 64e101d63a0..a17fa9228ea 100644
--- a/Libraries/LibWebView/WebUI.cpp
+++ b/Libraries/LibWebView/WebUI.cpp
@@ -20,6 +20,7 @@ namespace WebView {
static constexpr auto s_pages = to_array<WebUI::Page>({
{ "about"sv, "About URLs"sv, WebUI::PageType::Static },
{ "crashes"sv, "Crash Reports"sv, WebUI::PageType::Dynamic },
+ { "licenses"sv, "Licenses"sv, WebUI::PageType::Static },
{ "newtab"sv, "New Tab"sv, WebUI::PageType::Static },
{ "settings"sv, "Settings"sv, WebUI::PageType::Dynamic },
{ "support"sv, "Support"sv, WebUI::PageType::Dynamic },
diff --git a/Meta/CMake/licenses.cmake b/Meta/CMake/licenses.cmake
index c877b2f06fa..d64057a8c9f 100644
--- a/Meta/CMake/licenses.cmake
+++ b/Meta/CMake/licenses.cmake
@@ -36,6 +36,7 @@ add_custom_command(
VERBATIM
)
+# about:licenses decompresses the file itself, and falls back to the uncompressed one.
set(brotli_hints "")
if (NOT "${VCPKG_INSTALLED_DIR}" STREQUAL "" AND NOT "${VCPKG_TARGET_TRIPLET}" STREQUAL "")
list(APPEND brotli_hints "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/tools/brotli")
diff --git a/Tests/LibWebView/TestOmnibox.cpp b/Tests/LibWebView/TestOmnibox.cpp
index 22e18c21b3a..ea2533e2fac 100644
--- a/Tests/LibWebView/TestOmnibox.cpp
+++ b/Tests/LibWebView/TestOmnibox.cpp
@@ -350,6 +350,7 @@ TEST_CASE(all_web_ui_pages_are_suggested)
static constexpr Array expected_urls {
"about:about"sv,
"about:crashes"sv,
+ "about:licenses"sv,
"about:newtab"sv,
"about:settings"sv,
"about:support"sv,
diff --git a/UI/cmake/ResourceFiles.cmake b/UI/cmake/ResourceFiles.cmake
index 36eb0193889..8f57e616e5a 100644
--- a/UI/cmake/ResourceFiles.cmake
+++ b/UI/cmake/ResourceFiles.cmake
@@ -31,6 +31,7 @@ set(ABOUT_PAGES
crashes.html
downloads.html
history.html
+ licenses.html
newtab.html
settings.html
support.html
@@ -166,6 +167,12 @@ function(copy_resources_to_build base_directory bundle_target)
DESTINATION ${base_directory} TARGET ${bundle_target}
)
+ set_source_files_properties("${LADYBIRD_LICENSES_FILE}" PROPERTIES GENERATED TRUE)
+ copy_resource_set(ladybird RESOURCES "${LADYBIRD_LICENSES_FILE}"
+ DESTINATION ${base_directory} TARGET ${bundle_target}
+ )
+ add_dependencies(${bundle_target} generate_licenses)
+
copy_resource_set(ladybird/about-pages RESOURCES ${ABOUT_PAGES}
DESTINATION ${base_directory} TARGET ${bundle_target}
)
@@ -211,7 +218,8 @@ function(install_ladybird_resources destination component)
if (LADYBIRD_ICU_DATA_FILE)
install(FILES ${LADYBIRD_ICU_DATA_FILE} DESTINATION "${destination}/icu" COMPONENT ${component})
endif()
- install(FILES ${INTERNAL_RESOURCES} DESTINATION "${destination}/ladybird" COMPONENT ${component})
+ install(FILES ${INTERNAL_RESOURCES} "${LADYBIRD_LICENSES_FILE}" DESTINATION "${destination}/ladybird"
+ COMPONENT ${component})
install(FILES ${ABOUT_PAGES} DESTINATION "${destination}/ladybird/about-pages" COMPONENT ${component})
install(FILES ${ABOUT_SETTINGS_RESOURCES} DESTINATION "${destination}/ladybird/about-pages/settings" COMPONENT ${component})
install(FILES ${WEB_TEMPLATES} DESTINATION "${destination}/ladybird/templates" COMPONENT ${component})