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 * 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/WebKitBackForwardList.h> 33#include <webkit2/WebKitDefines.h> 34#include <webkit2/WebKitFileChooserRequest.h> 35#include <webkit2/WebKitFindController.h> 36#include <webkit2/WebKitFormSubmissionRequest.h> 37#include <webkit2/WebKitForwardDeclarations.h> 38#include <webkit2/WebKitHitTestResult.h> 39#include <webkit2/WebKitJavascriptResult.h> 40#include <webkit2/WebKitPermissionRequest.h> 41#include <webkit2/WebKitPolicyDecision.h> 42#include <webkit2/WebKitScriptDialog.h> 43#include <webkit2/WebKitSettings.h> 44#include <webkit2/WebKitURIRequest.h> 45#include <webkit2/WebKitWebContext.h> 46#include <webkit2/WebKitWebInspector.h> 47#include <webkit2/WebKitWebResource.h> 48#include <webkit2/WebKitWebViewBase.h> 49#include <webkit2/WebKitWebViewGroup.h> 50#include <webkit2/WebKitWindowProperties.h> 51 52G_BEGIN_DECLS 53 54#define WEBKIT_TYPE_WEB_VIEW (webkit_web_view_get_type()) 55#define WEBKIT_WEB_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_WEB_VIEW, WebKitWebView)) 56#define WEBKIT_IS_WEB_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_WEB_VIEW)) 57#define WEBKIT_WEB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_WEB_VIEW, WebKitWebViewClass)) 58#define WEBKIT_IS_WEB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_WEB_VIEW)) 59#define WEBKIT_WEB_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_WEB_VIEW, WebKitWebViewClass)) 60 61typedef struct _WebKitWebViewClass WebKitWebViewClass; 62typedef struct _WebKitWebViewPrivate WebKitWebViewPrivate; 63 64/** 65 * WebKitPolicyDecisionType: 66 * @WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION: This type of policy decision 67 * is requested when WebKit is about to navigate to a new page in either the 68 * main frame or a subframe. Acceptable policy decisions are either 69 * webkit_policy_decision_use() or webkit_policy_decision_ignore(). This 70 * type of policy decision is always a #WebKitNavigationPolicyDecision. 71 * @WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION: This type of policy decision 72 * is requested when WebKit is about to create a new window. Acceptable policy 73 * decisions are either webkit_policy_decision_use() or 74 * webkit_policy_decision_ignore(). This type of policy decision is always 75 * a #WebKitNavigationPolicyDecision. These decisions are useful for implementing 76 * special actions for new windows, such as forcing the new window to open 77 * in a tab when a keyboard modifier is active or handling a special 78 * target attribute on <a> elements. 79 * @WEBKIT_POLICY_DECISION_TYPE_RESPONSE: This type of decision is used when WebKit has 80 * received a response for a network resource and is about to start the load. 81 * Note that these resources include all subresources of a page such as images 82 * and stylesheets as well as main documents. Appropriate policy responses to 83 * this decision are webkit_policy_decision_use(), webkit_policy_decision_ignore(), 84 * or webkit_policy_decision_download(). This type of policy decision is always 85 * a #WebKitResponsePolicyDecision. This decision is useful for forcing 86 * some types of resources to be downloaded rather than rendered in the WebView 87 * or to block the transfer of resources entirely. 88 * 89 * Enum values used for determining the type of a policy decision during 90 * #WebKitWebView::decide-policy. 91 */ 92typedef enum { 93 WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION, 94 WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION, 95 WEBKIT_POLICY_DECISION_TYPE_RESPONSE, 96} WebKitPolicyDecisionType; 97 98/** 99 * WebKitLoadEvent: 100 * @WEBKIT_LOAD_STARTED: A new load request has been made. 101 * No data has been received yet, empty structures have 102 * been allocated to perform the load; the load may still 103 * fail due to transport issues such as not being able to 104 * resolve a name, or connect to a port. 105 * @WEBKIT_LOAD_REDIRECTED: A provisional data source received 106 * a server redirect. 107 * @WEBKIT_LOAD_COMMITTED: The content started arriving for a page load. 108 * The necessary transport requirements are stabilished, and the 109 * load is being performed. 110 * @WEBKIT_LOAD_FINISHED: Load completed. All resources are done loading 111 * or there was an error during the load operation. 112 * 113 * Enum values used to denote the different events that happen during a 114 * #WebKitWebView load operation. 115 */ 116typedef enum { 117 WEBKIT_LOAD_STARTED, 118 WEBKIT_LOAD_REDIRECTED, 119 WEBKIT_LOAD_COMMITTED, 120 WEBKIT_LOAD_FINISHED 121} WebKitLoadEvent; 122 123/** 124 * WebKitSaveMode: 125 * @WEBKIT_SAVE_MODE_MHTML: Save the current page using the MHTML format. 126 * 127 * Enum values to specify the different ways in which a #WebKitWebView 128 * can save its current web page into a self-contained file. 129 */ 130typedef enum { 131 WEBKIT_SAVE_MODE_MHTML 132} WebKitSaveMode; 133 134/** 135 * WebKitInsecureContentEvent: 136 * @WEBKIT_INSECURE_CONTENT_RUN: Insecure content has been detected by 137 * trying to execute any kind of logic (e.g. a script) from an 138 * untrusted source. 139 * @WEBKIT_INSECURE_CONTENT_DISPLAYED: Insecure content has been 140 * detected by trying to display any kind of resource (e.g. an image) 141 * from an untrusted source. 142 * 143 * Enum values used to denote the different events which can trigger 144 * the detection of insecure content. 145 */ 146typedef enum { 147 WEBKIT_INSECURE_CONTENT_RUN, 148 WEBKIT_INSECURE_CONTENT_DISPLAYED 149} WebKitInsecureContentEvent; 150 151/** 152 * WebKitViewMode: 153 * @WEBKIT_VIEW_MODE_WEB: The normal view mode to display web contents. 154 * @WEBKIT_VIEW_MODE_SOURCE: The source mode to display web source code. 155 * 156 * Enum values to specify the different ways in which a #WebKitWebView 157 * can display a web page. 158 */ 159typedef enum { 160 WEBKIT_VIEW_MODE_WEB, 161 WEBKIT_VIEW_MODE_SOURCE 162} WebKitViewMode; 163 164/** 165 * WebKitSnapshotOptions: 166 * @WEBKIT_SNAPSHOT_OPTIONS_NONE: Do not include any special options. 167 * @WEBKIT_SNAPSHOT_OPTIONS_INCLUDE_SELECTION_HIGHLIGHTING: Whether to include in the 168 * snapshot the highlight of the selected content. 169 * 170 * Enum values used to specify options when taking a snapshot 171 * from a #WebKitWebView. 172 */ 173typedef enum { 174 WEBKIT_SNAPSHOT_OPTIONS_NONE = 0, 175 WEBKIT_SNAPSHOT_OPTIONS_INCLUDE_SELECTION_HIGHLIGHTING = 1 << 0, 176} WebKitSnapshotOptions; 177 178/** 179 * WebKitSnapshotRegion: 180 * @WEBKIT_SNAPSHOT_REGION_VISIBLE: Specifies a snapshot only for the area that is 181 * visible in the webview 182 * @WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT: A snapshot of the entire document. 183 * 184 * Enum values used to specify the region from which to get a #WebKitWebView 185 * snapshot 186 */ 187typedef enum { 188 WEBKIT_SNAPSHOT_REGION_VISIBLE = 0, 189 WEBKIT_SNAPSHOT_REGION_FULL_DOCUMENT, 190} WebKitSnapshotRegion; 191 192struct _WebKitWebView { 193 WebKitWebViewBase parent; 194 195 /*< private >*/ 196 WebKitWebViewPrivate *priv; 197}; 198 199struct _WebKitWebViewClass { 200 WebKitWebViewBaseClass parent; 201 202 void (* load_changed) (WebKitWebView *web_view, 203 WebKitLoadEvent load_event); 204 gboolean (* load_failed) (WebKitWebView *web_view, 205 WebKitLoadEvent load_event, 206 const gchar *failing_uri, 207 GError *error); 208 209 GtkWidget *(* create) (WebKitWebView *web_view); 210 void (* ready_to_show) (WebKitWebView *web_view); 211 void (* run_as_modal) (WebKitWebView *web_view); 212 void (* close) (WebKitWebView *web_view); 213 214 gboolean (* script_dialog) (WebKitWebView *web_view, 215 WebKitScriptDialog *dialog) ; 216 217 gboolean (* decide_policy) (WebKitWebView *web_view, 218 WebKitPolicyDecision *decision, 219 WebKitPolicyDecisionType type); 220 gboolean (* permission_request) (WebKitWebView *web_view, 221 WebKitPermissionRequest *permission_request); 222 void (* mouse_target_changed) (WebKitWebView *web_view, 223 WebKitHitTestResult *hit_test_result, 224 guint modifiers); 225 gboolean (* print) (WebKitWebView *web_view, 226 WebKitPrintOperation *print_operation); 227 void (* resource_load_started) (WebKitWebView *web_view, 228 WebKitWebResource *resource, 229 WebKitURIRequest *request); 230 gboolean (* enter_fullscreen) (WebKitWebView *web_view); 231 gboolean (* leave_fullscreen) (WebKitWebView *web_view); 232 gboolean (* run_file_chooser) (WebKitWebView *web_view, 233 WebKitFileChooserRequest *request); 234 gboolean (* context_menu) (WebKitWebView *web_view, 235 WebKitContextMenu *context_menu, 236 GdkEvent *event, 237 WebKitHitTestResult *hit_test_result); 238 void (* context_menu_dismissed) (WebKitWebView *web_view); 239 void (* submit_form) (WebKitWebView *web_view, 240 WebKitFormSubmissionRequest *request); 241 void (* insecure_content_detected) (WebKitWebView *web_view, 242 WebKitInsecureContentEvent event); 243 gboolean (* web_process_crashed) (WebKitWebView *web_view); 244 245 void (*_webkit_reserved0) (void); 246 void (*_webkit_reserved1) (void); 247 void (*_webkit_reserved2) (void); 248 void (*_webkit_reserved3) (void); 249 void (*_webkit_reserved4) (void); 250 void (*_webkit_reserved5) (void); 251 void (*_webkit_reserved6) (void); 252 void (*_webkit_reserved7) (void); 253}; 254 255WEBKIT_API GType 256webkit_web_view_get_type (void); 257 258WEBKIT_API GtkWidget * 259webkit_web_view_new (void); 260 261WEBKIT_API GtkWidget * 262webkit_web_view_new_with_context (WebKitWebContext *context); 263 264WEBKIT_API GtkWidget * 265webkit_web_view_new_with_group (WebKitWebViewGroup *group); 266 267WEBKIT_API WebKitWebContext * 268webkit_web_view_get_context (WebKitWebView *web_view); 269 270WEBKIT_API WebKitWebViewGroup * 271webkit_web_view_get_group (WebKitWebView *web_view); 272 273WEBKIT_API void 274webkit_web_view_load_uri (WebKitWebView *web_view, 275 const gchar *uri); 276 277WEBKIT_API void 278webkit_web_view_load_html (WebKitWebView *web_view, 279 const gchar *content, 280 const gchar *base_uri); 281WEBKIT_API void 282webkit_web_view_load_alternate_html (WebKitWebView *web_view, 283 const gchar *content, 284 const gchar *content_uri, 285 const gchar *base_uri); 286WEBKIT_API void 287webkit_web_view_load_plain_text (WebKitWebView *web_view, 288 const gchar *plain_text); 289 290WEBKIT_API void 291webkit_web_view_load_request (WebKitWebView *web_view, 292 WebKitURIRequest *request); 293 294WEBKIT_API void 295webkit_web_view_stop_loading (WebKitWebView *web_view); 296 297WEBKIT_API gboolean 298webkit_web_view_is_loading (WebKitWebView *web_view); 299 300WEBKIT_API guint64 301webkit_web_view_get_page_id (WebKitWebView *web_view); 302 303WEBKIT_API const gchar * 304webkit_web_view_get_title (WebKitWebView *web_view); 305 306WEBKIT_API void 307webkit_web_view_reload (WebKitWebView *web_view); 308 309WEBKIT_API void 310webkit_web_view_reload_bypass_cache (WebKitWebView *web_view); 311 312WEBKIT_API gdouble 313webkit_web_view_get_estimated_load_progress (WebKitWebView *web_view); 314 315WEBKIT_API void 316webkit_web_view_go_back (WebKitWebView *web_view); 317 318WEBKIT_API gboolean 319webkit_web_view_can_go_back (WebKitWebView *web_view); 320 321WEBKIT_API void 322webkit_web_view_go_forward (WebKitWebView *web_view); 323 324WEBKIT_API gboolean 325webkit_web_view_can_go_forward (WebKitWebView *web_view); 326 327WEBKIT_API WebKitBackForwardList * 328webkit_web_view_get_back_forward_list (WebKitWebView *web_view); 329 330WEBKIT_API void 331webkit_web_view_go_to_back_forward_list_item (WebKitWebView *web_view, 332 WebKitBackForwardListItem *list_item); 333WEBKIT_API const gchar * 334webkit_web_view_get_uri (WebKitWebView *web_view); 335 336WEBKIT_API cairo_surface_t * 337webkit_web_view_get_favicon (WebKitWebView *web_view); 338 339WEBKIT_API const gchar * 340webkit_web_view_get_custom_charset (WebKitWebView *web_view); 341 342WEBKIT_API void 343webkit_web_view_set_custom_charset (WebKitWebView *web_view, 344 const gchar *charset); 345 346WEBKIT_API void 347webkit_web_view_set_settings (WebKitWebView *web_view, 348 WebKitSettings *settings); 349 350WEBKIT_API WebKitSettings * 351webkit_web_view_get_settings (WebKitWebView *web_view); 352 353WEBKIT_API WebKitWindowProperties * 354webkit_web_view_get_window_properties (WebKitWebView *web_view); 355 356WEBKIT_API void 357webkit_web_view_set_zoom_level (WebKitWebView *web_view, 358 gdouble zoom_level); 359WEBKIT_API gdouble 360webkit_web_view_get_zoom_level (WebKitWebView *web_view); 361 362WEBKIT_API void 363webkit_web_view_can_execute_editing_command (WebKitWebView *web_view, 364 const gchar *command, 365 GCancellable *cancellable, 366 GAsyncReadyCallback callback, 367 gpointer user_data); 368 369WEBKIT_API gboolean 370webkit_web_view_can_execute_editing_command_finish (WebKitWebView *web_view, 371 GAsyncResult *result, 372 GError **error); 373 374WEBKIT_API void 375webkit_web_view_execute_editing_command (WebKitWebView *web_view, 376 const gchar *command); 377 378WEBKIT_API WebKitFindController * 379webkit_web_view_get_find_controller (WebKitWebView *web_view); 380 381WEBKIT_API JSGlobalContextRef 382webkit_web_view_get_javascript_global_context (WebKitWebView *web_view); 383 384WEBKIT_API void 385webkit_web_view_run_javascript (WebKitWebView *web_view, 386 const gchar *script, 387 GCancellable *cancellable, 388 GAsyncReadyCallback callback, 389 gpointer user_data); 390WEBKIT_API WebKitJavascriptResult * 391webkit_web_view_run_javascript_finish (WebKitWebView *web_view, 392 GAsyncResult *result, 393 GError **error); 394 395WEBKIT_API void 396webkit_web_view_run_javascript_from_gresource (WebKitWebView *web_view, 397 const gchar *resource, 398 GCancellable *cancellable, 399 GAsyncReadyCallback callback, 400 gpointer user_data); 401 402WEBKIT_API WebKitJavascriptResult * 403webkit_web_view_run_javascript_from_gresource_finish (WebKitWebView *web_view, 404 GAsyncResult *result, 405 GError **error); 406 407WEBKIT_API WebKitWebResource * 408webkit_web_view_get_main_resource (WebKitWebView *web_view); 409 410WEBKIT_API WebKitWebInspector * 411webkit_web_view_get_inspector (WebKitWebView *web_view); 412 413WEBKIT_API gboolean 414webkit_web_view_can_show_mime_type (WebKitWebView *web_view, 415 const gchar *mime_type); 416 417WEBKIT_API void 418webkit_web_view_save (WebKitWebView *web_view, 419 WebKitSaveMode save_mode, 420 GCancellable *cancellable, 421 GAsyncReadyCallback callback, 422 gpointer user_data); 423 424WEBKIT_API GInputStream * 425webkit_web_view_save_finish (WebKitWebView *web_view, 426 GAsyncResult *result, 427 GError **error); 428 429WEBKIT_API void 430webkit_web_view_save_to_file (WebKitWebView *web_view, 431 GFile *file, 432 WebKitSaveMode save_mode, 433 GCancellable *cancellable, 434 GAsyncReadyCallback callback, 435 gpointer user_data); 436 437WEBKIT_API gboolean 438webkit_web_view_save_to_file_finish (WebKitWebView *web_view, 439 GAsyncResult *result, 440 GError **error); 441 442WEBKIT_API WebKitDownload * 443webkit_web_view_download_uri (WebKitWebView *web_view, 444 const char *uri); 445 446WEBKIT_API void 447webkit_web_view_set_view_mode (WebKitWebView *web_view, 448 WebKitViewMode view_mode); 449 450WEBKIT_API WebKitViewMode 451webkit_web_view_get_view_mode (WebKitWebView *web_view); 452 453WEBKIT_API gboolean 454webkit_web_view_get_tls_info (WebKitWebView *web_view, 455 GTlsCertificate **certificate, 456 GTlsCertificateFlags *errors); 457WEBKIT_API void 458webkit_web_view_get_snapshot (WebKitWebView *web_view, 459 WebKitSnapshotRegion region, 460 WebKitSnapshotOptions options, 461 GCancellable *cancellable, 462 GAsyncReadyCallback callback, 463 gpointer user_data); 464 465WEBKIT_API cairo_surface_t * 466webkit_web_view_get_snapshot_finish (WebKitWebView *web_view, 467 GAsyncResult *result, 468 GError **error); 469G_END_DECLS 470 471#endif 472