1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 18:08:12 +00:00

Ladybird: Only load a single URL at launch

When we launch Ladybird, we currently:

1. Create a BrowserWindow, whose constructor navigates to the configured
   new tab page URL.
2. Then navigate to either "about:blank" or whatever URL is provided via
   the command line.

This patch removes step 2 and forwards the URL from the command line (if
any) to BrowserWindow. BrowserWindow's constructor then either navigates
to that URL or the new tab page URL.
This commit is contained in:
Timothy Flynn 2023-08-08 15:59:55 -04:00 committed by Andreas Kling
parent 27fa029537
commit 6c7422e8b7
3 changed files with 13 additions and 10 deletions

View file

@ -107,17 +107,15 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto cookie_jar = database ? TRY(Browser::CookieJar::create(*database)) : Browser::CookieJar::create();
Optional<URL> initial_url;
if (auto url = TRY(get_formatted_url(raw_url)); url.is_valid())
initial_url = move(url);
Ladybird::s_settings = adopt_own_if_nonnull(new Ladybird::Settings());
Ladybird::BrowserWindow window(cookie_jar, webdriver_content_ipc_path, enable_callgrind_profiling ? WebView::EnableCallgrindProfiling::Yes : WebView::EnableCallgrindProfiling::No, use_lagom_networking ? Ladybird::UseLagomNetworking::Yes : Ladybird::UseLagomNetworking::No);
Ladybird::BrowserWindow window(initial_url, cookie_jar, webdriver_content_ipc_path, enable_callgrind_profiling ? WebView::EnableCallgrindProfiling::Yes : WebView::EnableCallgrindProfiling::No, use_lagom_networking ? Ladybird::UseLagomNetworking::Yes : Ladybird::UseLagomNetworking::No);
window.setWindowTitle("Ladybird");
window.resize(800, 600);
window.show();
if (auto url = TRY(get_formatted_url(raw_url)); url.is_valid()) {
window.view().load(url);
} else {
window.view().load("about:blank"sv);
}
return event_loop.exec();
}