From a443f508079971489af1f81265857417f617963e Mon Sep 17 00:00:00 2001 From: circl Date: Mon, 15 Jul 2024 18:00:14 +0200 Subject: [PATCH] Base: Move config files out of home/anon and into default-config --- .../BrowserAutoplayAllowlist.txt | 0 .../default-config}/BrowserContentFilters.txt | 0 .../ladybird/default-config}/bookmarks.json | 0 .../src/main/cpp/WebContentService.cpp | 8 ++--- Ladybird/WebContent/main.cpp | 4 +-- Ladybird/cmake/AndroidExtras.cmake | 12 +------ Ladybird/cmake/ResourceFiles.cmake | 7 ++-- Meta/gn/secondary/Ladybird/BUILD.gn | 32 +++++++++++++++---- 8 files changed, 34 insertions(+), 29 deletions(-) rename Base/{home/anon/.config => res/ladybird/default-config}/BrowserAutoplayAllowlist.txt (100%) rename Base/{home/anon/.config => res/ladybird/default-config}/BrowserContentFilters.txt (100%) rename Base/{home/anon/.config => res/ladybird/default-config}/bookmarks.json (100%) diff --git a/Base/home/anon/.config/BrowserAutoplayAllowlist.txt b/Base/res/ladybird/default-config/BrowserAutoplayAllowlist.txt similarity index 100% rename from Base/home/anon/.config/BrowserAutoplayAllowlist.txt rename to Base/res/ladybird/default-config/BrowserAutoplayAllowlist.txt diff --git a/Base/home/anon/.config/BrowserContentFilters.txt b/Base/res/ladybird/default-config/BrowserContentFilters.txt similarity index 100% rename from Base/home/anon/.config/BrowserContentFilters.txt rename to Base/res/ladybird/default-config/BrowserContentFilters.txt diff --git a/Base/home/anon/.config/bookmarks.json b/Base/res/ladybird/default-config/bookmarks.json similarity index 100% rename from Base/home/anon/.config/bookmarks.json rename to Base/res/ladybird/default-config/bookmarks.json diff --git a/Ladybird/Android/src/main/cpp/WebContentService.cpp b/Ladybird/Android/src/main/cpp/WebContentService.cpp index e03cfc99660..19e63b22ac8 100644 --- a/Ladybird/Android/src/main/cpp/WebContentService.cpp +++ b/Ladybird/Android/src/main/cpp/WebContentService.cpp @@ -106,9 +106,7 @@ ErrorOr> bind_service(void (*bind_method)(int)) static ErrorOr load_content_filters() { - auto file_or_error = Core::File::open(ByteString::formatted("{}/home/anon/.config/BrowserContentFilters.txt", s_serenity_resource_root), Core::File::OpenMode::Read); - if (file_or_error.is_error()) - file_or_error = Core::File::open(ByteString::formatted("{}/res/ladybird/BrowserContentFilters.txt", s_serenity_resource_root), Core::File::OpenMode::Read); + auto file_or_error = Core::File::open(ByteString::formatted("{}/res/ladybird/default-config/BrowserContentFilters.txt", s_serenity_resource_root), Core::File::OpenMode::Read); if (file_or_error.is_error()) return file_or_error.release_error(); @@ -135,9 +133,7 @@ static ErrorOr load_content_filters() static ErrorOr load_autoplay_allowlist() { - auto file_or_error = Core::File::open(TRY(String::formatted("{}/home/anon/.config/BrowserAutoplayAllowlist.txt", s_serenity_resource_root)), Core::File::OpenMode::Read); - if (file_or_error.is_error()) - file_or_error = Core::File::open(TRY(String::formatted("{}/res/ladybird/BrowserAutoplayAllowlist.txt", s_serenity_resource_root)), Core::File::OpenMode::Read); + auto file_or_error = Core::File::open(TRY(String::formatted("{}/res/ladybird/default-config/BrowserAutoplayAllowlist.txt", s_serenity_resource_root)), Core::File::OpenMode::Read); if (file_or_error.is_error()) return file_or_error.release_error(); diff --git a/Ladybird/WebContent/main.cpp b/Ladybird/WebContent/main.cpp index 4fcbe169e9d..cd25d3a582a 100644 --- a/Ladybird/WebContent/main.cpp +++ b/Ladybird/WebContent/main.cpp @@ -197,7 +197,7 @@ static ErrorOr load_content_filters() { auto buffer = TRY(ByteBuffer::create_uninitialized(4096)); - auto resource = TRY(Core::Resource::load_from_uri("resource://ladybird/BrowserContentFilters.txt"sv)); + auto resource = TRY(Core::Resource::load_from_uri("resource://ladybird/default-config/BrowserContentFilters.txt"sv)); auto ad_filter_list = TRY(InputBufferedSeekable::create(make(resource->data()))); Vector patterns; @@ -221,7 +221,7 @@ static ErrorOr load_autoplay_allowlist() { auto buffer = TRY(ByteBuffer::create_uninitialized(4096)); - auto resource = TRY(Core::Resource::load_from_uri("resource://ladybird/BrowserAutoplayAllowlist.txt"sv)); + auto resource = TRY(Core::Resource::load_from_uri("resource://ladybird/default-config/BrowserAutoplayAllowlist.txt"sv)); auto allowlist = TRY(InputBufferedSeekable::create(make(resource->data()))); Vector origins; diff --git a/Ladybird/cmake/AndroidExtras.cmake b/Ladybird/cmake/AndroidExtras.cmake index 9d469c7a63a..c15229609e5 100644 --- a/Ladybird/cmake/AndroidExtras.cmake +++ b/Ladybird/cmake/AndroidExtras.cmake @@ -22,22 +22,12 @@ copy_res_folder(fonts) copy_res_folder(icons) copy_res_folder(emoji) copy_res_folder(themes) -add_custom_target(copy-autoplay-allowlist - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${LADYBIRD_SOURCE_DIR}/Base/home/anon/.config/BrowserAutoplayAllowlist.txt" - "asset-bundle/res/ladybird/BrowserAutoplayAllowlist.txt" -) -add_custom_target(copy-content-filters - COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${LADYBIRD_SOURCE_DIR}/Base/home/anon/.config/BrowserContentFilters.txt" - "asset-bundle/res/ladybird/BrowserContentFilters.txt" -) add_custom_target(copy-certs COMMAND ${CMAKE_COMMAND} -E copy_if_different "${Lagom_BINARY_DIR}/cacert.pem" "asset-bundle/res/ladybird/cacert.pem" ) -add_dependencies(archive-assets copy-autoplay-allowlist copy-content-filters copy-certs) +add_dependencies(archive-assets copy-certs) add_custom_target(copy-assets COMMAND ${CMAKE_COMMAND} -E copy_if_different ladybird-assets.tar "${CMAKE_SOURCE_DIR}/Ladybird/Android/src/main/assets/") add_dependencies(copy-assets archive-assets) add_dependencies(ladybird copy-assets) diff --git a/Ladybird/cmake/ResourceFiles.cmake b/Ladybird/cmake/ResourceFiles.cmake index a698ee6b149..ca5b6743f50 100644 --- a/Ladybird/cmake/ResourceFiles.cmake +++ b/Ladybird/cmake/ResourceFiles.cmake @@ -82,10 +82,11 @@ set(THEMES list(TRANSFORM THEMES PREPEND "${LADYBIRD_SOURCE_DIR}/Base/res/themes/") set(CONFIG_RESOURCES + bookmarks.json BrowserAutoplayAllowlist.txt BrowserContentFilters.txt ) -list(TRANSFORM CONFIG_RESOURCES PREPEND "${LADYBIRD_SOURCE_DIR}/Base/home/anon/.config/") +list(TRANSFORM CONFIG_RESOURCES PREPEND "${LADYBIRD_SOURCE_DIR}/Base/res/ladybird/default-config/") set(DOWNLOADED_RESOURCES cacert.pem @@ -168,7 +169,7 @@ function(copy_resources_to_build base_directory bundle_target) DESTINATION ${base_directory} TARGET ${bundle_target} ) - copy_resource_set(ladybird RESOURCES ${CONFIG_RESOURCES} + copy_resource_set(ladybird/default-config RESOURCES ${CONFIG_RESOURCES} DESTINATION ${base_directory} TARGET ${bundle_target} ) @@ -190,6 +191,6 @@ function(install_ladybird_resources destination component) install(FILES ${THEMES} DESTINATION "${destination}/themes" COMPONENT ${component}) install(FILES ${WEB_RESOURCES} DESTINATION "${destination}/ladybird" COMPONENT ${component}) install(FILES ${WEB_TEMPLATES} DESTINATION "${destination}/ladybird/templates" COMPONENT ${component}) - install(FILES ${CONFIG_RESOURCES} DESTINATION "${destination}/ladybird" COMPONENT ${component}) + install(FILES ${CONFIG_RESOURCES} DESTINATION "${destination}/ladybird/default-config" COMPONENT ${component}) install(FILES ${DOWNLOADED_RESOURCES} DESTINATION "${destination}/ladybird" COMPONENT ${component}) endfunction() diff --git a/Meta/gn/secondary/Ladybird/BUILD.gn b/Meta/gn/secondary/Ladybird/BUILD.gn index 504f00dba7c..15cfb5c0d72 100644 --- a/Meta/gn/secondary/Ladybird/BUILD.gn +++ b/Meta/gn/secondary/Ladybird/BUILD.gn @@ -155,6 +155,7 @@ executable("ladybird_executable") { deps += [ "//Userland/Libraries/LibThreading" ] } else { data_deps += [ + ":ladybird_copy_cacert", ":ladybird_copy_config_resources", ":ladybird_copy_emoji", ":ladybird_copy_fonts", @@ -279,10 +280,12 @@ web_templates = [ "//Base/res/ladybird/templates/version.html", ] +cacert = [ "$root_build_dir/cacert.pem" ] + config_resources = [ - "$root_build_dir/cacert.pem", - "//Base/home/anon/.config/BrowserAutoplayAllowlist.txt", - "//Base/home/anon/.config/BrowserContentFilters.txt", + "//Base/res/ladybird/default-config/BrowserAutoplayAllowlist.txt", + "//Base/res/ladybird/default-config/BrowserContentFilters.txt", + "//Base/res/ladybird/default-config/bookmarks.json", ] if (current_os != "mac") { @@ -337,11 +340,18 @@ if (current_os != "mac") { [ "$root_out_dir/share/Lagom/ladybird/templates/{{source_file_part}}" ] } - copy("ladybird_copy_config_resources") { + copy("ladybird_copy_cacert") { public_deps = [ "//Userland/Libraries/LibTLS:ca_certificates_download" ] - sources = config_resources + sources = cacert outputs = [ "$root_out_dir/share/Lagom/ladybird/{{source_file_part}}" ] } + + copy("ladybird_copy_config_resources") { + sources = config_resources + outputs = [ + "$root_out_dir/share/Lagom/ladybird/default-config/{{source_file_part}}", + ] + } } else { # macOS bundle steps bundle_data("ladybird_bundle_info_plist") { @@ -477,12 +487,19 @@ if (current_os != "mac") { [ "{{bundle_resources_dir}}/ladybird/templates/{{source_file_part}}" ] } - bundle_data("ladybird_config_resources") { + bundle_data("ladybird_cacert") { public_deps = [ "//Userland/Libraries/LibTLS:ca_certificates_download" ] - sources = config_resources + sources = cacert outputs = [ "{{bundle_resources_dir}}/ladybird/{{source_file_part}}" ] } + bundle_data("ladybird_config_resources") { + sources = config_resources + outputs = [ + "{{bundle_resources_dir}}/ladybird/default-config/{{source_file_part}}", + ] + } + action("ladybird_create_icon") { script = "//Meta/gn/build/invoke_process_with_args.py" icon_path = "//Ladybird/Icons/macos/app_icon.iconset" @@ -527,6 +544,7 @@ if (current_os != "mac") { ":ladybird_bundle_executables", ":ladybird_bundle_info_plist", ":ladybird_bundle_libs", + ":ladybird_cacert", ":ladybird_config_resources", ":ladybird_emoji", ":ladybird_fonts",