Browser: Set 'webdriver-active flag' when creating a new Tab

This commit is contained in:
Linus Groh 2022-10-12 23:51:37 +02:00 committed by Andreas Kling
parent 3f24a444f9
commit 5681115744
Notes: sideshowbarker 2024-07-17 05:59:59 +09:00
3 changed files with 14 additions and 3 deletions

View File

@ -8,6 +8,7 @@
#include <AK/String.h>
#include <Applications/Browser/IconBag.h>
#include <Applications/Browser/WebDriverConnection.h>
namespace Browser {
@ -19,5 +20,6 @@ extern Vector<String> g_proxies;
extern HashMap<String, size_t> g_proxy_mappings;
extern bool g_content_filters_enabled;
extern IconBag g_icon_bag;
extern RefPtr<Browser::WebDriverConnection> g_web_driver_connection;
}

View File

@ -127,6 +127,9 @@ Tab::Tab(BrowserWindow& window)
m_web_content_view->set_proxy_mappings(g_proxies, g_proxy_mappings);
if (!g_web_driver_connection.is_null())
m_web_content_view->set_is_webdriver_active(true);
auto& go_back_button = toolbar.add_action(window.go_back_action());
go_back_button.on_context_menu_request = [&](auto&) {
if (!m_history.can_go_back())

View File

@ -26,6 +26,7 @@
#include <LibGUI/TabWidget.h>
#include <LibMain/Main.h>
#include <LibWeb/Loader/ResourceLoader.h>
#include <LibWebView/OutOfProcessWebView.h>
#include <LibWebView/RequestServerAdapter.h>
#include <unistd.h>
@ -39,6 +40,7 @@ bool g_content_filters_enabled { true };
Vector<String> g_proxies;
HashMap<String, size_t> g_proxy_mappings;
IconBag g_icon_bag;
RefPtr<Browser::WebDriverConnection> g_web_driver_connection;
}
@ -144,10 +146,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Browser::CookieJar cookie_jar;
auto window = Browser::BrowserWindow::construct(cookie_jar, first_url);
RefPtr<Browser::WebDriverConnection> web_driver_connection;
if (!webdriver_ipc_path.is_empty())
web_driver_connection = TRY(Browser::WebDriverConnection::connect_to_webdriver(window, webdriver_ipc_path));
if (!webdriver_ipc_path.is_empty()) {
Browser::g_web_driver_connection = TRY(Browser::WebDriverConnection::connect_to_webdriver(window, webdriver_ipc_path));
// The first tab is created with the BrowserWindow above, so we have to do this
// manually once after establishing the connection.
window->active_tab().view().set_is_webdriver_active(true);
}
auto content_filters_watcher = TRY(Core::FileWatcher::create());
content_filters_watcher->on_change = [&](Core::FileWatcherEvent const&) {