mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-03 06:40:05 +00:00
LibWeb+LibWebView+WebContent: Convert about:settings to a WebUI
Some checks are pending
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
Some checks are pending
CI / Lagom (x86_64, Fuzzers_CI, false, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, ubuntu-24.04, Linux, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, ubuntu-24.04, Linux, Clang) (push) Waiting to run
CI / Lagom (arm64, Sanitizer_CI, false, macos-15, macOS, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (macos-14, macOS, macOS-universal2) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (ubuntu-24.04, Linux, Linux-x86_64) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run
This commit is contained in:
parent
c75e40180c
commit
f05b0bfd5f
Notes:
github-actions[bot]
2025-03-28 11:32:05 +00:00
Author: https://github.com/trflynn89
Commit: f05b0bfd5f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4068
23 changed files with 151 additions and 264 deletions
|
@ -6,7 +6,6 @@
|
|||
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/JsonObject.h>
|
||||
#include <AK/JsonObjectSerializer.h>
|
||||
#include <AK/JsonValue.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
|
@ -40,13 +39,13 @@ static ErrorOr<JsonObject> read_settings_file(StringView settings_path)
|
|||
return move(settings_json.as_object());
|
||||
}
|
||||
|
||||
static ErrorOr<void> write_settings_file(StringView settings_path, StringView contents)
|
||||
static ErrorOr<void> write_settings_file(StringView settings_path, JsonValue const& contents)
|
||||
{
|
||||
auto settings_directory = LexicalPath { settings_path }.parent();
|
||||
TRY(Core::Directory::create(settings_directory, Core::Directory::CreateDirectories::Yes));
|
||||
|
||||
auto settings_file = TRY(Core::File::open(settings_path, Core::File::OpenMode::Write));
|
||||
TRY(settings_file->write_until_depleted(contents));
|
||||
TRY(settings_file->write_until_depleted(contents.serialized()));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -84,21 +83,19 @@ Settings::Settings(ByteString settings_path)
|
|||
{
|
||||
}
|
||||
|
||||
String Settings::serialize_json() const
|
||||
JsonValue Settings::serialize_json() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
auto serializer = MUST(JsonObjectSerializer<>::try_create(builder));
|
||||
|
||||
MUST(serializer.add(new_tab_page_url_key, m_new_tab_page_url.serialize()));
|
||||
JsonObject settings;
|
||||
settings.set(new_tab_page_url_key, m_new_tab_page_url.serialize());
|
||||
|
||||
if (m_search_engine.has_value()) {
|
||||
auto search_engine = MUST(serializer.add_object(search_engine_key));
|
||||
MUST(search_engine.add(search_engine_name_key, m_search_engine->name));
|
||||
MUST(search_engine.finish());
|
||||
JsonObject search_engine;
|
||||
search_engine.set(search_engine_name_key, m_search_engine->name);
|
||||
|
||||
settings.set(search_engine_key, move(search_engine));
|
||||
}
|
||||
|
||||
MUST(serializer.finish());
|
||||
return MUST(builder.to_string());
|
||||
return settings;
|
||||
}
|
||||
|
||||
void Settings::restore_defaults()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue