Allow retrieving the Soup session and modify the code to take
[WebKit-https.git] / WebKit / gtk / webkit / webkitwebview.h
1 /*
2  * Copyright (C) 2007 Holger Hans Peter Freyther
3  * Copyright (C) 2007, 2008 Alp Toker <alp@atoker.com>
4  * Copyright (C) 2008 Collabora Ltd.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public License
17  * along with this library; see the file COPYING.LIB.  If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21
22 #ifndef WEBKIT_WEB_VIEW_H
23 #define WEBKIT_WEB_VIEW_H
24
25 #include <gtk/gtk.h>
26 #include <libsoup/soup.h>
27 #include <JavaScriptCore/JSBase.h>
28
29 #include <webkit/webkitdefines.h>
30 #include <webkit/webkitwebbackforwardlist.h>
31 #include <webkit/webkitwebhistoryitem.h>
32 #include <webkit/webkitwebsettings.h>
33
34 G_BEGIN_DECLS
35
36 #define WEBKIT_TYPE_WEB_VIEW            (webkit_web_view_get_type())
37 #define WEBKIT_WEB_VIEW(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_VIEW, WebKitWebView))
38 #define WEBKIT_WEB_VIEW_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  WEBKIT_TYPE_WEB_VIEW, WebKitWebViewClass))
39 #define WEBKIT_IS_WEB_VIEW(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_VIEW))
40 #define WEBKIT_IS_WEB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_TYPE_WEB_VIEW))
41 #define WEBKIT_WEB_VIEW_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_TYPE_WEB_VIEW, WebKitWebViewClass))
42
43 typedef struct _WebKitWebViewPrivate WebKitWebViewPrivate;
44
45 typedef enum {
46     WEBKIT_NAVIGATION_RESPONSE_ACCEPT,
47     WEBKIT_NAVIGATION_RESPONSE_IGNORE,
48     WEBKIT_NAVIGATION_RESPONSE_DOWNLOAD
49 } WebKitNavigationResponse;
50
51 typedef enum
52 {
53     WEBKIT_WEB_VIEW_TARGET_INFO_HTML,
54     WEBKIT_WEB_VIEW_TARGET_INFO_TEXT
55 } WebKitWebViewTargetInfo;
56
57 struct _WebKitWebView {
58     GtkContainer parent_instance;
59
60     /*< private >*/
61     WebKitWebViewPrivate *priv;
62 };
63
64 struct _WebKitWebViewClass {
65     GtkContainerClass parent_class;
66
67     /*< public >*/
68     /*
69      * default handler/virtual methods
70      */
71     WebKitWebView            * (* create_web_view)        (WebKitWebView        *web_view,
72                                                            WebKitWebFrame       *web_frame);
73
74     gboolean                   (* web_view_ready)          (WebKitWebView* web_view);
75
76     WebKitNavigationResponse   (* navigation_requested)   (WebKitWebView        *web_view,
77                                                            WebKitWebFrame       *frame,
78                                                            WebKitNetworkRequest *request);
79     void                       (* window_object_cleared)  (WebKitWebView        *web_view,
80                                                            WebKitWebFrame       *frame,
81                                                            JSGlobalContextRef    context,
82                                                            JSObjectRef           window_object);
83     gchar                    * (* choose_file)            (WebKitWebView        *web_view,
84                                                            WebKitWebFrame       *frame,
85                                                            const gchar          *old_file);
86     gboolean                   (* script_alert)           (WebKitWebView        *web_view,
87                                                            WebKitWebFrame       *frame,
88                                                            const gchar          *alert_message);
89     gboolean                   (* script_confirm)         (WebKitWebView        *web_view,
90                                                            WebKitWebFrame       *frame,
91                                                            const gchar          *confirm_message,
92                                                            gboolean             *did_confirm);
93     gboolean                   (* script_prompt)          (WebKitWebView        *web_view,
94                                                            WebKitWebFrame       *frame,
95                                                            const gchar          *message,
96                                                            const gchar          *default_value,
97                                                            gchar*               *value);
98     gboolean                   (* console_message)        (WebKitWebView        *web_view,
99                                                            const gchar          *message,
100                                                            guint                 line_number,
101                                                            const gchar*          source_id);
102     void                       (* select_all)             (WebKitWebView        *web_view);
103     void                       (* cut_clipboard)          (WebKitWebView        *web_view);
104     void                       (* copy_clipboard)         (WebKitWebView        *web_view);
105     void                       (* paste_clipboard)        (WebKitWebView        *web_view);
106
107     /*
108      * internal
109      */
110     void                       (* set_scroll_adjustments) (WebKitWebView        *web_view,
111                                                            GtkAdjustment        *hadjustment,
112                                                            GtkAdjustment        *vadjustment);
113     /* Padding for future expansion */
114     void (*_webkit_reserved0) (void);
115     void (*_webkit_reserved1) (void);
116     void (*_webkit_reserved2) (void);
117     void (*_webkit_reserved3) (void);
118     void (*_webkit_reserved4) (void);
119     void (*_webkit_reserved5) (void);
120     void (*_webkit_reserved6) (void);
121     void (*_webkit_reserved7) (void);
122 };
123
124 WEBKIT_API GType
125 webkit_web_view_get_type (void);
126
127 WEBKIT_API GtkWidget *
128 webkit_web_view_new (void);
129
130 WEBKIT_API void
131 webkit_web_view_set_maintains_back_forward_list (WebKitWebView        *web_view,
132                                                  gboolean              flag);
133
134 WEBKIT_API WebKitWebBackForwardList *
135 webkit_web_view_get_back_forward_list           (WebKitWebView        *web_view);
136
137 WEBKIT_API gboolean
138 webkit_web_view_go_to_back_forward_item         (WebKitWebView        *web_view,
139                                                  WebKitWebHistoryItem *item);
140
141 WEBKIT_API gboolean
142 webkit_web_view_can_go_back                     (WebKitWebView        *web_view);
143
144 WEBKIT_API gboolean
145 webkit_web_view_can_go_back_or_forward          (WebKitWebView        *web_view,
146                                                  gint                  steps);
147
148 WEBKIT_API gboolean
149 webkit_web_view_can_go_forward                  (WebKitWebView        *web_view);
150
151 WEBKIT_API void
152 webkit_web_view_go_back                         (WebKitWebView        *web_view);
153
154 WEBKIT_API void
155 webkit_web_view_go_back_or_forward              (WebKitWebView        *web_view,
156                                                  gint                  steps);
157
158 WEBKIT_API void
159 webkit_web_view_go_forward                      (WebKitWebView        *web_view);
160
161 WEBKIT_API void
162 webkit_web_view_stop_loading                    (WebKitWebView        *web_view);
163
164 WEBKIT_API void
165 webkit_web_view_open                            (WebKitWebView        *web_view,
166                                                  const gchar          *uri);
167
168 WEBKIT_API void
169 webkit_web_view_reload                          (WebKitWebView        *web_view);
170
171 WEBKIT_API void
172 webkit_web_view_reload_bypass_cache             (WebKitWebView        *web_view);
173
174 WEBKIT_API void
175 webkit_web_view_load_uri                        (WebKitWebView        *web_view,
176                                                  const gchar          *uri);
177
178 WEBKIT_API void
179 webkit_web_view_load_string                     (WebKitWebView        *web_view,
180                                                  const gchar          *content,
181                                                  const gchar          *mime_type,
182                                                  const gchar          *encoding,
183                                                  const gchar          *base_uri);
184
185 WEBKIT_API void
186 webkit_web_view_load_html_string                (WebKitWebView        *web_view,
187                                                  const gchar          *content,
188                                                  const gchar          *base_uri);
189
190 WEBKIT_API void
191 webkit_web_view_load_request                    (WebKitWebView        *web_view,
192                                                  WebKitNetworkRequest *request);
193
194 WEBKIT_API gboolean
195 webkit_web_view_search_text                     (WebKitWebView        *web_view,
196                                                  const gchar          *text,
197                                                  gboolean              case_sensitive,
198                                                  gboolean              forward,
199                                                  gboolean              wrap);
200
201 WEBKIT_API guint
202 webkit_web_view_mark_text_matches               (WebKitWebView        *web_view,
203                                                  const gchar          *string,
204                                                  gboolean              case_sensitive,
205                                                  guint                 limit);
206
207 WEBKIT_API void
208 webkit_web_view_set_highlight_text_matches      (WebKitWebView        *web_view,
209                                                  gboolean              highlight);
210
211 WEBKIT_API void
212 webkit_web_view_unmark_text_matches             (WebKitWebView        *web_view);
213
214 WEBKIT_API WebKitWebFrame *
215 webkit_web_view_get_main_frame                  (WebKitWebView        *web_view);
216
217 WEBKIT_API WebKitWebFrame *
218 webkit_web_view_get_focused_frame               (WebKitWebView        *web_view);
219
220 WEBKIT_API void
221 webkit_web_view_execute_script                  (WebKitWebView        *web_view,
222                                                  const gchar          *script);
223
224 WEBKIT_API gboolean
225 webkit_web_view_can_cut_clipboard               (WebKitWebView        *web_view);
226
227 WEBKIT_API gboolean
228 webkit_web_view_can_copy_clipboard              (WebKitWebView        *web_view);
229
230 WEBKIT_API gboolean
231 webkit_web_view_can_paste_clipboard             (WebKitWebView        *web_view);
232
233 WEBKIT_API void
234 webkit_web_view_cut_clipboard                   (WebKitWebView        *web_view);
235
236 WEBKIT_API void
237 webkit_web_view_copy_clipboard                  (WebKitWebView        *web_view);
238
239 WEBKIT_API void
240 webkit_web_view_paste_clipboard                 (WebKitWebView        *web_view);
241
242 WEBKIT_API void
243 webkit_web_view_delete_selection                (WebKitWebView        *web_view);
244
245 WEBKIT_API gboolean
246 webkit_web_view_has_selection                   (WebKitWebView        *web_view);
247
248 WEBKIT_API void
249 webkit_web_view_select_all                      (WebKitWebView        *web_view);
250
251 WEBKIT_API gboolean
252 webkit_web_view_get_editable                    (WebKitWebView        *web_view);
253
254 WEBKIT_API void
255 webkit_web_view_set_editable                    (WebKitWebView        *web_view,
256                                                  gboolean              flag);
257
258 WEBKIT_API GtkTargetList *
259 webkit_web_view_get_copy_target_list            (WebKitWebView        *web_view);
260
261 WEBKIT_API GtkTargetList *
262 webkit_web_view_get_paste_target_list           (WebKitWebView        *web_view);
263
264 WEBKIT_API void
265 webkit_web_view_set_settings                    (WebKitWebView        *web_view,
266                                                  WebKitWebSettings    *settings);
267
268 WEBKIT_API WebKitWebSettings *
269 webkit_web_view_get_settings                    (WebKitWebView        *web_view);
270
271 WEBKIT_API WebKitWebInspector *
272 webkit_web_view_get_inspector                   (WebKitWebView        *web_view);
273
274 WEBKIT_API WebKitWebWindowFeatures*
275 webkit_web_view_get_window_features             (WebKitWebView        *web_view);
276
277 WEBKIT_API gboolean
278 webkit_web_view_can_show_mime_type              (WebKitWebView        *web_view,
279                                                  const gchar          *mime_type);
280
281 WEBKIT_API gboolean
282 webkit_web_view_get_transparent                 (WebKitWebView        *web_view);
283
284 WEBKIT_API void
285 webkit_web_view_set_transparent                 (WebKitWebView        *web_view,
286                                                  gboolean              flag);
287
288 WEBKIT_API gfloat
289 webkit_web_view_get_zoom_level                  (WebKitWebView        *web_view);
290
291 WEBKIT_API void
292 webkit_web_view_set_zoom_level                  (WebKitWebView        *web_view,
293                                                  gfloat                zoom_level);
294
295 WEBKIT_API void
296 webkit_web_view_zoom_in                         (WebKitWebView        *web_view);
297
298 WEBKIT_API void
299 webkit_web_view_zoom_out                        (WebKitWebView        *web_view);
300
301 WEBKIT_API gboolean
302 webkit_web_view_get_full_content_zoom           (WebKitWebView        *web_view);
303
304 WEBKIT_API void
305 webkit_web_view_set_full_content_zoom           (WebKitWebView        *web_view,
306                                                  gboolean              full_content_zoom);
307
308 WEBKIT_API SoupSession*
309 webkit_get_default_session                      (void);
310
311 G_END_DECLS
312
313 #endif