webview-lib: extend to support setting icons on Linux
This commit is contained in:
@@ -4,17 +4,16 @@ pkgs.clangStdenv.mkDerivation {
|
|||||||
pname = "webview";
|
pname = "webview";
|
||||||
version = "nightly";
|
version = "nightly";
|
||||||
|
|
||||||
src = pkgs.fetchFromGitHub {
|
|
||||||
owner = "webview";
|
|
||||||
repo = "webview";
|
|
||||||
rev = "f1a9d6b6fb8bcc2e266057224887a3d628f30f90";
|
|
||||||
sha256 = "sha256-sK7GXDbb2zEntWH5ylC2B39zW+gXvqQ1l843gvziDZo=";
|
|
||||||
};
|
|
||||||
|
|
||||||
# We add the function id to the promise to be able to cancel it through the UI
|
# We add the function id to the promise to be able to cancel it through the UI
|
||||||
# We disallow remote connections from the UI on Linux
|
# We disallow remote connections from the UI on Linux
|
||||||
# TODO: Disallow remote connections on MacOS
|
# TODO: Disallow remote connections on MacOS
|
||||||
patches = [ ./fixes.patch ];
|
|
||||||
|
src = pkgs.fetchFromGitHub {
|
||||||
|
owner = "clan-lol";
|
||||||
|
repo = "webview";
|
||||||
|
rev = "33374e1030c5e243dac491e6c0e84d32e895c2e5";
|
||||||
|
sha256 = "sha256-8BgfQL0V3f2n5lq5MDwJCJo6MkVSYvJkwpKCj2tBRz8=";
|
||||||
|
};
|
||||||
|
|
||||||
outputs = [
|
outputs = [
|
||||||
"out"
|
"out"
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
diff --git a/core/include/webview/detail/backends/gtk_webkitgtk.hh b/core/include/webview/detail/backends/gtk_webkitgtk.hh
|
|
||||||
index f44db8f..b5657ca 100644
|
|
||||||
--- a/core/include/webview/detail/backends/gtk_webkitgtk.hh
|
|
||||||
+++ b/core/include/webview/detail/backends/gtk_webkitgtk.hh
|
|
||||||
@@ -303,6 +303,37 @@ private:
|
|
||||||
add_init_script("function(message) {\n\
|
|
||||||
return window.webkit.messageHandlers.__webview__.postMessage(message);\n\
|
|
||||||
}");
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+ //===================MY CHANGES=========================
|
|
||||||
+ // TODO: Would be nice to have this configurable from the API.
|
|
||||||
+ auto on_decide_policy = +[] (WebKitWebView *,
|
|
||||||
+ WebKitPolicyDecision *decision,
|
|
||||||
+ WebKitPolicyDecisionType decision_type, gpointer) -> gboolean {
|
|
||||||
+ if (decision_type != WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION) {
|
|
||||||
+ return FALSE; // Continue with the default handler
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ WebKitNavigationPolicyDecision * navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision);
|
|
||||||
+ WebKitNavigationAction * navigation_action = webkit_navigation_policy_decision_get_navigation_action (navigation_decision);
|
|
||||||
+ WebKitURIRequest * request = webkit_navigation_action_get_request (navigation_action);
|
|
||||||
+ const char * uri = webkit_uri_request_get_uri (request);
|
|
||||||
+
|
|
||||||
+ if (g_str_has_prefix(uri, "file://") ||
|
|
||||||
+ g_str_has_prefix(uri, "http://localhost") ||
|
|
||||||
+ g_str_has_prefix(uri, "http://127.0.0.1") ||
|
|
||||||
+ g_str_has_prefix(uri, "http://[::1]")) {
|
|
||||||
+ printf("Allowing %s URI\n", uri);
|
|
||||||
+ return FALSE; // Continue with the default handler
|
|
||||||
+ } else {
|
|
||||||
+ printf("Blocking %s URI at %s:%d\n", uri, __FILE__, __LINE__);
|
|
||||||
+ webkit_policy_decision_ignore(decision);
|
|
||||||
+ return TRUE; // Stop the default handler
|
|
||||||
+ }
|
|
||||||
+ };
|
|
||||||
+ g_signal_connect(GTK_WIDGET(m_webview), "decide-policy",
|
|
||||||
+ G_CALLBACK(on_decide_policy), this);
|
|
||||||
+ //============END=========
|
|
||||||
}
|
|
||||||
|
|
||||||
void window_settings(bool debug) {
|
|
||||||
diff --git a/core/include/webview/detail/engine_base.hh b/core/include/webview/detail/engine_base.hh
|
|
||||||
index 01c8d29..8ea5622 100644
|
|
||||||
--- a/core/include/webview/detail/engine_base.hh
|
|
||||||
+++ b/core/include/webview/detail/engine_base.hh
|
|
||||||
@@ -232,6 +232,7 @@ protected:
|
|
||||||
var promise = new Promise(function(resolve, reject) {\n\
|
|
||||||
_promises[_id] = { resolve, reject };\n\
|
|
||||||
});\n\
|
|
||||||
+ promise._webviewMessageId = _id;\n\
|
|
||||||
this.post(JSON.stringify({\n\
|
|
||||||
id: _id,\n\
|
|
||||||
method: method,\n\
|
|
||||||
Reference in New Issue
Block a user