summaryrefslogtreecommitdiff
path: root/embed/web-extension/ephy-web-extension-main.c
blob: 9c416a014de0ee303ad76940e713569ca66cb701 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=2 sts=2 et: */
/*
 *  Copyright © 2012 Igalia S.L.
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2, or (at your option)
 *  any later version.
 *
 *  This program 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 General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "config.h"

#include "ephy-web-extension.h"
#include "ephy-debug.h"
#include "ephy-file-helpers.h"

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-prototypes"

static EphyWebExtension *extension = NULL;

G_MODULE_EXPORT void
webkit_web_extension_initialize_with_user_data (WebKitWebExtension *webkit_extension,
                                                GVariant *user_data)
{
  const char *server_address;
  const char *dot_dir;
  gboolean private_profile;
  GError *error = NULL;

  g_variant_get (user_data, "(m&s&sb)", &server_address, &dot_dir, &private_profile);

  if (!server_address) {
    g_warning ("UI process did not start D-Bus server, giving up.");
    return;
  }

  if (!ephy_file_helpers_init (dot_dir, 0, &error)) {
    g_warning ("Failed to initialize file helpers: %s", error->message);
    g_error_free (error);
  }

  ephy_debug_init ();

  extension = ephy_web_extension_get ();

  ephy_web_extension_initialize (extension,
                                 webkit_extension,
                                 server_address,
                                 dot_dir,
                                 private_profile);
}

static void __attribute__((destructor))
ephy_web_extension_shutdown (void)
{
  if (extension)
    g_object_unref (extension);
}

#pragma GCC diagnostic pop