mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 06:48:49 +00:00
LibWeb+LibWebView+WebContent: Introduce a basic about:settings page
This adds a basic settings page to manage persistent Ladybird settings. As a first pass, this exposes settings for the new tab page URL and the default search engine. The way the search engine option works is that once search is enabled, the user must choose their default search engine; we do not apply any default automatically. Search remains disabled until this is done. There are a couple of improvements that we should make here: * Settings changes are not broadcasted to all open about:settings pages. So if two instances are open, and the user changes the search engine in one instance, the other instance will have a stale UI. * Adding an IPC per setting is going to get annoying. It would be nice if we can come up with a smaller set of IPCs to send only the relevant changed settings.
This commit is contained in:
parent
e084a86861
commit
b169a98495
Notes:
github-actions[bot]
2025-03-22 16:28:49 +00:00
Author: https://github.com/trflynn89
Commit: b169a98495
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4036
16 changed files with 475 additions and 2 deletions
|
@ -670,6 +670,39 @@ void WebContentClient::update_process_statistics(u64 page_id)
|
|||
WebView::Application::the().send_updated_process_statistics_to_view(*view);
|
||||
}
|
||||
|
||||
void WebContentClient::request_current_settings(u64 page_id)
|
||||
{
|
||||
if (auto view = view_for_page_id(page_id); view.has_value())
|
||||
WebView::Application::the().send_current_settings_to_view(*view);
|
||||
}
|
||||
|
||||
void WebContentClient::restore_default_settings(u64 page_id)
|
||||
{
|
||||
WebView::Application::settings().restore_defaults();
|
||||
request_current_settings(page_id);
|
||||
}
|
||||
|
||||
void WebContentClient::set_new_tab_page_url(u64 page_id, URL::URL new_tab_page_url)
|
||||
{
|
||||
WebView::Application::settings().set_new_tab_page_url(move(new_tab_page_url));
|
||||
request_current_settings(page_id);
|
||||
}
|
||||
|
||||
void WebContentClient::request_available_search_engines(u64 page_id)
|
||||
{
|
||||
if (auto view = view_for_page_id(page_id); view.has_value())
|
||||
WebView::Application::the().send_available_search_engines_to_view(*view);
|
||||
}
|
||||
|
||||
void WebContentClient::set_search_engine(u64 page_id, Optional<String> search_engine)
|
||||
{
|
||||
WebView::Application::settings().set_search_engine(search_engine.map([](auto const& search_engine) {
|
||||
return search_engine.bytes_as_string_view();
|
||||
}));
|
||||
|
||||
request_current_settings(page_id);
|
||||
}
|
||||
|
||||
Optional<ViewImplementation&> WebContentClient::view_for_page_id(u64 page_id, SourceLocation location)
|
||||
{
|
||||
// Don't bother logging anything for the spare WebContent process. It will only receive a load notification for about:blank.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue