Commit c82d90b1 authored by Sébastien Wilmet's avatar Sébastien Wilmet

Sandbox WebKitGTK

This requires WebKitGTK 2.26.

And GLib 2.64 is needed for g_warning_once().

Fixes #22
parent faf87b0d
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/*
* SPDX-FileCopyrightText: 2012 Aleksander Morgado <aleksander@gnu.org>
* SPDX-FileCopyrightText: 2017 Sébastien Wilmet <swilmet@gnome.org>
/* SPDX-FileCopyrightText: 2012 Aleksander Morgado <aleksander@gnu.org>
* SPDX-FileCopyrightText: 2017-2020 Sébastien Wilmet <swilmet@gnome.org>
* SPDX-License-Identifier: GPL-3.0-or-later
*/
#include "config.h"
#include "dh-init.h"
#include <glib/gi18n-lib.h>
#include <webkit2/webkit2.h>
#include "dh-book-list.h"
#include "dh-profile.h"
#include "dh-settings.h"
......@@ -19,6 +19,9 @@
*
* This function can be called several times, but is meant to be called at the
* beginning of main(), before any other Devhelp function call.
*
* Since version 3.38, this function enables the WebKitGTK sandbox by calling
* webkit_web_context_set_sandbox_enabled() on the default #WebKitWebContext.
*/
void
dh_init (void)
......@@ -26,8 +29,14 @@ dh_init (void)
static gboolean done = FALSE;
if (!done) {
WebKitWebContext *webkit_context;
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
webkit_context = webkit_web_context_get_default ();
webkit_web_context_set_sandbox_enabled (webkit_context, TRUE);
done = TRUE;
}
}
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
/*
* SPDX-FileCopyrightText: 2018 Sébastien Wilmet <swilmet@gnome.org>
/* SPDX-FileCopyrightText: 2018-2020 Sébastien Wilmet <swilmet@gnome.org>
* SPDX-License-Identifier: GPL-3.0-or-later
*/
......@@ -468,12 +467,17 @@ static void
dh_web_view_constructed (GObject *object)
{
DhWebView *view = DH_WEB_VIEW (object);
WebKitWebContext *webkit_context;
WebKitSettings *webkit_settings;
DhSettings *dh_settings;
if (G_OBJECT_CLASS (dh_web_view_parent_class)->constructed != NULL)
G_OBJECT_CLASS (dh_web_view_parent_class)->constructed (object);
webkit_context = webkit_web_view_get_context (WEBKIT_WEB_VIEW (view));
if (!webkit_web_context_get_sandbox_enabled (webkit_context))
g_warning_once ("WebKitWebContext is not sandboxed.");
webkit_settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (view));
webkit_settings_set_enable_back_forward_navigation_gestures (webkit_settings, TRUE);
......
......@@ -34,9 +34,9 @@ LIBDEVHELP_LT_VERSION = '@0@.@1@.@2@'.format(lt_current, lt_revision, lt_age)
WEBKITGTK_DEP_STR = 'webkit2gtk-4.0'
libdevhelp_deps_array = [
['gio-2.0', '>= 2.60'],
['gio-2.0', '>= 2.64'],
['gtk+-3.0', '>= 3.22'],
[WEBKITGTK_DEP_STR, '>= 2.24']
[WEBKITGTK_DEP_STR, '>= 2.26']
]
LIBDEVHELP_DEPS_STR = []
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment