diff --git a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp index 84fc62bf5d..6b8988404b 100644 --- a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp +++ b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp @@ -287,6 +287,12 @@ void OutOfProcessWebView::notify_server_did_request_alert(Badge, const String& message) +{ + auto confirm_result = GUI::MessageBox::show(window(), message, "Confirm", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel); + return confirm_result == GUI::Dialog::ExecResult::ExecOK; +} + void OutOfProcessWebView::did_scroll() { client().post_message(Messages::WebContentServer::SetViewportRect(visible_content_rect())); diff --git a/Userland/Libraries/LibWeb/OutOfProcessWebView.h b/Userland/Libraries/LibWeb/OutOfProcessWebView.h index c6db3c982e..260792f16b 100644 --- a/Userland/Libraries/LibWeb/OutOfProcessWebView.h +++ b/Userland/Libraries/LibWeb/OutOfProcessWebView.h @@ -66,6 +66,7 @@ public: void notify_server_did_request_context_menu(Badge, const Gfx::IntPoint&); void notify_server_did_request_link_context_menu(Badge, const Gfx::IntPoint&, const URL&, const String& target, unsigned modifiers); void notify_server_did_request_alert(Badge, const String& message); + bool notify_server_did_request_confirm(Badge, const String& message); private: OutOfProcessWebView(); diff --git a/Userland/Libraries/LibWeb/WebContentClient.cpp b/Userland/Libraries/LibWeb/WebContentClient.cpp index 028da8d110..1318ada067 100644 --- a/Userland/Libraries/LibWeb/WebContentClient.cpp +++ b/Userland/Libraries/LibWeb/WebContentClient.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Andreas Kling + * Copyright (c) 2020-2021, Andreas Kling * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -137,4 +137,10 @@ OwnPtr WebContentClient::ha return make(); } +OwnPtr WebContentClient::handle(const Messages::WebContentClient::DidRequestConfirm& message) +{ + bool result = m_view.notify_server_did_request_confirm({}, message.message()); + return make(result); +} + } diff --git a/Userland/Libraries/LibWeb/WebContentClient.h b/Userland/Libraries/LibWeb/WebContentClient.h index 194901a809..1cc367364f 100644 --- a/Userland/Libraries/LibWeb/WebContentClient.h +++ b/Userland/Libraries/LibWeb/WebContentClient.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Andreas Kling + * Copyright (c) 2020-2021, Andreas Kling * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -65,6 +65,7 @@ private: virtual void handle(const Messages::WebContentClient::DidRequestContextMenu&) override; virtual void handle(const Messages::WebContentClient::DidRequestLinkContextMenu&) override; virtual OwnPtr handle(const Messages::WebContentClient::DidRequestAlert&) override; + virtual OwnPtr handle(const Messages::WebContentClient::DidRequestConfirm&) override; OutOfProcessWebView& m_view; }; diff --git a/Userland/Services/WebContent/PageHost.cpp b/Userland/Services/WebContent/PageHost.cpp index 929cfac044..427361fb84 100644 --- a/Userland/Services/WebContent/PageHost.cpp +++ b/Userland/Services/WebContent/PageHost.cpp @@ -176,4 +176,9 @@ void PageHost::page_did_request_alert(const String& message) m_client.send_sync(message); } +bool PageHost::page_did_request_confirm(const String& message) +{ + return m_client.send_sync(message)->result(); +} + } diff --git a/Userland/Services/WebContent/PageHost.h b/Userland/Services/WebContent/PageHost.h index 580685cfdb..85a7f53066 100644 --- a/Userland/Services/WebContent/PageHost.h +++ b/Userland/Services/WebContent/PageHost.h @@ -68,6 +68,7 @@ private: virtual void page_did_start_loading(const URL&) override; virtual void page_did_finish_loading(const URL&) override; virtual void page_did_request_alert(const String&) override; + virtual bool page_did_request_confirm(const String&) override; explicit PageHost(ClientConnection&); diff --git a/Userland/Services/WebContent/WebContentClient.ipc b/Userland/Services/WebContent/WebContentClient.ipc index 2e2f63d831..0eb5886a9c 100644 --- a/Userland/Services/WebContent/WebContentClient.ipc +++ b/Userland/Services/WebContent/WebContentClient.ipc @@ -15,4 +15,5 @@ endpoint WebContentClient = 90 DidRequestContextMenu(Gfx::IntPoint content_position) =| DidRequestLinkContextMenu(Gfx::IntPoint content_position, URL url, String target, unsigned modifiers) =| DidRequestAlert(String message) => () + DidRequestConfirm(String message) => (bool result) }