summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-02-10 08:48:28 +0100
committerAndreas Kling <kling@serenityos.org>2021-02-10 09:13:30 +0100
commit1ad65b173b71271bbe91f154478c77e0ee607242 (patch)
tree53f34b9dd0ea19cddd4df650adde4234a6d6c9ad
parentabf7c02acb4761a833726fed33ad88fc0c8177a3 (diff)
downloadserenity-1ad65b173b71271bbe91f154478c77e0ee607242.zip
LibWeb+WebContent: Support window.confirm() in OOPWV
-rw-r--r--Userland/Libraries/LibWeb/OutOfProcessWebView.cpp6
-rw-r--r--Userland/Libraries/LibWeb/OutOfProcessWebView.h1
-rw-r--r--Userland/Libraries/LibWeb/WebContentClient.cpp8
-rw-r--r--Userland/Libraries/LibWeb/WebContentClient.h3
-rw-r--r--Userland/Services/WebContent/PageHost.cpp5
-rw-r--r--Userland/Services/WebContent/PageHost.h1
-rw-r--r--Userland/Services/WebContent/WebContentClient.ipc1
7 files changed, 23 insertions, 2 deletions
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<WebContentClient
GUI::MessageBox::show(window(), message, "Alert", GUI::MessageBox::Type::Information);
}
+bool OutOfProcessWebView::notify_server_did_request_confirm(Badge<WebContentClient>, 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<WebContentClient>, const Gfx::IntPoint&);
void notify_server_did_request_link_context_menu(Badge<WebContentClient>, const Gfx::IntPoint&, const URL&, const String& target, unsigned modifiers);
void notify_server_did_request_alert(Badge<WebContentClient>, const String& message);
+ bool notify_server_did_request_confirm(Badge<WebContentClient>, 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 <kling@serenityos.org>
+ * Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -137,4 +137,10 @@ OwnPtr<Messages::WebContentClient::DidRequestAlertResponse> WebContentClient::ha
return make<Messages::WebContentClient::DidRequestAlertResponse>();
}
+OwnPtr<Messages::WebContentClient::DidRequestConfirmResponse> WebContentClient::handle(const Messages::WebContentClient::DidRequestConfirm& message)
+{
+ bool result = m_view.notify_server_did_request_confirm({}, message.message());
+ return make<Messages::WebContentClient::DidRequestConfirmResponse>(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 <kling@serenityos.org>
+ * Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
* 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<Messages::WebContentClient::DidRequestAlertResponse> handle(const Messages::WebContentClient::DidRequestAlert&) override;
+ virtual OwnPtr<Messages::WebContentClient::DidRequestConfirmResponse> 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<Messages::WebContentClient::DidRequestAlert>(message);
}
+bool PageHost::page_did_request_confirm(const String& message)
+{
+ return m_client.send_sync<Messages::WebContentClient::DidRequestConfirm>(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)
}