summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorBrandon Scott <xeons@users.noreply.github.com>2021-02-23 06:17:23 -0600
committerAndreas Kling <kling@serenityos.org>2021-02-23 16:23:56 +0100
commit2f56a86a4ee3db4ca6bf712a11072ff53ef1b603 (patch)
tree3a167d6c7d35d5f6c31b3a86c38863266cc1b4d7 /Userland/Libraries/LibWeb
parent306501fd4afa5fb6bf48f15aecd5921597a0d6cc (diff)
downloadserenity-2f56a86a4ee3db4ca6bf712a11072ff53ef1b603.zip
LibWeb: Added get source functionality and hook event
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/OutOfProcessWebView.cpp11
-rw-r--r--Userland/Libraries/LibWeb/OutOfProcessWebView.h2
-rw-r--r--Userland/Libraries/LibWeb/WebContentClient.cpp5
-rw-r--r--Userland/Libraries/LibWeb/WebContentClient.h1
-rw-r--r--Userland/Libraries/LibWeb/WebViewHooks.h1
5 files changed, 20 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp
index 91dd9c1e46..29e3467ceb 100644
--- a/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp
+++ b/Userland/Libraries/LibWeb/OutOfProcessWebView.cpp
@@ -314,6 +314,12 @@ String OutOfProcessWebView::notify_server_did_request_prompt(Badge<WebContentCli
return {};
}
+void OutOfProcessWebView::notify_server_did_get_source(const URL& url, const String& source)
+{
+ if (on_get_source)
+ on_get_source(url, source);
+}
+
void OutOfProcessWebView::did_scroll()
{
client().post_message(Messages::WebContentServer::SetViewportRect(visible_content_rect()));
@@ -340,4 +346,9 @@ void OutOfProcessWebView::debug_request(const String& request, const String& arg
client().post_message(Messages::WebContentServer::DebugRequest(request, argument));
}
+void OutOfProcessWebView::get_source()
+{
+ client().post_message(Messages::WebContentServer::GetSource());
+}
+
}
diff --git a/Userland/Libraries/LibWeb/OutOfProcessWebView.h b/Userland/Libraries/LibWeb/OutOfProcessWebView.h
index 0022efded8..1c243abd5a 100644
--- a/Userland/Libraries/LibWeb/OutOfProcessWebView.h
+++ b/Userland/Libraries/LibWeb/OutOfProcessWebView.h
@@ -50,6 +50,7 @@ public:
void load_empty_document();
void debug_request(const String& request, const String& argument = {});
+ void get_source();
void notify_server_did_layout(Badge<WebContentClient>, const Gfx::IntSize& content_size);
void notify_server_did_paint(Badge<WebContentClient>, i32 bitmap_id);
@@ -68,6 +69,7 @@ public:
void notify_server_did_request_alert(Badge<WebContentClient>, const String& message);
bool notify_server_did_request_confirm(Badge<WebContentClient>, const String& message);
String notify_server_did_request_prompt(Badge<WebContentClient>, const String& message, const String& default_);
+ void notify_server_did_get_source(const URL& url, const String& source);
private:
OutOfProcessWebView();
diff --git a/Userland/Libraries/LibWeb/WebContentClient.cpp b/Userland/Libraries/LibWeb/WebContentClient.cpp
index c90bbcb6c5..56a25cf7f6 100644
--- a/Userland/Libraries/LibWeb/WebContentClient.cpp
+++ b/Userland/Libraries/LibWeb/WebContentClient.cpp
@@ -131,6 +131,11 @@ 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());
}
+void WebContentClient::handle(const Messages::WebContentClient::DidGetSource& message)
+{
+ m_view.notify_server_did_get_source(message.url(), message.source());
+}
+
OwnPtr<Messages::WebContentClient::DidRequestAlertResponse> WebContentClient::handle(const Messages::WebContentClient::DidRequestAlert& message)
{
m_view.notify_server_did_request_alert({}, message.message());
diff --git a/Userland/Libraries/LibWeb/WebContentClient.h b/Userland/Libraries/LibWeb/WebContentClient.h
index 87fe8cbba9..513c4b5afd 100644
--- a/Userland/Libraries/LibWeb/WebContentClient.h
+++ b/Userland/Libraries/LibWeb/WebContentClient.h
@@ -64,6 +64,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 void handle(const Messages::WebContentClient::DidGetSource& message);
virtual OwnPtr<Messages::WebContentClient::DidRequestAlertResponse> handle(const Messages::WebContentClient::DidRequestAlert&) override;
virtual OwnPtr<Messages::WebContentClient::DidRequestConfirmResponse> handle(const Messages::WebContentClient::DidRequestConfirm&) override;
virtual OwnPtr<Messages::WebContentClient::DidRequestPromptResponse> handle(const Messages::WebContentClient::DidRequestPrompt&) override;
diff --git a/Userland/Libraries/LibWeb/WebViewHooks.h b/Userland/Libraries/LibWeb/WebViewHooks.h
index 198526e019..4ab97527c3 100644
--- a/Userland/Libraries/LibWeb/WebViewHooks.h
+++ b/Userland/Libraries/LibWeb/WebViewHooks.h
@@ -46,6 +46,7 @@ public:
Function<void(const Gfx::Bitmap&)> on_favicon_change;
Function<void(const URL&)> on_url_drop;
Function<void(DOM::Document*)> on_set_document;
+ Function<void(const URL&, const String&)> on_get_source;
};
}