1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /*
3  *  Copyright © 2019-2020 Jan-Michael Brummer <jan.brummer@tabos.org>
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 
22 #pragma once
23 
24 #include "ephy-debug.h"
25 #include "ephy-window.h"
26 
27 #include <gdk-pixbuf/gdk-pixbuf.h>
28 #include <gio/gio.h>
29 #include <string.h>
30 #include <webkit2/webkit2.h>
31 
32 G_BEGIN_DECLS
33 
34 #define EPHY_TYPE_WEB_EXTENSION (ephy_web_extension_get_type ())
35 
36 G_DECLARE_FINAL_TYPE (EphyWebExtension, ephy_web_extension, EPHY, WEB_EXTENSION, GObject)
37 
38 typedef char *(*executeHandler)(EphyWebExtension *web_extension,
39                                 char             *name,
40                                 JSCValue         *args);
41 
42 typedef struct {
43   char *name;
44   executeHandler execute;
45 } EphyWebExtensionApiHandler;
46 
47 GdkPixbuf             *ephy_web_extension_get_icon                        (EphyWebExtension *self,
48                                                                            gint64            size);
49 
50 const char            *ephy_web_extension_get_name                        (EphyWebExtension *self);
51 
52 const char            *ephy_web_extension_get_version                     (EphyWebExtension *self);
53 
54 const char            *ephy_web_extension_get_description                 (EphyWebExtension *self);
55 
56 const char            *ephy_web_extension_get_homepage_url                (EphyWebExtension *self);
57 
58 const char            *ephy_web_extension_get_author                      (EphyWebExtension *self);
59 
60 GList                 *ephy_web_extensions_get                            (void);
61 
62 EphyWebExtension      *ephy_web_extension_load                            (GFile *file);
63 
64 void                   ephy_web_extension_load_async                      (GFile               *target,
65                                                                            GCancellable        *cancellable,
66                                                                            GAsyncReadyCallback  callback,
67                                                                            gpointer             user_data);
68 
69 EphyWebExtension      *ephy_web_extension_load_finished                   (GObject       *unused,
70                                                                            GAsyncResult  *result,
71                                                                            GError       **error);
72 
73 GdkPixbuf             *ephy_web_extension_load_pixbuf                     (EphyWebExtension *self,
74                                                                            char             *file);
75 
76 gboolean               ephy_web_extension_has_page_action                 (EphyWebExtension *self);
77 
78 gboolean               ephy_web_extension_has_browser_action              (EphyWebExtension *self);
79 
80 gboolean               ephy_web_extension_has_background_web_view         (EphyWebExtension *self);
81 
82 void                   ephy_web_extension_remove                          (EphyWebExtension *self);
83 
84 const char            *ephy_web_extension_get_manifest                    (EphyWebExtension *self);
85 
86 const char            *ephy_web_extension_background_web_view_get_page    (EphyWebExtension *self);
87 
88 GdkPixbuf             *ephy_web_extension_browser_action_get_icon         (EphyWebExtension *self,
89                                                                            int               size);
90 
91 const char            *ephy_web_extension_browser_action_get_tooltip      (EphyWebExtension *self);
92 
93 const char            *ephy_web_extension_get_browser_popup               (EphyWebExtension *self);
94 
95 GPtrArray             *ephy_web_extension_background_web_view_get_scripts (EphyWebExtension *self);
96 
97 GList                 *ephy_web_extension_get_content_scripts             (EphyWebExtension *self);
98 
99 GList                 *ephy_web_extension_get_content_script_js           (EphyWebExtension *self,
100                                                                            gpointer          content_script);
101 
102 const char            *ephy_web_extension_get_base_location               (EphyWebExtension *self);
103 
104 gconstpointer          ephy_web_extension_get_resource                    (EphyWebExtension *self,
105                                                                            const char       *name,
106                                                                            gsize            *length);
107 
108 char                  *ephy_web_extension_get_resource_as_string          (EphyWebExtension *self,
109                                                                            const char       *name);
110 
111 WebKitUserStyleSheet  *ephy_web_extension_add_custom_css                  (EphyWebExtension *self,
112                                                                            const char       *code);
113 
114 WebKitUserStyleSheet  *ephy_web_extension_get_custom_css                  (EphyWebExtension *self,
115                                                                            const char       *code);
116 
117 GList                 *ephy_web_extension_get_custom_css_list             (EphyWebExtension *self);
118 
119 WebKitUserStyleSheet  *ephy_web_extension_custom_css_style                (EphyWebExtension *self,
120                                                                            gpointer          custom_css);
121 
122 char                  *ephy_web_extension_get_option_ui_page              (EphyWebExtension *self);
123 
124 const char            *ephy_web_extension_get_guid                        (EphyWebExtension *self);
125 
126 GPtrArray             *ephy_web_extension_get_permissions                 (EphyWebExtension *self);
127 
128 G_END_DECLS
129 
130