[glade] Webkit2gtk plugin: sandbox web view
- From: Juan Pablo Ugarte <jpu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade] Webkit2gtk plugin: sandbox web view
- Date: Tue, 16 Jun 2020 22:42:42 +0000 (UTC)
commit d981b9883a33c18c19f9684d90c5f79baf1d6025
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date: Tue Jun 16 19:40:42 2020 -0300
Webkit2gtk plugin: sandbox web view
Fix misc runtime warnings
plugins/webkit2gtk/glade-webkit2gtk.c | 22 +++++++++++++++-------
plugins/webkit2gtk/webkit2gtk.xml | 2 +-
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
@@ -27,6 +27,13 @@
#include <webkit2/webkit2.h>
#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,
@@ -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"
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]