summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Pablo Ugarte <juanpablougarte@gmail.com>2020-06-16 19:40:42 -0300
committerJuan Pablo Ugarte <juanpablougarte@gmail.com>2020-06-16 19:40:42 -0300
commitd981b9883a33c18c19f9684d90c5f79baf1d6025 (patch)
tree3d3ca554b124c8222976727ca047d6cc2a3d9ff7
parent0a948e4fd3169954c20d2af84d7e3b5e9323ec77 (diff)
downloadglade-d981b9883a33c18c19f9684d90c5f79baf1d6025.tar.gz
Webkit2gtk plugin: sandbox web view
Fix misc runtime warnings
-rw-r--r--plugins/webkit2gtk/glade-webkit2gtk.c22
-rw-r--r--plugins/webkit2gtk/webkit2gtk.xml2
2 files changed, 16 insertions, 8 deletions
diff --git a/plugins/webkit2gtk/glade-webkit2gtk.c b/plugins/webkit2gtk/glade-webkit2gtk.c
index a934e688..e680cef5 100644
--- a/plugins/webkit2gtk/glade-webkit2gtk.c
+++ b/plugins/webkit2gtk/glade-webkit2gtk.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 Juan Pablo Ugarte
+ * Copyright (C) 2011-2020 Juan Pablo Ugarte
* 2016 Endless Mobile Inc.
*
* This library is free software; you can redistribute it and/or
@@ -28,6 +28,13 @@
#include <gladeui/glade.h>
void
+glade_webkit2gtk_init (const gchar *name)
+{
+ /* Enable Sandbox */
+ webkit_web_context_set_sandbox_enabled (webkit_web_context_get_default (), TRUE);
+}
+
+void
glade_webkit_web_view_set_property (GladeWidgetAdaptor *adaptor,
GObject *object,
const gchar *id,
@@ -36,19 +43,20 @@ glade_webkit_web_view_set_property (GladeWidgetAdaptor *adaptor,
if (g_str_equal(id, "glade-url"))
{
const gchar *url = g_value_get_string (value);
- gchar *scheme = g_uri_parse_scheme (url);
+ g_autofree gchar *scheme, *full_url;
+
+ if (!url)
+ return;
- if (scheme)
+ if ((scheme = g_uri_parse_scheme (url)))
{
webkit_web_view_load_uri (WEBKIT_WEB_VIEW (object), url);
- g_free (scheme);
return;
}
- gchar *full_url = g_strconcat ("http://", url, NULL);
+ full_url = g_strconcat ("http://", url, NULL);
webkit_web_view_load_uri (WEBKIT_WEB_VIEW (object), full_url);
- g_free (full_url);
}
else
- GWA_GET_CLASS(G_TYPE_OBJECT)->set_property (adaptor, object, id, value);
+ GWA_GET_CLASS(GTK_TYPE_WIDGET)->set_property (adaptor, object, id, value);
}
diff --git a/plugins/webkit2gtk/webkit2gtk.xml b/plugins/webkit2gtk/webkit2gtk.xml
index 4f7b5af7..5c3c2443 100644
--- a/plugins/webkit2gtk/webkit2gtk.xml
+++ b/plugins/webkit2gtk/webkit2gtk.xml
@@ -6,7 +6,7 @@
domain="glade"
depends="gtk+"
book="WebKit2GTK">
-
+ <init-function>glade_webkit2gtk_init</init-function>
<glade-widget-classes>
<glade-widget-class name="WebKitWebView"