mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:37:35 +00:00
Ladybird: Implement notify_request_open_new_tab
This commit is contained in:
parent
a9f8d4eada
commit
640864b32e
4 changed files with 13 additions and 2 deletions
|
@ -333,7 +333,7 @@ void BrowserWindow::debug_request(DeprecatedString const& request, DeprecatedStr
|
||||||
m_current_tab->debug_request(request, argument);
|
m_current_tab->debug_request(request, argument);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserWindow::new_tab(QString const& url, Activate activate)
|
Tab& BrowserWindow::new_tab(QString const& url, Activate activate)
|
||||||
{
|
{
|
||||||
auto tab = make<Tab>(this, m_webdriver_content_ipc_path);
|
auto tab = make<Tab>(this, m_webdriver_content_ipc_path);
|
||||||
auto tab_ptr = tab.ptr();
|
auto tab_ptr = tab.ptr();
|
||||||
|
@ -358,6 +358,11 @@ void BrowserWindow::new_tab(QString const& url, Activate activate)
|
||||||
new_tab(urls[i].toString(), Activate::No);
|
new_tab(urls[i].toString(), Activate::No);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tab_ptr->view().on_new_tab = [this]() {
|
||||||
|
auto& tab = new_tab("about:blank", Activate::Yes);
|
||||||
|
return tab.view().handle();
|
||||||
|
};
|
||||||
|
|
||||||
tab_ptr->view().on_get_all_cookies = [this](auto const& url) {
|
tab_ptr->view().on_get_all_cookies = [this](auto const& url) {
|
||||||
return m_cookie_jar.get_all_cookies(url);
|
return m_cookie_jar.get_all_cookies(url);
|
||||||
};
|
};
|
||||||
|
@ -386,6 +391,8 @@ void BrowserWindow::new_tab(QString const& url, Activate activate)
|
||||||
// We make it HistoryNavigation so that the initial page doesn't get added to the history.
|
// We make it HistoryNavigation so that the initial page doesn't get added to the history.
|
||||||
tab_ptr->navigate(url, Tab::LoadType::HistoryNavigation);
|
tab_ptr->navigate(url, Tab::LoadType::HistoryNavigation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return *tab_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BrowserWindow::close_tab(int index)
|
void BrowserWindow::close_tab(int index)
|
||||||
|
|
|
@ -39,7 +39,7 @@ public:
|
||||||
public slots:
|
public slots:
|
||||||
void tab_title_changed(int index, QString const&);
|
void tab_title_changed(int index, QString const&);
|
||||||
void tab_favicon_changed(int index, QIcon icon);
|
void tab_favicon_changed(int index, QIcon icon);
|
||||||
void new_tab(QString const&, Activate);
|
Tab& new_tab(QString const&, Activate);
|
||||||
void close_tab(int index);
|
void close_tab(int index);
|
||||||
void close_current_tab();
|
void close_current_tab();
|
||||||
void open_next_tab();
|
void open_next_tab();
|
||||||
|
|
|
@ -977,6 +977,9 @@ void WebContentView::notify_server_did_close_browsing_context(Badge<WebContentCl
|
||||||
|
|
||||||
String WebContentView::notify_request_open_new_tab(Badge<WebContentClient>)
|
String WebContentView::notify_request_open_new_tab(Badge<WebContentClient>)
|
||||||
{
|
{
|
||||||
|
if (on_new_tab)
|
||||||
|
return on_new_tab();
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ public:
|
||||||
explicit WebContentView(StringView webdriver_content_ipc_path);
|
explicit WebContentView(StringView webdriver_content_ipc_path);
|
||||||
virtual ~WebContentView() override;
|
virtual ~WebContentView() override;
|
||||||
|
|
||||||
|
Function<String()> on_new_tab;
|
||||||
Function<void()> on_close;
|
Function<void()> on_close;
|
||||||
Function<void(Gfx::IntPoint screen_position)> on_context_menu_request;
|
Function<void(Gfx::IntPoint screen_position)> on_context_menu_request;
|
||||||
Function<void(const AK::URL&, DeprecatedString const& target, unsigned modifiers)> on_link_click;
|
Function<void(const AK::URL&, DeprecatedString const& target, unsigned modifiers)> on_link_click;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue