mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-28 07:18:51 +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:
parent
5b31a3dbc7
commit
0e94904034
Notes:
sideshowbarker
2024-07-17 04:25:17 +09:00
Author: https://github.com/trflynn89
Commit: 0e94904034
Pull-request: https://github.com/SerenityOS/serenity/pull/16091
Reviewed-by: https://github.com/linusg
10 changed files with 165 additions and 36 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue