Unreviewed, rolling out r108522.
[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
29 #include <webkit/webkitdefines.h>
30 #include <webkit/webkitdom.h>
31 #include <webkit/webkitwebbackforwardlist.h>
32 #include <webkit/webkitwebframe.h>
33 #include <webkit/webkitwebhistoryitem.h>
34 #include <webkit/webkitwebsettings.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
180     /* Padding for future expansion */
181     void (*_webkit_reserved0) (void);
182     void (*_webkit_reserved1) (void);
183     void (*_webkit_reserved2) (void);
184 };
185
186 WEBKIT_API GType
187 webkit_web_view_get_type (void);
188
189 WEBKIT_API GtkWidget *
190 webkit_web_view_new (void);
191
192 WEBKIT_API const gchar *
193 webkit_web_view_get_title                       (WebKitWebView        *web_view);
194
195
196 WEBKIT_API const gchar *
197 webkit_web_view_get_uri                         (WebKitWebView        *web_view);
198
199 WEBKIT_API void
200 webkit_web_view_set_maintains_back_forward_list (WebKitWebView        *web_view,
201                                                  gboolean              flag);
202
203 WEBKIT_API WebKitWebBackForwardList *
204 webkit_web_view_get_back_forward_list           (WebKitWebView        *web_view);
205
206 WEBKIT_API gboolean
207 webkit_web_view_go_to_back_forward_item         (WebKitWebView        *web_view,
208                                                  WebKitWebHistoryItem *item);
209
210 WEBKIT_API gboolean
211 webkit_web_view_can_go_back                     (WebKitWebView        *web_view);
212
213 WEBKIT_API gboolean
214 webkit_web_view_can_go_back_or_forward          (WebKitWebView        *web_view,
215                                                  gint                  steps);
216 WEBKIT_API gboolean
217 webkit_web_view_can_go_forward                  (WebKitWebView        *web_view);
218
219 WEBKIT_API void
220 webkit_web_view_go_back                         (WebKitWebView        *web_view);
221
222 WEBKIT_API void
223 webkit_web_view_go_back_or_forward              (WebKitWebView        *web_view,
224                                                  gint                  steps);
225 WEBKIT_API void
226 webkit_web_view_go_forward                      (WebKitWebView        *web_view);
227
228 WEBKIT_API void
229 webkit_web_view_stop_loading                    (WebKitWebView        *web_view);
230
231 #if !defined(WEBKIT_DISABLE_DEPRECATED)
232 WEBKIT_API void
233 webkit_web_view_open                            (WebKitWebView        *web_view,
234                                                  const gchar          *uri);
235
236 #endif
237
238 WEBKIT_API void
239 webkit_web_view_reload                          (WebKitWebView        *web_view);
240
241 WEBKIT_API void
242 webkit_web_view_reload_bypass_cache             (WebKitWebView        *web_view);
243
244 WEBKIT_API void
245 webkit_web_view_load_uri                        (WebKitWebView        *web_view,
246                                                  const gchar          *uri);
247 WEBKIT_API void
248 webkit_web_view_load_string                     (WebKitWebView        *web_view,
249                                                  const gchar          *content,
250                                                  const gchar          *mime_type,
251                                                  const gchar          *encoding,
252                                                  const gchar          *base_uri);
253
254 #if !defined(WEBKIT_DISABLE_DEPRECATED)
255 WEBKIT_API void
256 webkit_web_view_load_html_string                (WebKitWebView        *web_view,
257                                                  const gchar          *content,
258                                                  const gchar          *base_uri);
259 #endif
260
261 WEBKIT_API void
262 webkit_web_view_load_request                    (WebKitWebView        *web_view,
263                                                  WebKitNetworkRequest *request);
264
265 WEBKIT_API gboolean
266 webkit_web_view_search_text                     (WebKitWebView        *web_view,
267                                                  const gchar          *text,
268                                                  gboolean              case_sensitive,
269                                                  gboolean              forward,
270                                                  gboolean              wrap);
271
272 WEBKIT_API guint
273 webkit_web_view_mark_text_matches               (WebKitWebView        *web_view,
274                                                  const gchar          *string,
275                                                  gboolean              case_sensitive,
276                                                  guint                 limit);
277
278 WEBKIT_API void
279 webkit_web_view_set_highlight_text_matches      (WebKitWebView        *web_view,
280                                                  gboolean              highlight);
281
282 WEBKIT_API void
283 webkit_web_view_unmark_text_matches             (WebKitWebView        *web_view);
284
285 WEBKIT_API WebKitWebFrame *
286 webkit_web_view_get_main_frame                  (WebKitWebView        *web_view);
287
288 WEBKIT_API WebKitWebFrame *
289 webkit_web_view_get_focused_frame               (WebKitWebView        *web_view);
290
291 WEBKIT_API void
292 webkit_web_view_execute_script                  (WebKitWebView        *web_view,
293                                                  const gchar          *script);
294
295 WEBKIT_API gboolean
296 webkit_web_view_can_cut_clipboard               (WebKitWebView        *web_view);
297
298 WEBKIT_API gboolean
299 webkit_web_view_can_copy_clipboard              (WebKitWebView        *web_view);
300
301 WEBKIT_API gboolean
302 webkit_web_view_can_paste_clipboard             (WebKitWebView        *web_view);
303
304 WEBKIT_API void
305 webkit_web_view_cut_clipboard                   (WebKitWebView        *web_view);
306
307 WEBKIT_API void
308 webkit_web_view_copy_clipboard                  (WebKitWebView        *web_view);
309
310 WEBKIT_API void
311 webkit_web_view_paste_clipboard                 (WebKitWebView        *web_view);
312
313 WEBKIT_API void
314 webkit_web_view_delete_selection                (WebKitWebView        *web_view);
315
316 WEBKIT_API gboolean
317 webkit_web_view_has_selection                   (WebKitWebView        *web_view);
318
319 WEBKIT_API void
320 webkit_web_view_select_all                      (WebKitWebView        *web_view);
321
322 WEBKIT_API gboolean
323 webkit_web_view_get_editable                    (WebKitWebView        *web_view);
324
325 WEBKIT_API void
326 webkit_web_view_set_editable                    (WebKitWebView        *web_view,
327                                                  gboolean              flag);
328
329 WEBKIT_API GtkTargetList *
330 webkit_web_view_get_copy_target_list            (WebKitWebView        *web_view);
331
332 WEBKIT_API GtkTargetList *
333 webkit_web_view_get_paste_target_list           (WebKitWebView        *web_view);
334
335 WEBKIT_API void
336 webkit_web_view_set_settings                    (WebKitWebView        *web_view,
337                                                  WebKitWebSettings    *settings);
338
339 WEBKIT_API WebKitWebSettings *
340 webkit_web_view_get_settings                    (WebKitWebView        *web_view);
341
342 WEBKIT_API WebKitWebInspector *
343 webkit_web_view_get_inspector                   (WebKitWebView        *web_view);
344
345 WEBKIT_API WebKitWebWindowFeatures*
346 webkit_web_view_get_window_features             (WebKitWebView        *web_view);
347
348 WEBKIT_API gboolean
349 webkit_web_view_can_show_mime_type              (WebKitWebView        *web_view,
350                                                  const gchar          *mime_type);
351
352 WEBKIT_API gboolean
353 webkit_web_view_get_transparent                 (WebKitWebView        *web_view);
354
355 WEBKIT_API void
356 webkit_web_view_set_transparent                 (WebKitWebView        *web_view,
357                                                  gboolean              flag);
358
359 WEBKIT_API gfloat
360 webkit_web_view_get_zoom_level                  (WebKitWebView        *web_view);
361
362 WEBKIT_API void
363 webkit_web_view_set_zoom_level                  (WebKitWebView        *web_view,
364                                                  gfloat                zoom_level);
365
366 WEBKIT_API void
367 webkit_web_view_zoom_in                         (WebKitWebView        *web_view);
368
369 WEBKIT_API void
370 webkit_web_view_zoom_out                        (WebKitWebView        *web_view);
371
372 WEBKIT_API gboolean
373 webkit_web_view_get_full_content_zoom           (WebKitWebView        *web_view);
374
375 WEBKIT_API void
376 webkit_web_view_set_full_content_zoom           (WebKitWebView        *web_view,
377                                                  gboolean              full_content_zoom);
378
379 WEBKIT_API const gchar*
380 webkit_web_view_get_encoding                    (WebKitWebView        *web_view);
381
382 WEBKIT_API void
383 webkit_web_view_set_custom_encoding             (WebKitWebView        *web_view,
384                                                  const gchar          *encoding);
385
386 WEBKIT_API const char*
387 webkit_web_view_get_custom_encoding             (WebKitWebView        *web_view);
388
389 WEBKIT_API void
390 webkit_web_view_set_view_mode                   (WebKitWebView        *web_view,
391                                                  WebKitWebViewViewMode mode);
392
393 WEBKIT_API WebKitWebViewViewMode
394 webkit_web_view_get_view_mode                   (WebKitWebView        *web_view);
395
396 WEBKIT_API void
397 webkit_web_view_move_cursor                     (WebKitWebView        *web_view,
398                                                  GtkMovementStep        step,
399                                                  gint                   count);
400
401 WEBKIT_API WebKitLoadStatus
402 webkit_web_view_get_load_status                 (WebKitWebView        *web_view);
403
404 WEBKIT_API gdouble
405 webkit_web_view_get_progress                    (WebKitWebView        *web_view);
406
407 WEBKIT_API void
408 webkit_web_view_undo                            (WebKitWebView        *web_view);
409
410 WEBKIT_API gboolean
411 webkit_web_view_can_undo                        (WebKitWebView        *web_view);
412
413 WEBKIT_API void
414 webkit_web_view_redo                            (WebKitWebView        *web_view);
415
416 WEBKIT_API gboolean
417 webkit_web_view_can_redo                        (WebKitWebView        *web_view);
418
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
426 WEBKIT_API WebKitHitTestResult*
427 webkit_web_view_get_hit_test_result             (WebKitWebView        *web_view,
428                                                  GdkEventButton       *event);
429
430 WEBKIT_API const gchar *
431 webkit_web_view_get_icon_uri                    (WebKitWebView        *web_view);
432
433 WEBKIT_API GdkPixbuf *
434 webkit_web_view_get_icon_pixbuf                 (WebKitWebView        *web_view);
435
436 WEBKIT_API WebKitDOMDocument *
437 webkit_web_view_get_dom_document                (WebKitWebView        *web_view);
438
439 WEBKIT_API WebKitViewportAttributes*
440 webkit_web_view_get_viewport_attributes         (WebKitWebView        *web_view);
441
442 G_END_DECLS
443
444 #endif