Truly independent web browser
Meta+LibWebView+Hub+UI/Qt: Add an option to build without update checks
Jelle Raaijmakers22260494c639
diff --git a/Base/res/ladybird/about-pages/settings.html b/Base/res/ladybird/about-pages/settings.htmlindex df54754683f..bb3ccc09138 100644--- a/Base/res/ladybird/about-pages/settings.html+++ b/Base/res/ladybird/about-pages/settings.html@@ -1320,7 +1320,7 @@<div class="card-group inline-container control-row"><label for="update-checks">Update checks- <p class="description">+ <p id="update-checks-description" class="description">Periodically check whether a newer version of Ladybird is available.</p></label>diff --git a/Base/res/ladybird/about-pages/settings/services.js b/Base/res/ladybird/about-pages/settings/services.jsindex 6c22cdbf56c..df6d57facd0 100644--- a/Base/res/ladybird/about-pages/settings/services.js+++ b/Base/res/ladybird/about-pages/settings/services.js@@ -24,7 +24,14 @@ document.addEventListener("WebUIMessage", event => {allowServicesNetworkAccess.checked = settings.enabled;filterListUpdates.checked = settings.features.contentBlockerSubscriptionUpdates;filterListUpdates.disabled = !settings.enabled;- updateChecks.checked = settings.features.updateChecks;- updateChecks.disabled = !settings.enabled;+ if (Object.hasOwn(settings.features, "updateChecks")) {+ updateChecks.checked = settings.features.updateChecks;+ updateChecks.disabled = !settings.enabled;+ } else {+ updateChecks.checked = false;+ updateChecks.disabled = true;+ document.querySelector("#update-checks-description").textContent =+ "Updates for this build of Ladybird are managed externally.";+ }document.querySelector("#services-paused-note").classList.toggle("hidden", settings.enabled);});diff --git a/Base/res/ladybird/about-pages/welcome.js b/Base/res/ladybird/about-pages/welcome.jsindex c3834248295..5d36dc4bf36 100644--- a/Base/res/ladybird/about-pages/welcome.js+++ b/Base/res/ladybird/about-pages/welcome.js@@ -122,6 +122,12 @@ function updateDefaultBrowser() {else defaultBrowserLabel.removeAttribute("for");}+function updateUpdateChecks() {+ const networkFeatures = settings.backgroundNetworking.features;+ if (Object.hasOwn(networkFeatures, "updateChecks")) enableUpdateChecks.checked = networkFeatures.updateChecks;+ else enableUpdateChecks.closest(".switch-row").remove();+}+function initialize() {if (initialized || !settings || !engines || !features) return;initialized = true;@@ -135,7 +141,7 @@ function initialize() {updateSearchSuggestions();enableContentBlocking.checked = settings.contentBlockers.enabled;- enableUpdateChecks.checked = settings.backgroundNetworking.features.updateChecks;+ updateUpdateChecks();setupOptions.disabled = false;startBrowsing.disabled = false;}@@ -229,8 +235,7 @@ document.addEventListener("WebUIMessage", event => {}if (Object.hasOwn(data, "contentBlockers"))enableContentBlocking.checked = settings.contentBlockers.enabled;- if (Object.hasOwn(data, "backgroundNetworking"))- enableUpdateChecks.checked = settings.backgroundNetworking.features.updateChecks;+ if (Object.hasOwn(data, "backgroundNetworking")) updateUpdateChecks();if (Object.hasOwn(data, "defaultBrowser")) {defaultBrowserFailure = null;updateDefaultBrowser();diff --git a/Documentation/AdvancedBuildInstructions.md b/Documentation/AdvancedBuildInstructions.mdindex 3e13046a0b9..b97e5f8f835 100644--- a/Documentation/AdvancedBuildInstructions.md+++ b/Documentation/AdvancedBuildInstructions.md@@ -33,6 +33,7 @@ There are some optional features that can be enabled during compilation that are- `ENABLE_ALL_THE_DEBUG_MACROS`: used for checking whether debug code compiles on CI. This should not be set normally, as it clutters the console output and makes the system run very slowly. Instead, enable only the needed debug macros, as described below.- `ENABLE_COMPILETIME_FORMAT_CHECK`: checks for the validity of `std::format`-style format string during compilation. Enabled by default.- `ENABLE_JS_JIT`: builds the optimizing JIT for JavaScript. Enabled by default on x86-64 and AArch64 Linux and macOS and on x86-64 Windows, the platforms it generates code for. Without it, LibJS runs JavaScript in its interpreter alone, and the interpreter is built without the feedback collection and tier-up checks that only the JIT needs. See [the configuration of the JIT](../Libraries/LibJS/JIT/ARCHITECTURE.md#13-configuration).+- `LADYBIRD_ENABLE_UPDATE_CHECK`: checks whether a newer release of Ladybird is available. Enabled by default. Without it, Ladybird never downloads the list of releases and has no menu item or notice about updates, and its setting in `about:settings` says that updates are managed externally. Turning it off also turns off `LADYBIRD_ENABLE_SPARKLE`.- `LADYBIRD_ENABLE_SPARKLE`: updates the macOS app with [Sparkle](https://sparkle-project.org). Enabled by default. Without it, vcpkg doesn't build Sparkle, which needs Xcode, and Ladybird links to the release page of a newer version instead of installing it.- `LADYBIRD_BASELINE_CPU_TARGET`: builds C++ and Rust for a common CPU target instead of the build machine. Disabled by default and enabled by the `Distribution` preset; explicitly set `-DLADYBIRD_BASELINE_CPU_TARGET=ON` when packaging binaries for older machines with another configuration. On x86-64 this is x86-64-v2 (SSE4.2 and POPCNT), so distributed binaries run without AVX, AVX2, BMI or LZCNT. Both the JavaScript and WebAssembly JITs remain available; WebAssembly selects newer instructions at runtime when supported.- `INCLUDE_WASM_SPEC_TESTS`: downloads and includes the WebAssembly spec testsuite tests. In order to use this option, you will need to install `prettier` and `wasm-tools`.diff --git a/Libraries/LibWebView/Application.cpp b/Libraries/LibWebView/Application.cppindex ad2ecd2051f..76f9ccfe10b 100644--- a/Libraries/LibWebView/Application.cpp+++ b/Libraries/LibWebView/Application.cpp@@ -174,8 +174,10 @@ struct ApplicationSettingsObserver final : public SettingsObserver {Application::request_server_manager().disk_cache_settings_changed();else if (id == ConfigVariableID::DisableHighDynamicRangeSurfaces)Application::the().update_compositor_high_dynamic_range_surfaces();+#if defined(LADYBIRD_HAS_UPDATE_CHECK)else if (id == ConfigVariableID::UpdateCheckInterval && Application::the().update_checker())Application::the().update_checker()->settings_changed();+#endif}};@@ -763,6 +765,7 @@ ErrorOr<void> Application::initialize(Main::Arguments const& arguments)start_content_blocker_list_update(ContentBlockerListUpdateTrigger::Automatic);}+#if defined(LADYBIRD_HAS_UPDATE_CHECK)// Every profile of this installation shares when it last checked for updates. A temporary profile only checks when// the user asks it to.if (!m_browser_options.headless_mode.has_value() && !m_browser_options.webdriver_browser_endpoint.has_value()) {@@ -773,6 +776,7 @@ ErrorOr<void> Application::initialize(Main::Arguments const& arguments)if (!profile().is_temporary())m_update_checker->start();}+#endifinitialize_page_options();@@ -3205,8 +3209,10 @@ void Application::tab_settings_changed(Badge<ApplicationSettingsObserver>)void Application::background_networking_settings_changed(Badge<ApplicationSettingsObserver>){+#if defined(LADYBIRD_HAS_UPDATE_CHECK)if (m_update_checker)m_update_checker->settings_changed();+#endifif (!m_settings->automatic_filter_list_updates_allowed()) {m_pending_content_blocker_list_updates.remove_all_matching([](auto const& update) { return update.trigger == ContentBlockerListUpdateTrigger::Automatic; });diff --git a/Libraries/LibWebView/Application.h b/Libraries/LibWebView/Application.hindex 628c5acfc64..4f0ac6d6065 100644--- a/Libraries/LibWebView/Application.h+++ b/Libraries/LibWebView/Application.h@@ -339,9 +339,11 @@ public:virtual void display_download_confirmation_dialog(StringView download_name, LexicalPath const& path) const;virtual void display_error_dialog(StringView error_message) const;+#if defined(LADYBIRD_HAS_UPDATE_CHECK)virtual void display_update_check_result(UpdateCheckResult const&, UpdateCheckTrigger) { }UpdateChecker* update_checker() { return m_update_checker.ptr(); }+#endif// FIXME: We should implement UI-agnostic platform APIs to interact with the system clipboard.enum class ClipboardType : u8 {@@ -640,7 +642,9 @@ private:Optional<Core::AnonymousBuffer> m_content_blocker_list_buffer;RefPtr<Core::Timer> m_content_blocker_list_update_timer;ByteString m_instance_data_directory;+#if defined(LADYBIRD_HAS_UPDATE_CHECK)OwnPtr<UpdateChecker> m_update_checker;+#endifstruct PendingContentBlockerListUpdate {String identifier;String name;diff --git a/Libraries/LibWebView/CMakeLists.txt b/Libraries/LibWebView/CMakeLists.txtindex 6a86dcd562d..008e7d92b8b 100644--- a/Libraries/LibWebView/CMakeLists.txt+++ b/Libraries/LibWebView/CMakeLists.txt@@ -178,6 +178,10 @@ add_custom_target(generate_build_information DEPENDS ${build_information_stamp})ladybird_lib(LibWebView webview EXPLICIT_SYMBOL_EXPORT)add_dependencies(LibWebView generate_build_information)+if (LADYBIRD_ENABLE_UPDATE_CHECK)+ target_compile_definitions(LibWebView PUBLIC LADYBIRD_HAS_UPDATE_CHECK)+endif()+target_link_libraries(LibWebView PUBLIC LibCompositing LibPlatformFeatures LibSandbox LibWebCommon)target_link_libraries(LibWebView PRIVATE LibCore LibCrypto LibDatabase LibDevTools LibFileSystem LibGfx LibHTTP LibImageDecoderClient LibIPC LibRequests LibMedia LibMediaClient LibUnicode LibURL LibTextCodec LibThreading)diff --git a/Libraries/LibWebView/Settings.cpp b/Libraries/LibWebView/Settings.cppindex f13fb7f7b0d..5afb3756a75 100644--- a/Libraries/LibWebView/Settings.cpp+++ b/Libraries/LibWebView/Settings.cpp@@ -89,7 +89,9 @@ static constexpr auto CRASH_REPORT_SENDING_KEY = "crashReportSending"sv;static constexpr auto BACKGROUND_NETWORKING_KEY = "backgroundNetworking"sv;static constexpr auto BACKGROUND_NETWORKING_ENABLED_KEY = "enabled"sv;static constexpr auto BACKGROUND_NETWORKING_FEATURES_KEY = "features"sv;+#if defined(LADYBIRD_HAS_UPDATE_CHECK)static constexpr auto UPDATE_CHECKS_KEY = "updateChecks"sv;+#endifstatic constexpr auto CONTENT_BLOCKERS_KEY = "contentBlockers"sv;static constexpr auto CONTENT_BLOCKER_SUBSCRIPTION_UPDATES_KEY = "contentBlockerSubscriptionUpdates"sv;@@ -210,6 +212,7 @@ static auto const& CONFIG_VARIABLE_DEFINITIONS = *new Array<ConfigVariableDefini.default_value = false,.array_element_type = {},},+#if defined(LADYBIRD_HAS_UPDATE_CHECK){.id = ConfigVariableID::UpdateCheckInterval,.name = "updates.check_interval_minutes"sv,@@ -218,6 +221,7 @@ static auto const& CONFIG_VARIABLE_DEFINITIONS = *new Array<ConfigVariableDefini.default_value = 4 * 60,.array_element_type = {},},+#endif} };ReadonlySpan<ConfigVariableDefinition> config_variable_definitions()@@ -416,10 +420,12 @@ static bool config_variable_value_is_valid(ConfigVariableDefinition const& variareturn milliseconds.has_value() && *milliseconds >= 0 && value.get_double_with_precision_loss().value() == *milliseconds;}+#if defined(LADYBIRD_HAS_UPDATE_CHECK)if (variable.id == ConfigVariableID::UpdateCheckInterval) {auto minutes = value.get_integer<u32>();return minutes.has_value() && *minutes >= 5 && value.get_double_with_precision_loss() == minutes;}+#endifif (variable.id == ConfigVariableID::MaximumDiskCacheSize) {auto size = value.get_integer<u64>();@@ -536,8 +542,10 @@ void Settings::load_from_json(JsonValue const& json_value)if (auto features = background_networking->get_object(BACKGROUND_NETWORKING_FEATURES_KEY); features.has_value()) {if (auto filter_list_updates_enabled = features->get_bool(CONTENT_BLOCKER_SUBSCRIPTION_UPDATES_KEY); filter_list_updates_enabled.has_value())m_filter_list_updates_enabled = *filter_list_updates_enabled;+#if defined(LADYBIRD_HAS_UPDATE_CHECK)if (auto update_checks_enabled = features->get_bool(UPDATE_CHECKS_KEY); update_checks_enabled.has_value())m_update_checks_enabled = *update_checks_enabled;+#endif}}@@ -929,7 +937,9 @@ JsonValue Settings::serialize_json() constJsonObject background_network_features;background_network_features.set(CONTENT_BLOCKER_SUBSCRIPTION_UPDATES_KEY, m_filter_list_updates_enabled);+#if defined(LADYBIRD_HAS_UPDATE_CHECK)background_network_features.set(UPDATE_CHECKS_KEY, m_update_checks_enabled);+#endifJsonObject background_networking;background_networking.set(BACKGROUND_NETWORKING_ENABLED_KEY, m_background_networking_enabled);@@ -1569,6 +1579,7 @@ void Settings::set_filter_list_updates_enabled(bool enabled)observer.background_networking_settings_changed();}+#if defined(LADYBIRD_HAS_UPDATE_CHECK)void Settings::set_update_checks_enabled(bool enabled){if (m_update_checks_enabled == enabled)@@ -1580,6 +1591,7 @@ void Settings::set_update_checks_enabled(bool enabled)for (auto& observer : m_observers)observer.background_networking_settings_changed();}+#endifOptional<ContentBlockerList const&> Settings::content_blocker_list(StringView identifier) const{diff --git a/Libraries/LibWebView/Settings.h b/Libraries/LibWebView/Settings.hindex 5bc74ce7d21..798e2eee146 100644--- a/Libraries/LibWebView/Settings.h+++ b/Libraries/LibWebView/Settings.h@@ -167,7 +167,9 @@ enum class ConfigVariableID : u8 {SplitDownloadsWithoutValidators,RestartStalledConnections,DisableHighDynamicRangeSurfaces,+#if defined(LADYBIRD_HAS_UPDATE_CHECK)UpdateCheckInterval,+#endifCount,};@@ -239,7 +241,9 @@ struct WEBVIEW_API SettingsData {bool m_background_networking_enabled { true };bool m_filter_list_updates_enabled { false };+#if defined(LADYBIRD_HAS_UPDATE_CHECK)bool m_update_checks_enabled { true };+#endifbool m_content_blocker_enabled { false };HashTable<String> m_content_blocker_disabled_sites;Vector<ContentBlockerList> m_content_blocker_lists;@@ -354,9 +358,11 @@ public:bool filter_list_updates_enabled() const { return m_filter_list_updates_enabled; }bool automatic_filter_list_updates_allowed() const { return m_background_networking_enabled && m_filter_list_updates_enabled; }void set_filter_list_updates_enabled(bool);+#if defined(LADYBIRD_HAS_UPDATE_CHECK)bool update_checks_enabled() const { return m_update_checks_enabled; }bool automatic_update_checks_allowed() const { return m_background_networking_enabled && m_update_checks_enabled; }void set_update_checks_enabled(bool);+#endifbool content_blocker_enabled() const { return m_content_blocker_enabled; }void set_content_blocker_enabled(bool);diff --git a/Libraries/LibWebView/UpdateCheck.cpp b/Libraries/LibWebView/UpdateCheck.cppindex 3663564943c..c72fd92818b 100644--- a/Libraries/LibWebView/UpdateCheck.cpp+++ b/Libraries/LibWebView/UpdateCheck.cpp@@ -34,12 +34,14 @@# include <sys/sysctl.h>#endif-#if defined(AK_OS_WINDOWS)+#if defined(AK_OS_WINDOWS) && defined(LADYBIRD_HAS_UPDATE_CHECK)# include <AK/Windows.h>#endifnamespace WebView {+#if defined(LADYBIRD_HAS_UPDATE_CHECK)+static constexpr size_t maximum_feed_size = 4 * MiB;static constexpr auto request_timeout = AK::Duration::from_seconds(30);@@ -92,6 +94,8 @@ bool is_newer_version(StringView candidate, StringView current)return compare_versions(*candidate_version, *current_version) > 0;}+#endif+// https://www.freedesktop.org/software/systemd/man/latest/os-release.htmlOSRelease parse_os_release(StringView contents){@@ -179,7 +183,7 @@ static Optional<String> current_macos_version()#endif}-#if defined(AK_OS_WINDOWS)+#if defined(AK_OS_WINDOWS) && defined(LADYBIRD_HAS_UPDATE_CHECK)// GetVersionEx reports an older version of Windows to an application that does not declare in its manifest that it// supports the newer one. RtlGetVersion always reports the version that runs.static Optional<String> current_windows_version()@@ -219,6 +223,8 @@ SystemDescription describe_current_system()return system;}+#if defined(LADYBIRD_HAS_UPDATE_CHECK)+// releases.json names architectures the way that each kind of package does.static Optional<StringView> architecture_name(InstallMethod install_method, Architecture architecture){@@ -419,21 +425,21 @@ static ByteString update_check_header(SystemDescription const& system, StringVieStringBuilder builder;append_string_member(builder, "version"sv, browser_version);-#if defined(AK_OS_MACOS)+# if defined(AK_OS_MACOS)append_member(builder, "os"sv, "macos"sv);if (system.macos_version.has_value())append_string_member(builder, "os-version"sv, system.macos_version->bytes_as_string_view().find_first_split_view('.'));-#elif defined(AK_OS_LINUX)+# elif defined(AK_OS_LINUX)append_member(builder, "os"sv, "linux"sv);if (system.os_release.version_id.has_value())append_string_member(builder, "os-version"sv, *system.os_release.version_id);if (system.os_release.id.has_value())append_string_member(builder, "distro"sv, *system.os_release.id);-#elif defined(AK_OS_WINDOWS)+# elif defined(AK_OS_WINDOWS)append_member(builder, "os"sv, "windows"sv);if (auto windows_version = current_windows_version(); windows_version.has_value())append_string_member(builder, "os-version"sv, *windows_version);-#endif+# endifif (system.architecture == Architecture::X86_64)append_member(builder, "arch"sv, "x86_64"sv);@@ -747,4 +753,6 @@ void UpdateChecker::skip_version(String const& version)write_state(state);}+#endif+}diff --git a/Libraries/LibWebView/UpdateCheck.h b/Libraries/LibWebView/UpdateCheck.hindex ed0857d759a..8b73bd4f1ba 100644--- a/Libraries/LibWebView/UpdateCheck.h+++ b/Libraries/LibWebView/UpdateCheck.h@@ -70,13 +70,16 @@ struct UpdateCheckResult {Optional<AvailableUpdate> update;};+WEBVIEW_API OSRelease parse_os_release(StringView);+WEBVIEW_API Optional<InstallMethod> parse_package_format(StringView);+WEBVIEW_API SystemDescription describe_current_system();++#if defined(LADYBIRD_HAS_UPDATE_CHECK)+constexpr StringView RELEASES_FEED_URL = "https://download.ladybird.org/releases.json"sv;WEBVIEW_API Optional<Vector<u64>> parse_version(StringView);WEBVIEW_API bool is_newer_version(StringView candidate, StringView current);-WEBVIEW_API OSRelease parse_os_release(StringView);-WEBVIEW_API Optional<InstallMethod> parse_package_format(StringView);-WEBVIEW_API SystemDescription describe_current_system();WEBVIEW_API ErrorOr<Optional<String>> newest_release_for_system(StringView releases_json, SystemDescription const&, Optional<UnixDateTime> published_before = {});WEBVIEW_API AK::Duration time_until_next_update_check(UnixDateTime last_check, UnixDateTime now, AK::Duration interval);WEBVIEW_API String release_page_url(StringView version);@@ -130,4 +133,6 @@ private:Vector<UpdateCheckTrigger> m_waiting_triggers;};+#endif+}diff --git a/Libraries/LibWebView/WebUI/SettingsUI.cpp b/Libraries/LibWebView/WebUI/SettingsUI.cppindex 61cacbd255c..6969e29d183 100644--- a/Libraries/LibWebView/WebUI/SettingsUI.cpp+++ b/Libraries/LibWebView/WebUI/SettingsUI.cpp@@ -113,9 +113,11 @@ void SettingsUI::register_interfaces()register_interface("setFilterListUpdatesEnabled"sv, [this](auto const& data) {set_filter_list_updates_enabled(data);});+#if defined(LADYBIRD_HAS_UPDATE_CHECK)register_interface("setUpdateChecksEnabled"sv, [this](auto const& data) {set_update_checks_enabled(data);});+#endifregister_interface("setAppearance"sv, [this](auto const& data) {set_appearance(data);});@@ -766,6 +768,7 @@ void SettingsUI::set_filter_list_updates_enabled(JsonValue const& enabled)Application::settings().set_filter_list_updates_enabled(enabled.as_bool());}+#if defined(LADYBIRD_HAS_UPDATE_CHECK)void SettingsUI::set_update_checks_enabled(JsonValue const& enabled){if (!enabled.is_bool())@@ -773,6 +776,7 @@ void SettingsUI::set_update_checks_enabled(JsonValue const& enabled)Application::settings().set_update_checks_enabled(enabled.as_bool());}+#endifvoid SettingsUI::update_content_blocker_lists(JsonValue const&){diff --git a/Libraries/LibWebView/WebUI/SettingsUI.h b/Libraries/LibWebView/WebUI/SettingsUI.hindex b2d83cce2e1..e1b01836763 100644--- a/Libraries/LibWebView/WebUI/SettingsUI.h+++ b/Libraries/LibWebView/WebUI/SettingsUI.h@@ -102,7 +102,9 @@ private:void set_services_network_access_enabled(JsonValue const&);void set_filter_list_updates_enabled(JsonValue const&);+#if defined(LADYBIRD_HAS_UPDATE_CHECK)void set_update_checks_enabled(JsonValue const&);+#endifvoid update_content_blocker_lists(JsonValue const&);void set_content_blocker_enabled(JsonValue const&);void set_content_blocker_enabled_for_site(JsonValue const&);diff --git a/Meta/CMake/cmake_options.cmake b/Meta/CMake/cmake_options.cmakeindex f48605c5952..2606d5c3f2c 100644--- a/Meta/CMake/cmake_options.cmake+++ b/Meta/CMake/cmake_options.cmake@@ -36,7 +36,12 @@ option(ENABLE_GUI_TARGETS "Enable building GUI targets" ON)option(ENABLE_INSTALL_HEADERS "Enable installing headers" ON)option(ENABLE_INSTALL_FREEDESKTOP_FILES "Enable installing .desktop and .service files" ${freedesktop_files_default})option(LADYBIRD_ENABLE_CPPTRACE "Enable use of cpptrace as the default library for stacktraces. If not available falls back to backtrace.h" ON)+option(LADYBIRD_ENABLE_UPDATE_CHECK "Check for newer releases of Ladybird" ON)option(LADYBIRD_ENABLE_SPARKLE "Update the macOS app with Sparkle" ON)+if (NOT LADYBIRD_ENABLE_UPDATE_CHECK)+ # Sparkle only installs the releases that the update check finds.+ set(LADYBIRD_ENABLE_SPARKLE OFF)+endif()option(LADYBIRD_GENERATE_DSYM "Generate dSYM bundles for binaries and libraries (macOS only)" OFF)option(LADYBIRD_GENERATE_SYMBOL_FILES "Build with debug info and write the symbols of the installed executables to separate files" OFF)if (LADYBIRD_GENERATE_SYMBOL_FILES AND MSVC)diff --git a/Meta/CMake/environment.cmake b/Meta/CMake/environment.cmakeindex 4cb35a981db..f8dfa87c96a 100644--- a/Meta/CMake/environment.cmake+++ b/Meta/CMake/environment.cmake@@ -23,7 +23,8 @@ if (DEFINED LADYBIRD_VCPKG_TYPE)# Each optional dependency is a feature of vcpkg.json that an option selects. The options are declared after# project(), so one that is not set yet has its default. Keep in sync with MANIFEST_FEATURE_OPTIONS in# Meta/Utils/vcpkg_deps.py.- if (NOT DEFINED LADYBIRD_ENABLE_SPARKLE OR LADYBIRD_ENABLE_SPARKLE)+ if ((NOT DEFINED LADYBIRD_ENABLE_UPDATE_CHECK OR LADYBIRD_ENABLE_UPDATE_CHECK)+ AND (NOT DEFINED LADYBIRD_ENABLE_SPARKLE OR LADYBIRD_ENABLE_SPARKLE))list(APPEND VCPKG_MANIFEST_FEATURES "sparkle")endif()diff --git a/Meta/Utils/vcpkg_deps.py b/Meta/Utils/vcpkg_deps.pyindex 4764e687b5d..150d8114723 100644--- a/Meta/Utils/vcpkg_deps.py+++ b/Meta/Utils/vcpkg_deps.py@@ -24,9 +24,10 @@ from Utils.host_platform import HostArchitecture # noqa: E402from Utils.host_platform import HostSystem # noqa: E402from Utils.host_platform import Platform # noqa: E402-# The CMake options that each select a feature of vcpkg.json. Keep in sync with Meta/CMake/environment.cmake.+# The features of vcpkg.json, each with the CMake options that all have to be on to select it. Keep in sync with+# Meta/CMake/environment.cmake.MANIFEST_FEATURE_OPTIONS = {- "LADYBIRD_ENABLE_SPARKLE": "sparkle",+ "sparkle": ("LADYBIRD_ENABLE_UPDATE_CHECK", "LADYBIRD_ENABLE_SPARKLE"),}DEPEND_INFO_REGEX = re.compile(r"^([a-zA-Z0-9-]+)(?:\[([^]]*)\])?(:host)?:\s*(.*)$")@@ -173,8 +174,8 @@ def manifest_feature_arguments(build_dir: Path) -> list[str]:return [f"--x-feature={feature}"- for option, feature in MANIFEST_FEATURE_OPTIONS.items()- if cmake_option_is_on(cache, option)+ for feature, options in MANIFEST_FEATURE_OPTIONS.items()+ if all(cmake_option_is_on(cache, option) for option in options)]diff --git a/Services/Hub/Application.cpp b/Services/Hub/Application.cppindex 7070c7e5767..68afca87ebb 100644--- a/Services/Hub/Application.cpp+++ b/Services/Hub/Application.cpp@@ -247,6 +247,7 @@ void Application::display_error_dialog(StringView error_message) constWebView::Application::display_error_dialog(error_message);}+#if defined(LADYBIRD_HAS_UPDATE_CHECK)void Application::display_update_check_result(WebView::UpdateCheckResult const& result, WebView::UpdateCheckTrigger trigger){auto* ui = ConnectionFromUI::the();@@ -261,6 +262,7 @@ void Application::display_update_check_result(WebView::UpdateCheckResult const&}ui->async_app_display_update_check_result(result.kind, move(version), install_method, trigger);}+#endifvoid Application::set_clipboard_text(String text, ClipboardType type){diff --git a/Services/Hub/Application.h b/Services/Hub/Application.hindex 94ea5caa379..9e0f0e30f91 100644--- a/Services/Hub/Application.h+++ b/Services/Hub/Application.h@@ -92,7 +92,9 @@ private:virtual NonnullRefPtr<Core::Promise<ByteString>> ask_user_for_download_path(ByteString const& file) const override;virtual void display_download_confirmation_dialog(StringView download_name, LexicalPath const& path) const override;virtual void display_error_dialog(StringView error_message) const override;+#if defined(LADYBIRD_HAS_UPDATE_CHECK)virtual void display_update_check_result(WebView::UpdateCheckResult const&, WebView::UpdateCheckTrigger) override;+#endifvirtual void set_clipboard_text(String, ClipboardType) override;virtual void insert_clipboard_item(Web::Clipboard::SystemClipboardItem) override;virtual void read_clipboard_text(ClipboardType, Function<void(Utf16String)>) const override;diff --git a/Services/Hub/ConnectionFromUI.cpp b/Services/Hub/ConnectionFromUI.cppindex d2594b40bcd..091b2893bd2 100644--- a/Services/Hub/ConnectionFromUI.cpp+++ b/Services/Hub/ConnectionFromUI.cpp@@ -689,16 +689,20 @@ void ConnectionFromUI::stop_request(u64 request_id)(*request)->stop();}-void ConnectionFromUI::check_for_updates(WebView::UpdateCheckTrigger trigger)+void ConnectionFromUI::check_for_updates([[maybe_unused]] WebView::UpdateCheckTrigger trigger){+#if defined(LADYBIRD_HAS_UPDATE_CHECK)if (auto* update_checker = Application::the().update_checker())update_checker->check(trigger);+#endif}-void ConnectionFromUI::skip_update_version(String version)+void ConnectionFromUI::skip_update_version([[maybe_unused]] String version){+#if defined(LADYBIRD_HAS_UPDATE_CHECK)if (auto* update_checker = Application::the().update_checker())update_checker->skip_version(version);+#endif}void ConnectionFromUI::toggle_devtools_enabled()diff --git a/Tests/LibWebView/CMakeLists.txt b/Tests/LibWebView/CMakeLists.txtindex e6c9b65f69c..2027b0fccca 100644--- a/Tests/LibWebView/CMakeLists.txt+++ b/Tests/LibWebView/CMakeLists.txt@@ -96,12 +96,15 @@ set(TEST_SOURCESTestStorageJar.cppTestTabIndicators.cppTestTabPerformanceStats.cpp- TestUpdateCheck.cppTestWebDriverBiDiNetwork.cppTestWebViewURL.cppTestWebWorkerClient.cpp)+if (LADYBIRD_ENABLE_UPDATE_CHECK)+ list(APPEND TEST_SOURCES TestUpdateCheck.cpp)+endif()+if (APPLE OR LINUX)list(APPEND TEST_SOURCESTestCrashReport.cppdiff --git a/Tests/LibWebView/TestBackgroundNetworking.cpp b/Tests/LibWebView/TestBackgroundNetworking.cppindex b863a54bed6..94bf41e94d7 100644--- a/Tests/LibWebView/TestBackgroundNetworking.cpp+++ b/Tests/LibWebView/TestBackgroundNetworking.cpp@@ -74,6 +74,7 @@ TEST_CASE(feature_policy)remove_settings_file();}+#if defined(LADYBIRD_HAS_UPDATE_CHECK)TEST_CASE(update_check_policy){remove_settings_file();@@ -101,6 +102,7 @@ TEST_CASE(update_check_policy)EXPECT_EQ(reloaded.config_variable_as_integer<u32>(WebView::ConfigVariableID::UpdateCheckInterval), 5u);remove_settings_file();}+#endifTEST_CASE(settings_are_persistent){diff --git a/UI/Qt/Application.cpp b/UI/Qt/Application.cppindex c5a63902179..147ee8b03f2 100644--- a/UI/Qt/Application.cpp+++ b/UI/Qt/Application.cpp@@ -552,6 +552,7 @@ public:m_help_menu->addSeparator();m_help_menu->addAction(create_application_action(*m_application_widget, application.open_about_page_action(), IncludeActionIcon::No));+#if defined(LADYBIRD_HAS_UPDATE_CHECK)auto* check_for_updates_action = make_action("Check for Updates…");// NB: On macOS, this moves the item into the application menu, below About Ladybird.check_for_updates_action->setMenuRole(QAction::ApplicationSpecificRole);@@ -559,13 +560,18 @@ public:HubConnection::the().async_check_for_updates(WebView::UpdateCheckTrigger::UserInitiated);});m_help_menu->addAction(check_for_updates_action);+#endif+#if defined(LADYBIRD_HAS_UPDATE_CHECK) || defined(AK_OS_LINUX)+ m_debug_menu->addSeparator();+#endif+#if defined(LADYBIRD_HAS_UPDATE_CHECK)auto* simulate_update_action = make_action("Simulate Available Update");QObject::connect(simulate_update_action, &QAction::triggered, this, [] {HubConnection::the().async_check_for_updates(WebView::UpdateCheckTrigger::Debug);});- m_debug_menu->addSeparator();m_debug_menu->addAction(simulate_update_action);+#endif#if defined(AK_OS_LINUX)auto* simulate_replaced_installation_action = make_action("Simulate Replaced Installation");QObject::connect(simulate_replaced_installation_action, &QAction::triggered, this, [] {@@ -2442,6 +2448,7 @@ void Application::display_error_dialog(StringView error_message) constcreate_message_box(QMessageBox::Warning, error_message, active_window_if_any())->open();}+#if defined(LADYBIRD_HAS_UPDATE_CHECK)void Application::display_update_check_result(WebView::UpdateCheckResult::Kind kind, Optional<String> const& version, WebView::InstallMethod install_method, WebView::UpdateCheckTrigger trigger){static constexpr auto current_version = BROWSER_VERSION ""sv;@@ -2489,7 +2496,7 @@ void Application::display_update_check_result(WebView::UpdateCheckResult::Kind kif (first_is_one_of(install_method, WebView::InstallMethod::DEB, WebView::InstallMethod::RPM, WebView::InstallMethod::Flatpak)) {text = qformatted("You have Ladybird {}. Update it with your system's software updater.", current_version);buttons.append({ "Remind me later", PageCard::ButtonRole::Primary, {} });-#if defined(LADYBIRD_HAS_SPARKLE)+# if defined(LADYBIRD_HAS_SPARKLE)} else if (install_method == WebView::InstallMethod::MacOSApp) {buttons.append({ "Remind me later", PageCard::ButtonRole::Secondary, {} });buttons.append({ "Install update", PageCard::ButtonRole::Primary, [trigger] {@@ -2501,7 +2508,7 @@ void Application::display_update_check_result(WebView::UpdateCheckResult::Kind kelsesoftware_updater->install_update();} });-#endif+# endif} else {buttons.append({ "Remind me later", PageCard::ButtonRole::Secondary, {} });buttons.append({ "View release", PageCard::ButtonRole::Primary, [url = WebView::release_page_url(*version)] {@@ -2512,6 +2519,7 @@ void Application::display_update_check_result(WebView::UpdateCheckResult::Kind kwindow->show_page_card(BrowserWindow::PageCardSlot::Update, qformatted("Ladybird {} is available", *version), text, move(buttons));}+#endif#if defined(AK_OS_LINUX)// The system replaces the files of a package that it updates while Ladybird runs from the ones that it started with. Thediff --git a/UI/Qt/Application.h b/UI/Qt/Application.hindex 43dbe23dcb2..ceb9bf403bd 100644--- a/UI/Qt/Application.h+++ b/UI/Qt/Application.h@@ -278,7 +278,9 @@ private:void ask_user_for_download_path(u64 request_id, ByteString const& file) const;void display_download_confirmation_dialog(StringView download_name, ByteString const& path) const;void display_error_dialog(StringView error_message) const;+#if defined(LADYBIRD_HAS_UPDATE_CHECK)void display_update_check_result(WebView::UpdateCheckResult::Kind, Optional<String> const& version, WebView::InstallMethod, WebView::UpdateCheckTrigger);+#endifvoid open_file(String const& path) const;virtual void crash_reports_changed() override;diff --git a/UI/Qt/HubConnection.cpp b/UI/Qt/HubConnection.cppindex d33933d6f87..8b16aa305c7 100644--- a/UI/Qt/HubConnection.cpp+++ b/UI/Qt/HubConnection.cpp@@ -348,9 +348,11 @@ void HubConnection::app_display_error_dialog(String message)Application::the().display_error_dialog(message);}-void HubConnection::app_display_update_check_result(WebView::UpdateCheckResult::Kind kind, Optional<String> version, WebView::InstallMethod install_method, WebView::UpdateCheckTrigger trigger)+void HubConnection::app_display_update_check_result([[maybe_unused]] WebView::UpdateCheckResult::Kind kind, [[maybe_unused]] Optional<String> version, [[maybe_unused]] WebView::InstallMethod install_method, [[maybe_unused]] WebView::UpdateCheckTrigger trigger){+#if defined(LADYBIRD_HAS_UPDATE_CHECK)Application::the().display_update_check_result(kind, version, install_method, trigger);+#endif}void HubConnection::app_display_download_confirmation_dialog(String download_name, ByteString path)