12ea0d69519d04cdce00629f2f226f96e06240fe
[WebKit-https.git] / Source / 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 webkitwebview_h
23 #define webkitwebview_h
24
25 #include <gtk/gtk.h>
26 #include <libsoup/soup.h>
27 #include <JavaScriptCore/JSBase.h>
28 #include <webkit/webkitdefines.h>
29 #include <webkit/webkitfilechooserrequest.h>
30 #include <webkit/webkitwebbackforwardlist.h>
31 #include <webkit/webkitwebframe.h>
32 #include <webkit/webkitwebhistoryitem.h>
33 #include <webkit/webkitwebsettings.h>
34 #include <webkitdom/webkitdom.h>
35
36 G_BEGIN_DECLS
37
38 #define WEBKIT_TYPE_WEB_VIEW            (webkit_web_view_get_type())
39 #define WEBKIT_WEB_VIEW(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_VIEW, WebKitWebView))
40 #define WEBKIT_WEB_VIEW_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  WEBKIT_TYPE_WEB_VIEW, WebKitWebViewClass))
41 #define WEBKIT_IS_WEB_VIEW(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_VIEW))
42 #define WEBKIT_IS_WEB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_TYPE_WEB_VIEW))
43 #define WEBKIT_WEB_VIEW_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_TYPE_WEB_VIEW, WebKitWebViewClass))
44
45 typedef struct _WebKitWebViewPrivate WebKitWebViewPrivate;
46
47 /**
48  * WebKitNavigationResponse:
49  * @WEBKIT_NAVIGATION_RESPONSE_ACCEPT: Instruct WebKit to allow the navigation.
50  * @WEBKIT_NAVIGATION_RESPONSE_IGNORE: Instruct WebKit to ignore the navigation.
51  * @WEBKIT_NAVIGATION_RESPONSE_DOWNLOAD: Instruct WebKit to start a download of the destination instead.
52  *
53  * Enum values used to denote the various responses to a navigation policy decision.
54  **/
55 typedef enum {
56     WEBKIT_NAVIGATION_RESPONSE_ACCEPT,
57     WEBKIT_NAVIGATION_RESPONSE_IGNORE,
58     WEBKIT_NAVIGATION_RESPONSE_DOWNLOAD
59 } WebKitNavigationResponse;
60
61 /**
62  * WebKitWebViewTargetInfo:
63  * @WEBKIT_WEB_VIEW_TARGET_INFO_HTML: Rich markup data
64  * @WEBKIT_WEB_VIEW_TARGET_INFO_TEXT: Text data
65  * @WEBKIT_WEB_VIEW_TARGET_INFO_IMAGE: Image data
66  * @WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST: URI list data
67  * @WEBKIT_WEB_VIEW_TARGET_INFO_NETSCAPE_URL: A single URL in the Netscape protocol
68  *
69  * Enum values used to denote the info value of various selection types. These can be used
70  * to interpret the data WebKitGTK+ publishes via GtkClipboard and drag-and-drop.
71  **/
72 typedef enum
73 {
74     WEBKIT_WEB_VIEW_TARGET_INFO_HTML,
75     WEBKIT_WEB_VIEW_TARGET_INFO_TEXT,
76     WEBKIT_WEB_VIEW_TARGET_INFO_IMAGE,
77     WEBKIT_WEB_VIEW_TARGET_INFO_URI_LIST,
78     WEBKIT_WEB_VIEW_TARGET_INFO_NETSCAPE_URL
79 } WebKitWebViewTargetInfo;
80
81 /**
82  * WebKitWebViewViewMode:
83  * @WEBKIT_WEB_VIEW_VIEW_MODE_WINDOWED: Windowed view mode
84  * @WEBKIT_WEB_VIEW_VIEW_MODE_FLOATING: Floating view mode
85  * @WEBKIT_WEB_VIEW_VIEW_MODE_FULLSCREEN: Fullscreen view mode
86  * @WEBKIT_WEB_VIEW_VIEW_MODE_MAXIMIZED: Maximized view mode
87  * @WEBKIT_WEB_VIEW_VIEW_MODE_MINIMIZED: Minimized view mode
88  *
89  * Enum values used to denote the various types of view modes. See the
90  * #WebKitWebView:view-mode property.
91  **/
92 typedef enum
93 {
94     WEBKIT_WEB_VIEW_VIEW_MODE_WINDOWED,
95     WEBKIT_WEB_VIEW_VIEW_MODE_FLOATING,
96     WEBKIT_WEB_VIEW_VIEW_MODE_FULLSCREEN,
97     WEBKIT_WEB_VIEW_VIEW_MODE_MAXIMIZED,
98     WEBKIT_WEB_VIEW_VIEW_MODE_MINIMIZED
99 } WebKitWebViewViewMode;
100
101 typedef enum
102 {
103     WEBKIT_SELECTION_AFFINITY_UPSTREAM,
104     WEBKIT_SELECTION_AFFINITY_DOWNSTREAM,
105 } WebKitSelectionAffinity;
106
107 typedef enum
108 {
109     WEBKIT_INSERT_ACTION_TYPED,
110     WEBKIT_INSERT_ACTION_PASTED,
111     WEBKIT_INSERT_ACTION_DROPPED,
112 } WebKitInsertAction;
113
114 struct _WebKitWebView {
115     GtkContainer parent_instance;
116
117     /*< private >*/
118     WebKitWebViewPrivate *priv;
119 };
120
121 struct _WebKitWebViewClass {
122     GtkContainerClass parent_class;
123
124     /*< public >*/
125     /*
126      * default handler/virtual methods
127      */
128     WebKitWebView            * (* create_web_view)        (WebKitWebView        *web_view,
129                                                            WebKitWebFrame       *web_frame);
130
131     gboolean                   (* web_view_ready)          (WebKitWebView* web_view);
132
133     gboolean                   (* close_web_view)         (WebKitWebView* web_view);
134
135     WebKitNavigationResponse   (* navigation_requested)   (WebKitWebView        *web_view,
136                                                            WebKitWebFrame       *frame,
137                                                            WebKitNetworkRequest *request);
138     void                       (* window_object_cleared)  (WebKitWebView        *web_view,
139                                                            WebKitWebFrame       *frame,
140                                                            JSGlobalContextRef    context,
141                                                            JSObjectRef           window_object);
142     gchar                    * (* choose_file)            (WebKitWebView        *web_view,
143                                                            WebKitWebFrame       *frame,
144                                                            const gchar          *old_file);
145     gboolean                   (* script_alert)           (WebKitWebView        *web_view,
146                                                            WebKitWebFrame       *frame,
147                                                            const gchar          *alert_message);
148     gboolean                   (* script_confirm)         (WebKitWebView        *web_view,
149                                                            WebKitWebFrame       *frame,
150                                                            const gchar          *confirm_message,
151                                                            gboolean             *did_confirm);
152     gboolean                   (* script_prompt)          (WebKitWebView        *web_view,
153                                                            WebKitWebFrame       *frame,
154                                                            const gchar          *message,
155                                                            const gchar          *default_value,
156                                                            gchar*               *value);
157     gboolean                   (* console_message)        (WebKitWebView        *web_view,
158                                                            const gchar          *message,
159                                                            guint                 line_number,
160                                                            const gchar*          source_id);
161     void                       (* select_all)             (WebKitWebView        *web_view);
162     void                       (* cut_clipboard)          (WebKitWebView        *web_view);
163     void                       (* copy_clipboard)         (WebKitWebView        *web_view);
164     void                       (* paste_clipboard)        (WebKitWebView        *web_view);
165     gboolean                   (* move_cursor)            (WebKitWebView        *web_view,
166                                                            GtkMovementStep       step,
167                                                            gint                  count);
168
169     /*
170      * internal
171      */
172     void                       (* set_scroll_adjustments) (WebKitWebView        *web_view,
173                                                            GtkAdjustment        *hadjustment,
174                                                            GtkAdjustment        *vadjustment);
175
176     void                       (* undo)                   (WebKitWebView        *web_view);
177     void                       (* redo)                   (WebKitWebView        *web_view);
178     gboolean                   (* should_allow_editing_action) (WebKitWebView   *web_view);
179     gboolean                   (* entering_fullscreen) (WebKitWebView   *web_view);
180     gboolean                   (* leaving_fullscreen) (WebKitWebView   *web_view);
181     gboolean                   (* run_file_chooser)       (WebKitWebView            *web_view,
182                                                            WebKitFileChooserRequest *request);
183 };
184
185 WEBKIT_API GType
186 webkit_web_view_get_type (void);
187
188 WEBKIT_API GtkWidget *
189 webkit_web_view_new (void);
190
191 WEBKIT_API const gchar *
192 webkit_web_view_get_title                       (WebKitWebView        *web_view);
193
194
195 WEBKIT_API const gchar *
196 webkit_web_view_get_uri                         (WebKitWebView        *web_view);
197
198 WEBKIT_API void
199 webkit_web_view_set_maintains_back_forward_list (WebKitWebView        *web_view,
200                                                  gboolean              flag);
201
202 WEBKIT_API WebKitWebBackForwardList *
203 webkit_web_view_get_back_forward_list           (WebKitWebView        *web_view);
204
205 WEBKIT_API gboolean
206 webkit_web_view_go_to_back_forward_item         (WebKitWebView        *web_view,
207                                                  WebKitWebHistoryItem *item);
208
209 WEBKIT_API gboolean
210 webkit_web_view_can_go_back                     (WebKitWebView        *web_view);
211
212 WEBKIT_API gboolean
213 webkit_web_view_can_go_back_or_forward          (WebKitWebView        *web_view,
214                                                  gint                  steps);
215 WEBKIT_API gboolean
216 webkit_web_view_can_go_forward                  (WebKitWebView        *web_view);
217
218 WEBKIT_API void
219 webkit_web_view_go_back                         (WebKitWebView        *web_view);
220
221 WEBKIT_API void
222 webkit_web_view_go_back_or_forward              (WebKitWebView        *web_view,
223                                                  gint                  steps);
224 WEBKIT_API void
225 webkit_web_view_go_forward                      (WebKitWebView        *web_view);
226
227 WEBKIT_API void
228 webkit_web_view_stop_loading                    (WebKitWebView        *web_view);
229
230 #if !defined(WEBKIT_DISABLE_DEPRECATED)
231 WEBKIT_API void
232 webkit_web_view_open                            (WebKitWebView        *web_view,
233                                                  const gchar          *uri);
234
235 #endif
236
237 WEBKIT_API void
238 webkit_web_view_reload                          (WebKitWebView        *web_view);
239
240 WEBKIT_API void
241 webkit_web_view_reload_bypass_cache             (WebKitWebView        *web_view);
242
243 WEBKIT_API void
244 webkit_web_view_load_uri                        (WebKitWebView        *web_view,
245                                                  const gchar          *uri);
246 WEBKIT_API void
247 webkit_web_view_load_string                     (WebKitWebView        *web_view,
248                                                  const gchar          *content,
249                                                  const gchar          *mime_type,
250                                                  const gchar          *encoding,
251                                                  const gchar          *base_uri);
252
253 #if !defined(WEBKIT_DISABLE_DEPRECATED)
254 WEBKIT_API void
255 webkit_web_view_load_html_string                (WebKitWebView        *web_view,
256                                                  const gchar          *content,
257                                                  const gchar          *base_uri);
258 #endif
259
260 WEBKIT_API void
261 webkit_web_view_load_request                    (WebKitWebView        *web_view,
262                                                  WebKitNetworkRequest *request);
263
264 WEBKIT_API gboolean
265 webkit_web_view_search_text                     (WebKitWebView        *web_view,
266                                                  const gchar          *text,
267                                                  gboolean              case_sensitive,
268                                                  gboolean              forward,
269                                                  gboolean              wrap);
270
271 WEBKIT_API guint
272 webkit_web_view_mark_text_matches               (WebKitWebView        *web_view,
273                                                  const gchar          *string,
274                                                  gboolean              case_sensitive,
275                                                  guint                 limit);
276
277 WEBKIT_API void
278 webkit_web_view_set_highlight_text_matches      (WebKitWebView        *web_view,
279                                                  gboolean              highlight);
280
281 WEBKIT_API void
282 webkit_web_view_unmark_text_matches             (WebKitWebView        *web_view);
283
284 WEBKIT_API WebKitWebFrame *
285 webkit_web_view_get_main_frame                  (WebKitWebView        *web_view);
286
287 WEBKIT_API WebKitWebFrame *
288 webkit_web_view_get_focused_frame               (WebKitWebView        *web_view);
289
290 WEBKIT_API void
291 webkit_web_view_execute_script                  (WebKitWebView        *web_view,
292                                                  const gchar          *script);
293
294 WEBKIT_API gboolean
295 webkit_web_view_can_cut_clipboard               (WebKitWebView        *web_view);
296
297 WEBKIT_API gboolean
298 webkit_web_view_can_copy_clipboard              (WebKitWebView        *web_view);
299
300 WEBKIT_API gboolean
301 webkit_web_view_can_paste_clipboard             (WebKitWebView        *web_view);
302
303 WEBKIT_API void
304 webkit_web_view_cut_clipboard                   (WebKitWebView        *web_view);
305
306 WEBKIT_API void
307 webkit_web_view_copy_clipboard                  (WebKitWebView        *web_view);
308
309 WEBKIT_API void
310 webkit_web_view_paste_clipboard                 (WebKitWebView        *web_view);
311
312 WEBKIT_API void
313 webkit_web_view_delete_selection                (WebKitWebView        *web_view);
314
315 WEBKIT_API gboolean
316 webkit_web_view_has_selection                   (WebKitWebView        *web_view);
317
318 WEBKIT_API void
319 webkit_web_view_select_all                      (WebKitWebView        *web_view);
320
321 WEBKIT_API gboolean
322 webkit_web_view_get_editable                    (WebKitWebView        *web_view);
323
324 WEBKIT_API void
325 webkit_web_view_set_editable                    (WebKitWebView        *web_view,
326                                                  gboolean              flag);
327
328 WEBKIT_API GtkTargetList *
329 webkit_web_view_get_copy_target_list            (WebKitWebView        *web_view);
330
331 WEBKIT_API GtkTargetList *
332 webkit_web_view_get_paste_target_list           (WebKitWebView        *web_view);
333
334 WEBKIT_API void
335 webkit_web_view_set_settings                    (WebKitWebView        *web_view,
336                                                  WebKitWebSettings    *settings);
337
338 WEBKIT_API WebKitWebSettings *
339 webkit_web_view_get_settings                    (WebKitWebView        *web_view);
340
341 WEBKIT_API WebKitWebInspector *
342 webkit_web_view_get_inspector                   (WebKitWebView        *web_view);
343
344 WEBKIT_API WebKitWebWindowFeatures*
345 webkit_web_view_get_window_features             (WebKitWebView        *web_view);
346
347 WEBKIT_API gboolean
348 webkit_web_view_can_show_mime_type              (WebKitWebView        *web_view,
349                                                  const gchar          *mime_type);
350
351 WEBKIT_API gboolean
352 webkit_web_view_get_transparent                 (WebKitWebView        *web_view);
353
354 WEBKIT_API void
355 webkit_web_view_set_transparent                 (WebKitWebView        *web_view,
356                                                  gboolean              flag);
357
358 WEBKIT_API gfloat
359 webkit_web_view_get_zoom_level                  (WebKitWebView        *web_view);
360
361 WEBKIT_API void
362 webkit_web_view_set_zoom_level                  (WebKitWebView        *web_view,
363                                                  gfloat                zoom_level);
364
365 WEBKIT_API void
366 webkit_web_view_zoom_in                         (WebKitWebView        *web_view);
367
368 WEBKIT_API void
369 webkit_web_view_zoom_out                        (WebKitWebView        *web_view);
370
371 WEBKIT_API gboolean
372 webkit_web_view_get_full_content_zoom           (WebKitWebView        *web_view);
373
374 WEBKIT_API void
375 webkit_web_view_set_full_content_zoom           (WebKitWebView        *web_view,
376                                                  gboolean              full_content_zoom);
377
378 WEBKIT_API const gchar*
379 webkit_web_view_get_encoding                    (WebKitWebView        *web_view);
380
381 WEBKIT_API void
382 webkit_web_view_set_custom_encoding             (WebKitWebView        *web_view,
383                                                  const gchar          *encoding);
384
385 WEBKIT_API const char*
386 webkit_web_view_get_custom_encoding             (WebKitWebView        *web_view);
387
388 WEBKIT_API void
389 webkit_web_view_set_view_mode                   (WebKitWebView        *web_view,
390                                                  WebKitWebViewViewMode mode);
391
392 WEBKIT_API WebKitWebViewViewMode
393 webkit_web_view_get_view_mode                   (WebKitWebView        *web_view);
394
395 WEBKIT_API void
396 webkit_web_view_move_cursor                     (WebKitWebView        *web_view,
397                                                  GtkMovementStep        step,
398                                                  gint                   count);
399
400 WEBKIT_API WebKitLoadStatus
401 webkit_web_view_get_load_status                 (WebKitWebView        *web_view);
402
403 WEBKIT_API gdouble
404 webkit_web_view_get_progress                    (WebKitWebView        *web_view);
405
406 WEBKIT_API void
407 webkit_web_view_undo                            (WebKitWebView        *web_view);
408
409 WEBKIT_API gboolean
410 webkit_web_view_can_undo                        (WebKitWebView        *web_view);
411
412 WEBKIT_API void
413 webkit_web_view_redo                            (WebKitWebView        *web_view);
414
415 WEBKIT_API gboolean
416 webkit_web_view_can_redo                        (WebKitWebView        *web_view);
417
418 #if !defined(WEBKIT_DISABLE_DEPRECATED)
419 WEBKIT_API void
420 webkit_web_view_set_view_source_mode            (WebKitWebView        *web_view,
421                                                  gboolean             view_source_mode);
422
423 WEBKIT_API gboolean
424 webkit_web_view_get_view_source_mode            (WebKitWebView        *web_view);
425 #endif
426
427 WEBKIT_API WebKitHitTestResult*
428 webkit_web_view_get_hit_test_result             (WebKitWebView        *web_view,
429                                                  GdkEventButton       *event);
430
431 WEBKIT_API const gchar *
432 webkit_web_view_get_icon_uri                    (WebKitWebView        *web_view);
433
434 #if !defined(WEBKIT_DISABLE_DEPRECATED)
435 WEBKIT_API GdkPixbuf *
436 webkit_web_view_get_icon_pixbuf                 (WebKitWebView        *web_view);
437 #endif
438
439 WEBKIT_API GdkPixbuf *
440 webkit_web_view_try_get_favicon_pixbuf          (WebKitWebView        *web_view,
441                                                  guint                 width,
442                                                  guint                 height);
443
444 WEBKIT_API WebKitDOMDocument *
445 webkit_web_view_get_dom_document                (WebKitWebView        *web_view);
446
447 WEBKIT_API WebKitViewportAttributes*
448 webkit_web_view_get_viewport_attributes         (WebKitWebView        *web_view);
449
450 WEBKIT_API cairo_surface_t*
451 webkit_web_view_get_snapshot                    (WebKitWebView        *web_view);
452
453 G_END_DECLS
454
455 #endif