mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 10:07:35 +00:00
WebContent+Everywhere: Add an option to not activate new tabs over IPC
WebDriver, for example, will want to create new tabs without activating them.
This commit is contained in:
parent
78ed798852
commit
e6fc35897f
21 changed files with 81 additions and 62 deletions
|
@ -313,7 +313,7 @@ BrowserWindow::BrowserWindow(Browser::CookieJar& cookie_jar, StringView webdrive
|
|||
});
|
||||
|
||||
QObject::connect(new_tab_action, &QAction::triggered, this, [this] {
|
||||
new_tab(s_settings->new_tab_page(), Activate::Yes);
|
||||
new_tab(s_settings->new_tab_page(), Web::HTML::ActivateTab::Yes);
|
||||
});
|
||||
QObject::connect(settings_action, &QAction::triggered, this, [this] {
|
||||
new SettingsDialog(this);
|
||||
|
@ -327,7 +327,7 @@ BrowserWindow::BrowserWindow(Browser::CookieJar& cookie_jar, StringView webdrive
|
|||
QObject::connect(m_tabs_container, &QTabWidget::tabCloseRequested, this, &BrowserWindow::close_tab);
|
||||
QObject::connect(close_current_tab_action, &QAction::triggered, this, &BrowserWindow::close_current_tab);
|
||||
|
||||
new_tab(s_settings->new_tab_page(), Activate::Yes);
|
||||
new_tab(s_settings->new_tab_page(), Web::HTML::ActivateTab::Yes);
|
||||
|
||||
setCentralWidget(m_tabs_container);
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ void BrowserWindow::debug_request(DeprecatedString const& request, DeprecatedStr
|
|||
m_current_tab->debug_request(request, argument);
|
||||
}
|
||||
|
||||
Tab& BrowserWindow::new_tab(QString const& url, Activate activate)
|
||||
Tab& BrowserWindow::new_tab(QString const& url, Web::HTML::ActivateTab activate_tab)
|
||||
{
|
||||
auto tab = make<Tab>(this, m_webdriver_content_ipc_path);
|
||||
auto tab_ptr = tab.ptr();
|
||||
|
@ -350,7 +350,7 @@ Tab& BrowserWindow::new_tab(QString const& url, Activate activate)
|
|||
}
|
||||
|
||||
m_tabs_container->addTab(tab_ptr, "New Tab");
|
||||
if (activate == Activate::Yes)
|
||||
if (activate_tab == Web::HTML::ActivateTab::Yes)
|
||||
m_tabs_container->setCurrentWidget(tab_ptr);
|
||||
|
||||
QObject::connect(tab_ptr, &Tab::title_changed, this, &BrowserWindow::tab_title_changed);
|
||||
|
@ -361,11 +361,11 @@ Tab& BrowserWindow::new_tab(QString const& url, Activate activate)
|
|||
m_current_tab->navigate(urls[0].toString());
|
||||
|
||||
for (qsizetype i = 1; i < urls.size(); ++i)
|
||||
new_tab(urls[i].toString(), Activate::No);
|
||||
new_tab(urls[i].toString(), Web::HTML::ActivateTab::No);
|
||||
});
|
||||
|
||||
tab_ptr->view().on_new_tab = [this]() {
|
||||
auto& tab = new_tab("about:blank", Activate::Yes);
|
||||
tab_ptr->view().on_new_tab = [this](auto activate_tab) {
|
||||
auto& tab = new_tab("about:blank", activate_tab);
|
||||
return tab.view().handle();
|
||||
};
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "Tab.h"
|
||||
#include <LibCore/Forward.h>
|
||||
#include <LibWeb/HTML/ActivateTab.h>
|
||||
#include <QIcon>
|
||||
#include <QLineEdit>
|
||||
#include <QMainWindow>
|
||||
|
@ -31,15 +32,10 @@ public:
|
|||
|
||||
int tab_index(Tab*);
|
||||
|
||||
enum class Activate {
|
||||
Yes,
|
||||
No,
|
||||
};
|
||||
|
||||
public slots:
|
||||
void tab_title_changed(int index, QString const&);
|
||||
void tab_favicon_changed(int index, QIcon icon);
|
||||
Tab& new_tab(QString const&, Activate);
|
||||
Tab& new_tab(QString const&, Web::HTML::ActivateTab);
|
||||
void close_tab(int index);
|
||||
void close_current_tab();
|
||||
void open_next_tab();
|
||||
|
|
|
@ -970,25 +970,24 @@ void WebContentView::notify_server_did_set_cookie(Badge<WebContentClient>, AK::U
|
|||
on_set_cookie(url, cookie, source);
|
||||
}
|
||||
|
||||
void WebContentView::notify_server_did_update_cookie(Badge<WebContentClient>, Web::Cookie::Cookie const& cookie)
|
||||
{
|
||||
if (on_update_cookie)
|
||||
on_update_cookie(cookie);
|
||||
}
|
||||
|
||||
void WebContentView::notify_server_did_close_browsing_context(Badge<WebContentClient>)
|
||||
{
|
||||
emit close();
|
||||
}
|
||||
|
||||
String WebContentView::notify_request_open_new_tab(Badge<WebContentClient>)
|
||||
String WebContentView::notify_server_did_request_new_tab(Badge<WebContentClient>, Web::HTML::ActivateTab activate_tab)
|
||||
{
|
||||
if (on_new_tab)
|
||||
return on_new_tab();
|
||||
|
||||
return on_new_tab(activate_tab);
|
||||
return {};
|
||||
}
|
||||
|
||||
void WebContentView::notify_server_did_update_cookie(Badge<WebContentClient>, Web::Cookie::Cookie const& cookie)
|
||||
{
|
||||
if (on_update_cookie)
|
||||
on_update_cookie(cookie);
|
||||
}
|
||||
|
||||
void WebContentView::notify_server_did_update_resource_count(i32 count_waiting)
|
||||
{
|
||||
// FIXME
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <LibWeb/CSS/PreferredColorScheme.h>
|
||||
#include <LibWeb/CSS/Selector.h>
|
||||
#include <LibWeb/Forward.h>
|
||||
#include <LibWeb/HTML/ActivateTab.h>
|
||||
#include <LibWebView/ViewImplementation.h>
|
||||
#include <QAbstractScrollArea>
|
||||
#include <QPointer>
|
||||
|
@ -49,7 +50,7 @@ public:
|
|||
explicit WebContentView(StringView webdriver_content_ipc_path);
|
||||
virtual ~WebContentView() override;
|
||||
|
||||
Function<String()> on_new_tab;
|
||||
Function<String(Web::HTML::ActivateTab)> 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;
|
||||
|
@ -146,7 +147,7 @@ public:
|
|||
virtual DeprecatedString notify_server_did_request_cookie(Badge<WebContentClient>, const AK::URL& url, Web::Cookie::Source source) override;
|
||||
virtual void notify_server_did_set_cookie(Badge<WebContentClient>, const AK::URL& url, Web::Cookie::ParsedCookie const& cookie, Web::Cookie::Source source) override;
|
||||
virtual void notify_server_did_update_cookie(Badge<WebContentClient>, Web::Cookie::Cookie const& cookie) override;
|
||||
virtual String notify_request_open_new_tab(Badge<WebContentClient>) override;
|
||||
virtual String notify_server_did_request_new_tab(Badge<WebContentClient>, Web::HTML::ActivateTab activate_tab) override;
|
||||
virtual void notify_server_did_close_browsing_context(Badge<WebContentClient>) override;
|
||||
virtual void notify_server_did_update_resource_count(i32 count_waiting) override;
|
||||
virtual void notify_server_did_request_restore_window() override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue