Base: Move config files out of home/anon and into default-config

This commit is contained in:
circl 2024-07-15 18:00:14 +02:00 committed by Andrew Kaster
parent 4ef0a123ea
commit a443f50807
Notes: sideshowbarker 2024-07-18 02:44:17 +09:00
8 changed files with 34 additions and 29 deletions

View file

@ -106,9 +106,7 @@ ErrorOr<NonnullRefPtr<Client>> bind_service(void (*bind_method)(int))
static ErrorOr<void> 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<void> load_content_filters()
static ErrorOr<void> 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();

View file

@ -197,7 +197,7 @@ static ErrorOr<void> 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<FixedMemoryStream>::create(make<FixedMemoryStream>(resource->data())));
Vector<String> patterns;
@ -221,7 +221,7 @@ static ErrorOr<void> 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<FixedMemoryStream>::create(make<FixedMemoryStream>(resource->data())));
Vector<String> origins;

View file

@ -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)

View file

@ -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()

View file

@ -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",