Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/configure.ac b/configure.ac
- index cda6916..847eace 100644
- --- a/configure.ac
- +++ b/configure.ac
- @@ -498,6 +498,7 @@ src/goa/Makefile
- src/goa/goa-1.0.pc
- src/goabackend/Makefile
- src/goabackend/goa-backend-1.0.pc
- +src/goawebextension/Makefile
- src/goaidentity/Makefile
- src/daemon/Makefile
- src/examples/Makefile
- diff --git a/src/Makefile.am b/src/Makefile.am
- index 63a20e5..3045044 100644
- --- a/src/Makefile.am
- +++ b/src/Makefile.am
- @@ -1,6 +1,6 @@
- NULL =
- -SUBDIRS = goa goaidentity goabackend daemon examples
- +SUBDIRS = goa goaidentity goabackend goawebextension daemon examples
- -include $(top_srcdir)/git.mk
- diff --git a/src/goabackend/Makefile.am b/src/goabackend/Makefile.am
- index 5ca8e5c..182090d 100644
- --- a/src/goabackend/Makefile.am
- +++ b/src/goabackend/Makefile.am
- @@ -3,24 +3,25 @@ NULL =
- CLEANFILES =
- EXTRA_DIST =
- -AM_CPPFLAGS = \
- - -I$(top_builddir)/src -I$(top_srcdir)/src \
- - -I$(top_builddir)/src -I$(top_srcdir)/src \
- - -I$(top_builddir)/src/goa \
- - -I$(top_srcdir)/src/goaidentity \
- - -I$(top_builddir)/src/goaidentity \
- - -DG_LOG_DOMAIN=\"GoaBackend\" \
- - -DGOA_BACKEND_COMPILATION \
- - -DGOA_API_IS_SUBJECT_TO_CHANGE \
- - -DPACKAGE_LIBEXEC_DIR=\""$(libexecdir)"\" \
- - -DPACKAGE_SYSCONF_DIR=\""$(sysconfdir)"\" \
- - -DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\" \
- - -DPACKAGE_BIN_DIR=\""$(bindir)"\" \
- - -DPACKAGE_LOCALSTATE_DIR=\""$(localstatedir)"\" \
- - -DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \
- - -DPACKAGE_LIB_DIR=\""$(libdir)"\" \
- - -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT \
- - $(WARN_CFLAGS) \
- +AM_CPPFLAGS = \
- + -I$(top_builddir)/src -I$(top_srcdir)/src \
- + -I$(top_builddir)/src -I$(top_srcdir)/src \
- + -I$(top_builddir)/src/goa \
- + -I$(top_srcdir)/src/goaidentity \
- + -I$(top_builddir)/src/goaidentity \
- + -DG_LOG_DOMAIN=\"GoaBackend\" \
- + -DGOA_BACKEND_COMPILATION \
- + -DGOA_API_IS_SUBJECT_TO_CHANGE \
- + -DGOA_WEB_EXTENSIONS_DIR=\""$(libdir)/goa-1.0/web-extensions"\" \
- + -DPACKAGE_LIBEXEC_DIR=\""$(libexecdir)"\" \
- + -DPACKAGE_SYSCONF_DIR=\""$(sysconfdir)"\" \
- + -DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\" \
- + -DPACKAGE_BIN_DIR=\""$(bindir)"\" \
- + -DPACKAGE_LOCALSTATE_DIR=\""$(localstatedir)"\" \
- + -DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \
- + -DPACKAGE_LIB_DIR=\""$(libdir)"\" \
- + -D_POSIX_PTHREAD_SEMANTICS -D_REENTRANT \
- + $(WARN_CFLAGS) \
- $(NULL)
- # ----------------------------------------------------------------------------------------------------
- diff --git a/src/goabackend/goawebview.c b/src/goabackend/goawebview.c
- index 2fe19d1..99504d3 100644
- --- a/src/goabackend/goawebview.c
- +++ b/src/goabackend/goawebview.c
- @@ -254,11 +254,16 @@ static void
- goa_web_view_class_init (GoaWebViewClass *klass)
- {
- GObjectClass *object_class;
- + WebKitWebContext *web_context;
- object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = goa_web_view_dispose;
- g_type_class_add_private (object_class, sizeof (GoaWebViewPrivate));
- +
- + web_context = webkit_web_context_get_default ();
- + webkit_web_context_set_web_extensions_directory (web_context,
- + GOA_WEB_EXTENSIONS_DIR);
- }
- GtkWidget *
- diff --git a/src/goawebextension/goawebextension.c b/src/goawebextension/goawebextension.c
- new file mode 100644
- index 0000000..e207c14
- --- /dev/null
- +++ b/src/goawebextension/goawebextension.c
- @@ -0,0 +1,114 @@
- +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
- +/*
- + * Copyright (C) 2015 Damián Nohales
- + *
- + * This library is free software; you can redistribute it and/or
- + * modify it under the terms of the GNU Lesser General Public
- + * License as published by the Free Software Foundation; either
- + * version 2 of the License, or (at your option) any later version.
- + *
- + * This library is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- + * Lesser General Public License for more details.
- + *
- + * You should have received a copy of the GNU Lesser General
- + * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
- + */
- +
- +#include "goawebextension.h"
- +
- +struct _GoaWebExtensionPrivate
- +{
- + WebKitWebExtension *extension;
- + gboolean initialized;
- +};
- +
- +G_DEFINE_TYPE_WITH_PRIVATE (GoaWebExtension, goa_web_extension, G_TYPE_OBJECT)
- +
- +enum {
- + PROP_0,
- + LAST_PROP
- +};
- +
- +static GParamSpec *gParamSpecs [LAST_PROP];
- +
- +static void
- +goa_web_extension_finalize (GObject *object)
- +{
- + GoaWebExtensionPrivate *priv = GOA_WEB_EXTENSION (object)->priv;
- +
- + G_OBJECT_CLASS (goa_web_extension_parent_class)->finalize (object);
- +}
- +
- +static void
- +goa_web_extension_get_property (GObject *object,
- + guint prop_id,
- + GValue *value,
- + GParamSpec *pspec)
- +{
- + GoaWebExtension *self = GOA_WEB_EXTENSION (object);
- +
- + switch (prop_id)
- + {
- + default:
- + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- + }
- +}
- +
- +static void
- +goa_web_extension_set_property (GObject *object,
- + guint prop_id,
- + const GValue *value,
- + GParamSpec *pspec)
- +{
- + GoaWebExtension *self = GOA_WEB_EXTENSION (object);
- +
- + switch (prop_id)
- + {
- + default:
- + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- + }
- +}
- +
- +static void
- +goa_web_extension_class_init (GoaWebExtensionClass *klass)
- +{
- + GObjectClass *object_class = G_OBJECT_CLASS (klass);
- +
- + object_class->finalize = goa_web_extension_finalize;
- + object_class->get_property = goa_web_extension_get_property;
- + object_class->set_property = goa_web_extension_set_property;
- +}
- +
- +static void
- +goa_web_extension_init (GoaWebExtension *self)
- +{
- + self->priv = goa_web_extension_get_instance_private (self);
- +}
- +
- +static gpointer
- +goa_web_extension_create_instance(gpointer data)
- +{
- + return g_object_new (EPHY_TYPE_WEB_EXTENSION, NULL);
- +}
- +
- +GoaWebExtension *
- +goa_web_extension_get (void)
- +{
- + static GOnce once_init = G_ONCE_INIT;
- + return GOA_WEB_EXTENSION (g_once (&once_init, goa_web_extension_create_instance, NULL));
- +}
- +
- +void
- +goa_web_extension_initialize (GoaWebExtension *extension,
- + WebKitWebExtension *wk_extension)
- +{
- + g_return_if_fail (EPHY_IS_WEB_EXTENSION (extension));
- +
- + if (priv->initialized)
- + return;
- +
- + priv->initialized = TRUE;
- + priv->extension = g_object_ref (wk_extension);
- +}
- diff --git a/src/goawebextension/goawebextension.h b/src/goawebextension/goawebextension.h
- new file mode 100644
- index 0000000..a0c66bd
- --- /dev/null
- +++ b/src/goawebextension/goawebextension.h
- @@ -0,0 +1,58 @@
- +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
- +/*
- + * Copyright (C) 2015 Damián Nohales
- + *
- + * This library is free software; you can redistribute it and/or
- + * modify it under the terms of the GNU Lesser General Public
- + * License as published by the Free Software Foundation; either
- + * version 2 of the License, or (at your option) any later version.
- + *
- + * This library is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- + * Lesser General Public License for more details.
- + *
- + * You should have received a copy of the GNU Lesser General
- + * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
- + */
- +
- +#ifndef __GOA_WEB_EXTENSION_H__
- +#define __GOA_WEB_EXTENSION_H__
- +
- +#include <glib-object.h>
- +
- +G_BEGIN_DECLS
- +
- +#define GOA_TYPE_WEB_EXTENSION (goa_web_extension_get_type())
- +#define GOA_WEB_EXTENSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GOA_TYPE_WEB_EXTENSION, GoaWebExtension))
- +#define GOA_WEB_EXTENSION_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GOA_TYPE_WEB_EXTENSION, GoaWebExtension const))
- +#define GOA_WEB_EXTENSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GOA_TYPE_WEB_EXTENSION, GoaWebExtensionClass))
- +#define GOA_IS_WEB_EXTENSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GOA_TYPE_WEB_EXTENSION))
- +#define GOA_IS_WEB_EXTENSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GOA_TYPE_WEB_EXTENSION))
- +#define GOA_WEB_EXTENSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GOA_TYPE_WEB_EXTENSION, GoaWebExtensionClass))
- +
- +typedef struct _GoaWebExtension GoaWebExtension;
- +typedef struct _GoaWebExtensionClass GoaWebExtensionClass;
- +typedef struct _GoaWebExtensionPrivate GoaWebExtensionPrivate;
- +
- +struct _GoaWebExtension
- +{
- + GObject parent;
- +
- + /*< private >*/
- + GoaWebExtensionPrivate *priv;
- +};
- +
- +struct _GoaWebExtensionClass
- +{
- + GObjectClass parent;
- +};
- +
- +GType goa_web_extension_get_type (void);
- +GoaWebExtension *goa_web_extension_get (void);
- +void goa_web_extension_initialize (GoaWebExtension *extension,
- + WebKitWebExtension *wk_extension);
- +
- +G_END_DECLS
- +
- +#endif /* __GOA_WEB_EXTENSION_H__ */
- diff --git a/src/goawebextension/goawebkitextensionmain.c b/src/goawebextension/goawebkitextensionmain.c
- new file mode 100644
- index 0000000..83d4517
- --- /dev/null
- +++ b/src/goawebextension/goawebkitextensionmain.c
- @@ -0,0 +1,58 @@
- +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
- +/*
- + * Copyright (C) 2015 Damián Nohales
- + *
- + * This library is free software; you can redistribute it and/or
- + * modify it under the terms of the GNU Lesser General Public
- + * License as published by the Free Software Foundation; either
- + * version 2 of the License, or (at your option) any later version.
- + *
- + * This library is distributed in the hope that it will be useful,
- + * but WITHOUT ANY WARRANTY; without even the implied warranty of
- + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- + * Lesser General Public License for more details.
- + *
- + * You should have received a copy of the GNU Lesser General
- + * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
- + */
- +
- +#include <webkit2/webkit-web-extension.h>
- +
- +#include "goawebextension.h"
- +
- +static void
- +web_page_created_callback (WebKitWebExtension *extension,
- + WebKitWebPage *web_page,
- + gpointer user_data)
- +{
- + g_print ("Page %d created for %s\n",
- + webkit_web_page_get_id (web_page),
- + webkit_web_page_get_uri (web_page));
- +}
- +
- +G_MODULE_EXPORT void
- +webkit_web_extension_initialize (WebKitWebExtension *extension,
- + GVariant *user_data)
- +{
- + GoaWebExtension *web_extension;
- + char *service_name;
- + const char *extension_id;
- + const char *dot_dir;
- + gboolean private_profile;
- + GError *error = NULL;
- +
- + g_variant_get (user_data, "(&s&sb)", &extension_id, &dot_dir, &private_profile);
- +
- + web_extension = goa_web_extension_get ();
- + ephy_web_extension_initialize (web_extension, extension, dot_dir, private_profile);
- +
- + service_name = g_strdup_printf ("%s-%s", EPHY_WEB_EXTENSION_SERVICE_NAME, extension_id);
- + g_bus_own_name (G_BUS_TYPE_SESSION,
- + service_name,
- + G_BUS_NAME_OWNER_FLAGS_NONE,
- + NULL,
- + (GBusNameAcquiredCallback)name_acquired_cb,
- + NULL,
- + web_extension, NULL);
- + g_free (service_name);
- +}
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment