mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:57:45 +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:
parent
27fa029537
commit
6c7422e8b7
3 changed files with 13 additions and 10 deletions
|
@ -40,7 +40,7 @@ static QIcon const& app_icon()
|
|||
return icon;
|
||||
}
|
||||
|
||||
BrowserWindow::BrowserWindow(Browser::CookieJar& cookie_jar, StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling enable_callgrind_profiling, UseLagomNetworking use_lagom_networking)
|
||||
BrowserWindow::BrowserWindow(Optional<URL> const& initial_url, Browser::CookieJar& cookie_jar, StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling enable_callgrind_profiling, UseLagomNetworking use_lagom_networking)
|
||||
: m_cookie_jar(cookie_jar)
|
||||
, m_webdriver_content_ipc_path(webdriver_content_ipc_path)
|
||||
, m_enable_callgrind_profiling(enable_callgrind_profiling)
|
||||
|
@ -397,7 +397,12 @@ BrowserWindow::BrowserWindow(Browser::CookieJar& cookie_jar, StringView webdrive
|
|||
m_go_back_action->setEnabled(false);
|
||||
m_go_forward_action->setEnabled(false);
|
||||
|
||||
if (initial_url.has_value()) {
|
||||
auto initial_url_string = qstring_from_ak_deprecated_string(initial_url->serialize());
|
||||
new_tab(initial_url_string, Web::HTML::ActivateTab::Yes);
|
||||
} else {
|
||||
new_tab(s_settings->new_tab_page(), Web::HTML::ActivateTab::Yes);
|
||||
}
|
||||
|
||||
setCentralWidget(m_tabs_container);
|
||||
setContextMenuPolicy(Qt::PreventContextMenu);
|
||||
|
|
|
@ -28,7 +28,7 @@ class WebContentView;
|
|||
class BrowserWindow : public QMainWindow {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BrowserWindow(Browser::CookieJar&, StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling, UseLagomNetworking);
|
||||
explicit BrowserWindow(Optional<URL> const& initial_url, Browser::CookieJar&, StringView webdriver_content_ipc_path, WebView::EnableCallgrindProfiling, UseLagomNetworking);
|
||||
|
||||
WebContentView& view() const { return m_current_tab->view(); }
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue