1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 08:47:44 +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:
Timothy Flynn 2023-03-20 18:39:20 -04:00 committed by Linus Groh
parent 78ed798852
commit e6fc35897f
21 changed files with 81 additions and 62 deletions

View file

@ -59,14 +59,6 @@ void OutOfProcessWebView::handle_web_content_process_crash()
load_html(builder.to_deprecated_string(), m_url);
}
String OutOfProcessWebView::notify_request_open_new_tab(Badge<WebContentClient>)
{
if (on_new_tab)
return on_new_tab();
return {};
}
void OutOfProcessWebView::create_client()
{
m_client_state = {};
@ -475,18 +467,25 @@ void OutOfProcessWebView::notify_server_did_set_cookie(Badge<WebContentClient>,
on_set_cookie(url, cookie, source);
}
void OutOfProcessWebView::notify_server_did_close_browsing_context(Badge<WebContentClient>)
{
if (on_close)
on_close();
}
void OutOfProcessWebView::notify_server_did_update_cookie(Badge<WebContentClient>, Web::Cookie::Cookie const& cookie)
{
if (on_update_cookie)
on_update_cookie(cookie);
}
String OutOfProcessWebView::notify_server_did_request_new_tab(Badge<WebContentClient>, Web::HTML::ActivateTab activate_tab)
{
if (on_new_tab)
return on_new_tab(activate_tab);
return {};
}
void OutOfProcessWebView::notify_server_did_close_browsing_context(Badge<WebContentClient>)
{
if (on_close)
on_close();
}
void OutOfProcessWebView::notify_server_did_update_resource_count(i32 count_waiting)
{
if (on_resource_status_change)

View file

@ -12,6 +12,7 @@
#include <LibGUI/AbstractScrollableWidget.h>
#include <LibGUI/Widget.h>
#include <LibWeb/CSS/Selector.h>
#include <LibWeb/HTML/ActivateTab.h>
#include <LibWeb/Page/Page.h>
#include <LibWebView/ViewImplementation.h>
@ -57,7 +58,7 @@ public:
// In practice, this means that OOPWV may render scaled stale versions of the content while resizing.
void set_content_scales_to_viewport(bool);
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;
@ -162,7 +163,7 @@ private:
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;

View file

@ -12,6 +12,7 @@
#include <LibGfx/Forward.h>
#include <LibGfx/StandardCursor.h>
#include <LibWeb/Forward.h>
#include <LibWeb/HTML/ActivateTab.h>
#include <LibWebView/Forward.h>
#include <LibWebView/WebContentClient.h>
@ -98,7 +99,7 @@ public:
virtual DeprecatedString notify_server_did_request_cookie(Badge<WebContentClient>, const AK::URL& url, Web::Cookie::Source source) = 0;
virtual void notify_server_did_set_cookie(Badge<WebContentClient>, const AK::URL& url, Web::Cookie::ParsedCookie const& cookie, Web::Cookie::Source source) = 0;
virtual void notify_server_did_update_cookie(Badge<WebContentClient>, Web::Cookie::Cookie const& cookie) = 0;
virtual String notify_request_open_new_tab(Badge<WebContentClient>) = 0;
virtual String notify_server_did_request_new_tab(Badge<WebContentClient>, Web::HTML::ActivateTab activate_tab) = 0;
virtual void notify_server_did_close_browsing_context(Badge<WebContentClient>) = 0;
virtual void notify_server_did_update_resource_count(i32 count_waiting) = 0;
virtual void notify_server_did_request_restore_window() = 0;

View file

@ -240,9 +240,9 @@ void WebContentClient::did_update_cookie(Web::Cookie::Cookie const& cookie)
m_view.notify_server_did_update_cookie({}, cookie);
}
Messages::WebContentClient::DidRequestNewTabResponse WebContentClient::did_request_new_tab()
Messages::WebContentClient::DidRequestNewTabResponse WebContentClient::did_request_new_tab(Web::HTML::ActivateTab const& activate_tab)
{
return m_view.notify_request_open_new_tab({});
return m_view.notify_server_did_request_new_tab({}, activate_tab);
}
void WebContentClient::did_close_browsing_context()

View file

@ -8,6 +8,7 @@
#include <AK/HashMap.h>
#include <LibIPC/ConnectionToServer.h>
#include <LibWeb/HTML/ActivateTab.h>
#include <WebContent/WebContentClientEndpoint.h>
#include <WebContent/WebContentServerEndpoint.h>
@ -69,6 +70,7 @@ private:
virtual Messages::WebContentClient::DidRequestCookieResponse did_request_cookie(AK::URL const&, u8) override;
virtual void did_set_cookie(AK::URL const&, Web::Cookie::ParsedCookie const&, u8) override;
virtual void did_update_cookie(Web::Cookie::Cookie const&) override;
virtual Messages::WebContentClient::DidRequestNewTabResponse did_request_new_tab(Web::HTML::ActivateTab const& activate_tab) override;
virtual void did_close_browsing_context() override;
virtual void did_update_resource_count(i32 count_waiting) override;
virtual void did_request_restore_window() override;
@ -79,7 +81,6 @@ private:
virtual Messages::WebContentClient::DidRequestFullscreenWindowResponse did_request_fullscreen_window() override;
virtual void did_request_file(DeprecatedString const& path, i32) override;
virtual void did_finish_handling_input_event(bool event_was_accepted) override;
virtual Messages::WebContentClient::DidRequestNewTabResponse did_request_new_tab() override;
ViewImplementation& m_view;
};