diff --git a/Libraries/LibWeb/DOM/Window.cpp b/Libraries/LibWeb/DOM/Window.cpp index 35a3fa3786..7799b00837 100644 --- a/Libraries/LibWeb/DOM/Window.cpp +++ b/Libraries/LibWeb/DOM/Window.cpp @@ -57,7 +57,9 @@ void Window::set_wrapper(Badge, Bindings::WindowObject& void Window::alert(const String& message) { - GUI::MessageBox::show(nullptr, message, "Alert", GUI::MessageBox::Type::Information); + if (!m_document.frame()) + return; + m_document.frame()->page().client().page_did_request_alert(message); } bool Window::confirm(const String& message) diff --git a/Libraries/LibWeb/InProcessWebView.cpp b/Libraries/LibWeb/InProcessWebView.cpp index 34896db864..9333ae2d08 100644 --- a/Libraries/LibWeb/InProcessWebView.cpp +++ b/Libraries/LibWeb/InProcessWebView.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -43,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -50,7 +52,6 @@ #include #include #include -#include #include #include #include @@ -416,4 +417,9 @@ void InProcessWebView::drop_event(GUI::DropEvent& event) ScrollableWidget::drop_event(event); } +void InProcessWebView::page_did_request_alert(const String& message) +{ + GUI::MessageBox::show(window(), message, "Alert", GUI::MessageBox::Type::Information); +} + } diff --git a/Libraries/LibWeb/InProcessWebView.h b/Libraries/LibWeb/InProcessWebView.h index 544079d1d8..c6931936dc 100644 --- a/Libraries/LibWeb/InProcessWebView.h +++ b/Libraries/LibWeb/InProcessWebView.h @@ -104,6 +104,7 @@ private: virtual void page_did_change_favicon(const Gfx::Bitmap&) override; virtual void page_did_layout() override; virtual void page_did_request_scroll_into_view(const Gfx::IntRect&) override; + virtual void page_did_request_alert(const String&) override; void layout_and_sync_size(); diff --git a/Libraries/LibWeb/OutOfProcessWebView.cpp b/Libraries/LibWeb/OutOfProcessWebView.cpp index 3fe4b19052..22cdcaf51f 100644 --- a/Libraries/LibWeb/OutOfProcessWebView.cpp +++ b/Libraries/LibWeb/OutOfProcessWebView.cpp @@ -27,6 +27,7 @@ #include "OutOfProcessWebView.h" #include "WebContentClient.h" #include +#include #include #include #include @@ -179,6 +180,11 @@ void OutOfProcessWebView::notify_server_did_request_link_context_menu(Badge, const String& message) +{ + GUI::MessageBox::show(window(), message, "Alert", GUI::MessageBox::Type::Information); +} + void OutOfProcessWebView::did_scroll() { client().post_message(Messages::WebContentServer::SetViewportRect(visible_content_rect())); diff --git a/Libraries/LibWeb/OutOfProcessWebView.h b/Libraries/LibWeb/OutOfProcessWebView.h index bdde1f7cff..47cf0f497c 100644 --- a/Libraries/LibWeb/OutOfProcessWebView.h +++ b/Libraries/LibWeb/OutOfProcessWebView.h @@ -59,6 +59,7 @@ public: void notify_server_did_start_loading(Badge, const URL&); 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); private: OutOfProcessWebView(); diff --git a/Libraries/LibWeb/Page/Page.h b/Libraries/LibWeb/Page/Page.h index 1af2fec572..0cbb992994 100644 --- a/Libraries/LibWeb/Page/Page.h +++ b/Libraries/LibWeb/Page/Page.h @@ -95,6 +95,7 @@ public: virtual void page_did_change_favicon(const Gfx::Bitmap&) { } virtual void page_did_layout() { } virtual void page_did_request_scroll_into_view(const Gfx::IntRect&) { } + virtual void page_did_request_alert(const String&) { } }; } diff --git a/Libraries/LibWeb/WebContentClient.cpp b/Libraries/LibWeb/WebContentClient.cpp index 74c2be6959..5a679ab068 100644 --- a/Libraries/LibWeb/WebContentClient.cpp +++ b/Libraries/LibWeb/WebContentClient.cpp @@ -142,4 +142,10 @@ void WebContentClient::handle(const Messages::WebContentClient::DidRequestLinkCo m_view.notify_server_did_request_link_context_menu({}, message.content_position(), message.url(), message.target(), message.modifiers()); } +OwnPtr WebContentClient::handle(const Messages::WebContentClient::DidRequestAlert& message) +{ + m_view.notify_server_did_request_alert({}, message.message()); + return make(); +} + } diff --git a/Libraries/LibWeb/WebContentClient.h b/Libraries/LibWeb/WebContentClient.h index 7357f09375..c712b193b7 100644 --- a/Libraries/LibWeb/WebContentClient.h +++ b/Libraries/LibWeb/WebContentClient.h @@ -60,6 +60,7 @@ private: virtual void handle(const Messages::WebContentClient::DidStartLoading&) override; virtual void handle(const Messages::WebContentClient::DidRequestContextMenu&) override; virtual void handle(const Messages::WebContentClient::DidRequestLinkContextMenu&) override; + virtual OwnPtr handle(const Messages::WebContentClient::DidRequestAlert&) override; OutOfProcessWebView& m_view; }; diff --git a/Services/WebContent/PageHost.cpp b/Services/WebContent/PageHost.cpp index c0a2e82e92..90c763d16a 100644 --- a/Services/WebContent/PageHost.cpp +++ b/Services/WebContent/PageHost.cpp @@ -169,4 +169,9 @@ void PageHost::page_did_request_link_context_menu(const Gfx::IntPoint& content_p m_client.post_message(Messages::WebContentClient::DidRequestLinkContextMenu(content_position, url, target, modifiers)); } +void PageHost::page_did_request_alert(const String& message) +{ + m_client.send_sync(message); +} + } diff --git a/Services/WebContent/PageHost.h b/Services/WebContent/PageHost.h index fc48da1359..6e3a9ec68e 100644 --- a/Services/WebContent/PageHost.h +++ b/Services/WebContent/PageHost.h @@ -63,6 +63,7 @@ private: virtual void page_did_request_context_menu(const Gfx::IntPoint&) override; virtual void page_did_request_link_context_menu(const Gfx::IntPoint&, const URL&, const String& target, unsigned modifiers) override; virtual void page_did_start_loading(const URL&) override; + virtual void page_did_request_alert(const String&) override; explicit PageHost(ClientConnection&); diff --git a/Services/WebContent/WebContentClient.ipc b/Services/WebContent/WebContentClient.ipc index 6778d2eda5..2b88944cfd 100644 --- a/Services/WebContent/WebContentClient.ipc +++ b/Services/WebContent/WebContentClient.ipc @@ -14,4 +14,5 @@ endpoint WebContentClient = 90 DidStartLoading(URL url) =| DidRequestContextMenu(Gfx::IntPoint content_position) =| DidRequestLinkContextMenu(Gfx::IntPoint content_position, URL url, String target, unsigned modifiers) =| + DidRequestAlert(String message) => () }