mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 10:48:41 +00:00
LibWebView+WebContent: Begin handling open user dialogs for WebDriver
The way in which dialogs should be handled is configurable by the driver capabilities object, which we don't support yet. So this implements just the default mode to dismiss the dialog and return an error if there is one open. In the OOPWV, this means we need to refer to the dialog after it has been open, so we now hold a pointer to whatever dialog is open.
This commit is contained in:
committed by
Linus Groh
parent
5b31a3dbc7
commit
0e94904034
@@ -10,6 +10,7 @@
|
||||
#include <LibFileSystemAccessClient/Client.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/Desktop.h>
|
||||
#include <LibGUI/Dialog.h>
|
||||
#include <LibGUI/InputBox.h>
|
||||
#include <LibGUI/MessageBox.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
@@ -347,23 +348,46 @@ void OutOfProcessWebView::notify_server_did_request_image_context_menu(Badge<Web
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_request_alert(Badge<WebContentClient>, String const& message)
|
||||
{
|
||||
GUI::MessageBox::show(window(), message, "Alert"sv, GUI::MessageBox::Type::Information);
|
||||
m_dialog = GUI::MessageBox::construct(window(), message, "Alert"sv, GUI::MessageBox::Type::Information, GUI::MessageBox::InputType::OK);
|
||||
m_dialog->set_icon(window()->icon());
|
||||
m_dialog->exec();
|
||||
|
||||
client().async_alert_closed();
|
||||
m_dialog = nullptr;
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_request_confirm(Badge<WebContentClient>, String const& message)
|
||||
{
|
||||
auto confirm_result = GUI::MessageBox::show(window(), message, "Confirm"sv, GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel);
|
||||
client().async_confirm_closed(confirm_result == GUI::Dialog::ExecResult::OK);
|
||||
m_dialog = GUI::MessageBox::construct(window(), message, "Confirm"sv, GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel);
|
||||
m_dialog->set_icon(window()->icon());
|
||||
|
||||
client().async_confirm_closed(m_dialog->exec() == GUI::Dialog::ExecResult::OK);
|
||||
m_dialog = nullptr;
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_request_prompt(Badge<WebContentClient>, String const& message, String const& default_)
|
||||
{
|
||||
String response { default_ };
|
||||
if (GUI::InputBox::show(window(), response, message, "Prompt"sv) == GUI::InputBox::ExecResult::OK)
|
||||
client().async_prompt_closed(move(response));
|
||||
m_dialog = GUI::InputBox::construct(window(), default_, message, "Prompt"sv, StringView {}, GUI::InputType::Text);
|
||||
m_dialog->set_icon(window()->icon());
|
||||
|
||||
if (m_dialog->exec() == GUI::InputBox::ExecResult::OK)
|
||||
client().async_prompt_closed(static_cast<GUI::InputBox&>(*m_dialog).text_value());
|
||||
else
|
||||
client().async_prompt_closed({});
|
||||
|
||||
m_dialog = nullptr;
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_request_accept_dialog(Badge<WebContentClient>)
|
||||
{
|
||||
if (m_dialog)
|
||||
m_dialog->done(GUI::Dialog::ExecResult::OK);
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_request_dismiss_dialog(Badge<WebContentClient>)
|
||||
{
|
||||
if (m_dialog)
|
||||
m_dialog->done(GUI::Dialog::ExecResult::Cancel);
|
||||
}
|
||||
|
||||
void OutOfProcessWebView::notify_server_did_get_source(const AK::URL& url, String const& source)
|
||||
|
||||
Reference in New Issue
Block a user