1/*
2 * Copyright (C) 2007 Holger Hans Peter Freyther
3 * Copyright (C) 2007, 2008 Alp Toker <[email protected]>
4 * Copyright (C) 2008 Collabora Ltd.
5 * Copyright (C) 2011 Igalia S.L.
6 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
17 *
18 * You should have received a copy of the GNU Library General Public License
19 * along with this library; see the file COPYING.LIB. If not, write to
20 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301, USA.
22 */
23
24#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
25#error "Only <webkit2/webkit2.h> can be included directly."
26#endif
27
28#ifndef WebKitWebView_h
29#define WebKitWebView_h
30
31#include <JavaScriptCore/JSBase.h>
32#include <webkit2/WebKitAuthenticationRequest.h>
33#include <webkit2/WebKitBackForwardList.h>
34#include <webkit2/WebKitDefines.h>
35#include <webkit2/WebKitColorChooserRequest.h>
36#include <webkit2/WebKitEditorState.h>
37#include <webkit2/WebKitFileChooserRequest.h>
38#include <webkit2/WebKitFindController.h>
39#include <webkit2/WebKitFormSubmissionRequest.h>
40#include <webkit2/WebKitForwardDeclarations.h>
41#include <webkit2/WebKitHitTestResult.h>
42#include <webkit2/WebKitJavascriptResult.h>
43#include <webkit2/WebKitNavigationAction.h>
44#include <webkit2/WebKitNotification.h>
45#include <webkit2/WebKitOptionMenu.h>
46#include <webkit2/WebKitPermissionRequest.h>
47#include <webkit2/WebKitPolicyDecision.h>
48#include <webkit2/WebKitScriptDialog.h>
49#include <webkit2/WebKitSettings.h>
50#include <webkit2/WebKitURIRequest.h>
51#include <webkit2/WebKitUserContentManager.h>
52#include <webkit2/WebKitWebContext.h>
53#include <webkit2/WebKitWebInspector.h>
54#include <webkit2/WebKitWebResource.h>
55#include <webkit2/WebKitWebViewBase.h>
56#include <webkit2/WebKitWebViewSessionState.h>
57#include <webkit2/WebKitWindowProperties.h>
58
59G_BEGIN_DECLS
60
61#define WEBKIT_TYPE_WEB_VIEW (webkit_web_view_get_type())
62#define WEBKIT_WEB_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_VIEW, WebKitWebView))
63#define WEBKIT_IS_WEB_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_VIEW))
64#define WEBKIT_WEB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_VIEW, WebKitWebViewClass))
65#define WEBKIT_IS_WEB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_VIEW))
66#define WEBKIT_WEB_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_VIEW, WebKitWebViewClass))
67
68typedef struct _WebKitWebViewClass WebKitWebViewClass;
69typedef struct _WebKitWebViewPrivate WebKitWebViewPrivate;
70
71/**
72 * WebKitPolicyDecisionType:
73 * @WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION: This type of policy decision
74 * is requested when WebKit is about to navigate to a new page in either the
75 * main frame or a subframe. Acceptable policy decisions are either
76 * webkit_policy_decision_use() or webkit_policy_decision_ignore(). This
77 * type of policy decision is always a #WebKitNavigationPolicyDecision.
78 * @WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION: This type of policy decision
79 * is requested when WebKit is about to create a new window. Acceptable policy
80 * decisions are either webkit_policy_decision_use() or
81 * webkit_policy_decision_ignore(). This type of policy decision is always
82 * a #WebKitNavigationPolicyDecision. These decisions are useful for implementing
83 * special actions for new windows, such as forcing the new window to open
84 * in a tab when a keyboard modifier is active or handling a special
85 * target attribute on &lt;a&gt; elements.
86 * @WEBKIT_POLICY_DECISION_TYPE_RESPONSE: This type of decision is used when WebKit has
87 * received a response for a network resource and is about to start the load.
88 * Note that these resources include all subresources of a page such as images
89 * and stylesheets as well as main documents. Appropriate policy responses to
90 * this decision are webkit_policy_decision_use(), webkit_policy_decision_ignore(),
91 * or webkit_policy_decision_download(). This type of policy decision is always
92 * a #WebKitResponsePolicyDecision. This decision is useful for forcing
93 * some types of resources to be downloaded rather than rendered in the WebView
94 * or to block the transfer of resources entirely.
95 *
96 * Enum values used for determining the type of a policy decision during
97 * #WebKitWebView::decide-policy.
98 */
99typedef enum {
100 WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION,
101 WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION,
102 WEBKIT_POLICY_DECISION_TYPE_RESPONSE,
103} WebKitPolicyDecisionType;
104
105/**
106 * WebKitLoadEvent:
107 * @WEBKIT_LOAD_STARTED: A new load request has been made.
108 * No data has been received yet, empty structures have
109 * been allocated to perform the load; the load may still
110 * fail due to transport issues such as not being able to
111 * resolve a name, or connect to a port.
112 * @WEBKIT_LOAD_REDIRECTED: A provisional data source received
113 * a server redirect.
114 * @WEBKIT_LOAD_COMMITTED: The content started arriving for a page load.
115 * The necessary transport requirements are established, and the
116 * load is being performed.
117 * @WEBKIT_LOAD_FINISHED: Load completed. All resources are done loading
118 * or there was an error during the load operation.
119 *
120 * Enum values used to denote the different events that happen during a
121 * #WebKitWebView load operation.
122 */
123typedef enum {
124 WEBKIT_LOAD_STARTED,
125 WEBKIT_LOAD_REDIRECTED,
126 WEBKIT_LOAD_COMMITTED,
127 WEBKIT_LOAD_FINISHED
128} WebKitLoadEvent;
129
130/**
131 * WebKitSaveMode:
132 * @WEBKIT_SAVE_MODE_MHTML: Save the current page using the MHTML format.
133 *
134 * Enum values to specify the different ways in which a #WebKitWebView
135 * can save its current web page into a self-contained file.
136 */
137typedef enum {
138 WEBKIT_SAVE_MODE_MHTML
139} WebKitSaveMode;
140
141/**
142 * WebKitInsecureContentEvent:
143 * @WEBKIT_INSECURE_CONTENT_RUN: Insecure content has been detected by
144 * trying to execute any kind of logic (e.g. a script) from an
145 * untrusted source.
146 * @WEBKIT_INSECURE_CONTENT_DISPLAYED: Insecure content has been
147 * detected by trying to display any kind of resource (e.g. an image)
148 * from an untrusted source.
149 *
150 * Enum values used to denote the different events which can trigger
151 * the detection of insecure content.
152 */
153typedef enum {
154 WEBKIT_INSECURE_CONTENT_RUN,
155 WEBKIT_INSECURE_CONTENT_DISPLAYED
156} WebKitInsecureContentEvent;
157
158/**
159 * WebKitSnapshotOptions:
160 * @WEBKIT_SNAPSHOT_OPTIONS_NONE: Do not include any special options.
161 * @WEBKIT_SNAPSHOT_OPTIONS_INCLUDE_SELECTION_HIGHLIGHTING: Whether to include in the
162 * snapshot the highlight of the selected content.
163 * @WEBKIT_SNAPSHOT_OPTIONS_TRANSPARENT_BACKGROUND: Do not fill the background with white before
164 * rendering the snapshot. Since 2.8
165 *
166 * Enum values used to specify options when taking a snapshot
167 * from a #WebKitWebView.
168 */
169typedef enum {
170 WEBKIT_SNAPSHOT_OPTIONS_NONE = 0,
171 WEBKIT_SNAPSHOT_OPTIONS_INCLUDE_SELECTION_HIGHLIGHTING = 1 << 0,
172 WEBKIT_SNAPSHOT_OPTIONS_TRANSPARENT_BACKGROUND = 1 << 1,
173} WebKitSnapshotOptions;
174
175/**
176 * WebKitSnapshotRegion:
177 * @WEBKIT_SNAPSHOT_REGION_VISIBLE: Specifies a snapshot only for the area that is
178 * visible in the webview
179 * @WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT: A snapshot of the entire document.
180 *
181 * Enum values used to specify the region from which to get a #WebKitWebView
182 * snapshot
183 */
184typedef enum {
185 WEBKIT_SNAPSHOT_REGION_VISIBLE = 0,
186 WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT,
187} WebKitSnapshotRegion;
188
189/**
190 * WebKitWebProcessTerminationReason:
191 * @WEBKIT_WEB_PROCESS_CRASHED: the web process crashed.
192 * @WEBKIT_WEB_PROCESS_EXCEEDED_MEMORY_LIMIT: the web process exceeded the memory limit.
193 *
194 * Enum values used to specify the reason why the web process terminated abnormally.
195 *
196 * Since: 2.20
197 */
198typedef enum {
199 WEBKIT_WEB_PROCESS_CRASHED,
200 WEBKIT_WEB_PROCESS_EXCEEDED_MEMORY_LIMIT
201} WebKitWebProcessTerminationReason;
202
203struct _WebKitWebView {
204 WebKitWebViewBase parent;
205
206 /*< private >*/
207 WebKitWebViewPrivate *priv;
208};
209
210struct _WebKitWebViewClass {
211 WebKitWebViewBaseClass parent;
212
213 void (* load_changed) (WebKitWebView *web_view,
214 WebKitLoadEvent load_event);
215 gboolean (* load_failed) (WebKitWebView *web_view,
216 WebKitLoadEvent load_event,
217 const gchar *failing_uri,
218 GError *error);
219
220 GtkWidget *(* create) (WebKitWebView *web_view,
221 WebKitNavigationAction *navigation_action);
222 void (* ready_to_show) (WebKitWebView *web_view);
223 void (* run_as_modal) (WebKitWebView *web_view);
224 void (* close) (WebKitWebView *web_view);
225
226 gboolean (* script_dialog) (WebKitWebView *web_view,
227 WebKitScriptDialog *dialog) ;
228
229 gboolean (* decide_policy) (WebKitWebView *web_view,
230 WebKitPolicyDecision *decision,
231 WebKitPolicyDecisionType type);
232 gboolean (* permission_request) (WebKitWebView *web_view,
233 WebKitPermissionRequest *permission_request);
234 void (* mouse_target_changed) (WebKitWebView *web_view,
235 WebKitHitTestResult *hit_test_result,
236 guint modifiers);
237 gboolean (* print) (WebKitWebView *web_view,
238 WebKitPrintOperation *print_operation);
239 void (* resource_load_started) (WebKitWebView *web_view,
240 WebKitWebResource *resource,
241 WebKitURIRequest *request);
242 gboolean (* enter_fullscreen) (WebKitWebView *web_view);
243 gboolean (* leave_fullscreen) (WebKitWebView *web_view);
244 gboolean (* run_file_chooser) (WebKitWebView *web_view,
245 WebKitFileChooserRequest *request);
246 gboolean (* context_menu) (WebKitWebView *web_view,
247 WebKitContextMenu *context_menu,
248 GdkEvent *event,
249 WebKitHitTestResult *hit_test_result);
250 void (* context_menu_dismissed) (WebKitWebView *web_view);
251 void (* submit_form) (WebKitWebView *web_view,
252 WebKitFormSubmissionRequest *request);
253 void (* insecure_content_detected) (WebKitWebView *web_view,
254 WebKitInsecureContentEvent event);
255 gboolean (* web_process_crashed) (WebKitWebView *web_view);
256
257 gboolean (* authenticate) (WebKitWebView *web_view,
258 WebKitAuthenticationRequest *request);
259 gboolean (* load_failed_with_tls_errors) (WebKitWebView *web_view,
260 const gchar *failing_uri,
261 GTlsCertificate *certificate,
262 GTlsCertificateFlags errors);
263 gboolean (* show_notification) (WebKitWebView *web_view,
264 WebKitNotification *notification);
265 gboolean (* run_color_chooser) (WebKitWebView *web_view,
266 WebKitColorChooserRequest *request);
267 gboolean (* show_option_menu) (WebKitWebView *web_view,
268 GdkRectangle *rectangle,
269 WebKitOptionMenu *menu);
270 void (* web_process_terminated) (WebKitWebView *web_view,
271 WebKitWebProcessTerminationReason reason);
272
273 void (*_webkit_reserved0) (void);
274 void (*_webkit_reserved1) (void);
275};
276
277WEBKIT_API GType
278webkit_web_view_get_type (void);
279
280WEBKIT_API GtkWidget *
281webkit_web_view_new (void);
282
283WEBKIT_API GtkWidget *
284webkit_web_view_new_with_context (WebKitWebContext *context);
285
286WEBKIT_API GtkWidget *
287webkit_web_view_new_with_settings (WebKitSettings *settings);
288
289WEBKIT_API GtkWidget *
290webkit_web_view_new_with_related_view (WebKitWebView *web_view);
291
292WEBKIT_API GtkWidget *
293webkit_web_view_new_with_user_content_manager (WebKitUserContentManager *user_content_manager);
294
295WEBKIT_API gboolean
296webkit_web_view_is_ephemeral (WebKitWebView *web_view);
297
298WEBKIT_API gboolean
299webkit_web_view_is_controlled_by_automation (WebKitWebView *web_view);
300
301WEBKIT_API WebKitWebsiteDataManager *
302webkit_web_view_get_website_data_manager (WebKitWebView *web_view);
303
304WEBKIT_API WebKitWebContext *
305webkit_web_view_get_context (WebKitWebView *web_view);
306
307WEBKIT_API void
308webkit_web_view_try_close (WebKitWebView *web_view);
309
310WEBKIT_API void
311webkit_web_view_load_uri (WebKitWebView *web_view,
312 const gchar *uri);
313
314WEBKIT_API void
315webkit_web_view_load_html (WebKitWebView *web_view,
316 const gchar *content,
317 const gchar *base_uri);
318WEBKIT_API void
319webkit_web_view_load_alternate_html (WebKitWebView *web_view,
320 const gchar *content,
321 const gchar *content_uri,
322 const gchar *base_uri);
323WEBKIT_API void
324webkit_web_view_load_plain_text (WebKitWebView *web_view,
325 const gchar *plain_text);
326
327WEBKIT_API void
328webkit_web_view_load_bytes (WebKitWebView *web_view,
329 GBytes *bytes,
330 const gchar *mime_type,
331 const gchar *encoding,
332 const gchar *base_uri);
333
334WEBKIT_API void
335webkit_web_view_load_request (WebKitWebView *web_view,
336 WebKitURIRequest *request);
337
338WEBKIT_API void
339webkit_web_view_stop_loading (WebKitWebView *web_view);
340
341WEBKIT_API gboolean
342webkit_web_view_is_loading (WebKitWebView *web_view);
343
344WEBKIT_API gboolean
345webkit_web_view_is_playing_audio (WebKitWebView *web_view);
346
347WEBKIT_API guint64
348webkit_web_view_get_page_id (WebKitWebView *web_view);
349
350WEBKIT_API const gchar *
351webkit_web_view_get_title (WebKitWebView *web_view);
352
353WEBKIT_API void
354webkit_web_view_reload (WebKitWebView *web_view);
355
356WEBKIT_API void
357webkit_web_view_reload_bypass_cache (WebKitWebView *web_view);
358
359WEBKIT_API gdouble
360webkit_web_view_get_estimated_load_progress (WebKitWebView *web_view);
361
362WEBKIT_API void
363webkit_web_view_go_back (WebKitWebView *web_view);
364
365WEBKIT_API gboolean
366webkit_web_view_can_go_back (WebKitWebView *web_view);
367
368WEBKIT_API void
369webkit_web_view_go_forward (WebKitWebView *web_view);
370
371WEBKIT_API gboolean
372webkit_web_view_can_go_forward (WebKitWebView *web_view);
373
374WEBKIT_API WebKitBackForwardList *
375webkit_web_view_get_back_forward_list (WebKitWebView *web_view);
376
377WEBKIT_API void
378webkit_web_view_go_to_back_forward_list_item (WebKitWebView *web_view,
379 WebKitBackForwardListItem *list_item);
380WEBKIT_API const gchar *
381webkit_web_view_get_uri (WebKitWebView *web_view);
382
383WEBKIT_API cairo_surface_t *
384webkit_web_view_get_favicon (WebKitWebView *web_view);
385
386WEBKIT_API const gchar *
387webkit_web_view_get_custom_charset (WebKitWebView *web_view);
388
389WEBKIT_API void
390webkit_web_view_set_custom_charset (WebKitWebView *web_view,
391 const gchar *charset);
392
393WEBKIT_API void
394webkit_web_view_set_settings (WebKitWebView *web_view,
395 WebKitSettings *settings);
396
397WEBKIT_API WebKitSettings *
398webkit_web_view_get_settings (WebKitWebView *web_view);
399
400WEBKIT_API WebKitWindowProperties *
401webkit_web_view_get_window_properties (WebKitWebView *web_view);
402
403WEBKIT_API void
404webkit_web_view_set_zoom_level (WebKitWebView *web_view,
405 gdouble zoom_level);
406WEBKIT_API gdouble
407webkit_web_view_get_zoom_level (WebKitWebView *web_view);
408
409WEBKIT_API void
410webkit_web_view_can_execute_editing_command (WebKitWebView *web_view,
411 const gchar *command,
412 GCancellable *cancellable,
413 GAsyncReadyCallback callback,
414 gpointer user_data);
415
416WEBKIT_API gboolean
417webkit_web_view_can_execute_editing_command_finish (WebKitWebView *web_view,
418 GAsyncResult *result,
419 GError **error);
420
421WEBKIT_API void
422webkit_web_view_execute_editing_command (WebKitWebView *web_view,
423 const gchar *command);
424
425WEBKIT_API void
426webkit_web_view_execute_editing_command_with_argument(WebKitWebView *web_view,
427 const char *command,
428 const char *argument);
429
430WEBKIT_API WebKitFindController *
431webkit_web_view_get_find_controller (WebKitWebView *web_view);
432
433WEBKIT_DEPRECATED JSGlobalContextRef
434webkit_web_view_get_javascript_global_context (WebKitWebView *web_view);
435
436WEBKIT_API void
437webkit_web_view_run_javascript (WebKitWebView *web_view,
438 const gchar *script,
439 GCancellable *cancellable,
440 GAsyncReadyCallback callback,
441 gpointer user_data);
442WEBKIT_API WebKitJavascriptResult *
443webkit_web_view_run_javascript_finish (WebKitWebView *web_view,
444 GAsyncResult *result,
445 GError **error);
446
447WEBKIT_API void
448webkit_web_view_run_javascript_in_world (WebKitWebView *web_view,
449 const gchar *script,
450 const gchar *world_name,
451 GCancellable *cancellable,
452 GAsyncReadyCallback callback,
453 gpointer user_data);
454WEBKIT_API WebKitJavascriptResult *
455webkit_web_view_run_javascript_in_world_finish (WebKitWebView *web_view,
456 GAsyncResult *result,
457 GError **error);
458
459WEBKIT_API void
460webkit_web_view_run_javascript_from_gresource (WebKitWebView *web_view,
461 const gchar *resource,
462 GCancellable *cancellable,
463 GAsyncReadyCallback callback,
464 gpointer user_data);
465
466WEBKIT_API WebKitJavascriptResult *
467webkit_web_view_run_javascript_from_gresource_finish (WebKitWebView *web_view,
468 GAsyncResult *result,
469 GError **error);
470
471WEBKIT_API WebKitWebResource *
472webkit_web_view_get_main_resource (WebKitWebView *web_view);
473
474WEBKIT_API WebKitWebInspector *
475webkit_web_view_get_inspector (WebKitWebView *web_view);
476
477WEBKIT_API gboolean
478webkit_web_view_can_show_mime_type (WebKitWebView *web_view,
479 const gchar *mime_type);
480
481WEBKIT_API void
482webkit_web_view_save (WebKitWebView *web_view,
483 WebKitSaveMode save_mode,
484 GCancellable *cancellable,
485 GAsyncReadyCallback callback,
486 gpointer user_data);
487
488WEBKIT_API GInputStream *
489webkit_web_view_save_finish (WebKitWebView *web_view,
490 GAsyncResult *result,
491 GError **error);
492
493WEBKIT_API void
494webkit_web_view_save_to_file (WebKitWebView *web_view,
495 GFile *file,
496 WebKitSaveMode save_mode,
497 GCancellable *cancellable,
498 GAsyncReadyCallback callback,
499 gpointer user_data);
500
501WEBKIT_API gboolean
502webkit_web_view_save_to_file_finish (WebKitWebView *web_view,
503 GAsyncResult *result,
504 GError **error);
505
506WEBKIT_API WebKitDownload *
507webkit_web_view_download_uri (WebKitWebView *web_view,
508 const char *uri);
509
510WEBKIT_API gboolean
511webkit_web_view_get_tls_info (WebKitWebView *web_view,
512 GTlsCertificate **certificate,
513 GTlsCertificateFlags *errors);
514WEBKIT_API void
515webkit_web_view_get_snapshot (WebKitWebView *web_view,
516 WebKitSnapshotRegion region,
517 WebKitSnapshotOptions options,
518 GCancellable *cancellable,
519 GAsyncReadyCallback callback,
520 gpointer user_data);
521
522WEBKIT_API cairo_surface_t *
523webkit_web_view_get_snapshot_finish (WebKitWebView *web_view,
524 GAsyncResult *result,
525 GError **error);
526
527WEBKIT_API WebKitUserContentManager *
528webkit_web_view_get_user_content_manager (WebKitWebView *web_view);
529
530WEBKIT_API void
531webkit_web_view_set_background_color (WebKitWebView *web_view,
532 const GdkRGBA *rgba);
533
534WEBKIT_API void
535webkit_web_view_get_background_color (WebKitWebView *web_view,
536 GdkRGBA *rgba);
537
538WEBKIT_API gboolean
539webkit_web_view_is_editable (WebKitWebView *web_view);
540
541WEBKIT_API void
542webkit_web_view_set_editable (WebKitWebView *web_view,
543 gboolean editable);
544
545WEBKIT_API WebKitEditorState *
546webkit_web_view_get_editor_state (WebKitWebView *web_view);
547
548WEBKIT_API WebKitWebViewSessionState *
549webkit_web_view_get_session_state (WebKitWebView *web_view);
550
551WEBKIT_API void
552webkit_web_view_restore_session_state (WebKitWebView *web_view,
553 WebKitWebViewSessionState *state);
554
555G_END_DECLS
556
557#endif
558