Ladybird: Implement notify_request_open_new_tab
This commit is contained in:
parent
a9f8d4eada
commit
640864b32e
Notes:
sideshowbarker
2024-07-17 07:08:37 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/640864b32e Pull-request: https://github.com/SerenityOS/serenity/pull/17855 Reviewed-by: https://github.com/linusg Reviewed-by: https://github.com/trflynn89 ✅
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);
|
||||
}
|
||||
|
||||
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_ptr = tab.ptr();
|
||||
|
@ -358,6 +358,11 @@ void BrowserWindow::new_tab(QString const& url, Activate activate)
|
|||
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) {
|
||||
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.
|
||||
tab_ptr->navigate(url, Tab::LoadType::HistoryNavigation);
|
||||
}
|
||||
|
||||
return *tab_ptr;
|
||||
}
|
||||
|
||||
void BrowserWindow::close_tab(int index)
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
public slots:
|
||||
void tab_title_changed(int index, QString const&);
|
||||
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_current_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>)
|
||||
{
|
||||
if (on_new_tab)
|
||||
return on_new_tab();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ public:
|
|||
explicit WebContentView(StringView webdriver_content_ipc_path);
|
||||
virtual ~WebContentView() override;
|
||||
|
||||
Function<String()> on_new_tab;
|
||||
Function<void()> on_close;
|
||||
Function<void(Gfx::IntPoint screen_position)> on_context_menu_request;
|
||||
Function<void(const AK::URL&, DeprecatedString const& target, unsigned modifiers)> on_link_click;
|
||||
|
|
Loading…
Add table
Reference in a new issue