1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3  *  Copyright © 2012 Igalia S.L.
4  *
5  *  This file is part of Epiphany.
6  *
7  *  Epiphany is free software: you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation, either version 3 of the License, or
10  *  (at your option) any later version.
11  *
12  *  Epiphany is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with Epiphany.  If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #include "config.h"
22 
23 #include "ephy-web-process-extension.h"
24 #include "ephy-debug.h"
25 #include "ephy-file-helpers.h"
26 #include "ephy-flatpak-utils.h"
27 #include "ephy-settings.h"
28 
29 #pragma GCC diagnostic push
30 #pragma GCC diagnostic ignored "-Wmissing-prototypes"
31 
32 static EphyWebProcessExtension *extension = NULL;
33 
34 G_MODULE_EXPORT void
webkit_web_extension_initialize_with_user_data(WebKitWebExtension * webkit_extension,GVariant * user_data)35 webkit_web_extension_initialize_with_user_data (WebKitWebExtension *webkit_extension,
36                                                 GVariant           *user_data)
37 {
38   const char *guid;
39   const char *profile_dir;
40   gboolean private_profile;
41   gboolean should_remember_passwords;
42   g_autoptr (GError) error = NULL;
43 
44   g_variant_get (user_data, "(&sm&sbb)", &guid, &profile_dir, &should_remember_passwords, &private_profile);
45 
46   if (!ephy_file_helpers_init (profile_dir, 0, &error))
47     g_warning ("Failed to initialize file helpers: %s", error->message);
48 
49   ephy_debug_init ();
50 
51   ephy_flatpak_utils_set_is_web_process_extension ();
52   ephy_settings_set_is_web_process_extension ();
53 
54   extension = ephy_web_process_extension_get ();
55 
56   ephy_web_process_extension_initialize (extension,
57                                          webkit_extension,
58                                          guid,
59                                          should_remember_passwords,
60                                          private_profile);
61 }
62 
63 static void __attribute__((destructor))
ephy_web_process_extension_shutdown(void)64 ephy_web_process_extension_shutdown (void)
65 {
66   g_clear_object (&extension);
67   ephy_settings_shutdown ();
68   ephy_file_helpers_shutdown ();
69 }
70 
71 #pragma GCC diagnostic pop
72