1 module webkit2.WebView; 2 3 private import cairo.Surface; 4 private import gdk.Event; 5 private import gdk.RGBA; 6 private import gio.AsyncResultIF; 7 private import gio.Cancellable; 8 private import gio.FileIF; 9 private import gio.InputStream; 10 private import gio.TlsCertificate; 11 private import glib.Bytes; 12 private import glib.ConstructionException; 13 private import glib.ErrorG; 14 private import glib.GException; 15 private import glib.MemorySlice; 16 private import glib.Str; 17 private import gobject.ObjectG; 18 private import gobject.Signals; 19 private import gtk.Widget; 20 private import std.algorithm; 21 private import webkit2.AuthenticationRequest; 22 private import webkit2.BackForwardList; 23 private import webkit2.BackForwardListItem; 24 private import webkit2.ColorChooserRequest; 25 private import webkit2.ContextMenu; 26 private import webkit2.Download; 27 private import webkit2.EditorState; 28 private import webkit2.FileChooserRequest; 29 private import webkit2.FindController; 30 private import webkit2.FormSubmissionRequest; 31 private import webkit2.HitTestResult; 32 private import webkit2.InputMethodContext; 33 private import webkit2.JavascriptResult; 34 private import webkit2.NavigationAction; 35 private import webkit2.Notification; 36 private import webkit2.OptionMenu; 37 private import webkit2.PermissionRequestIF; 38 private import webkit2.PolicyDecision; 39 private import webkit2.PrintOperation; 40 private import webkit2.ScriptDialog; 41 private import webkit2.Settings; 42 private import webkit2.URIRequest; 43 private import webkit2.UserContentManager; 44 private import webkit2.UserMessage; 45 private import webkit2.WebContext; 46 private import webkit2.WebInspector; 47 private import webkit2.WebResource; 48 private import webkit2.WebViewBase; 49 private import webkit2.WebViewSessionState; 50 private import webkit2.WebsiteDataManager; 51 private import webkit2.WebsitePolicies; 52 private import webkit2.WindowProperties; 53 private import webkit2.c.functions; 54 public import webkit2.c.types; 55 56 57 /** 58 * #WebKitWebView is the central class of the WPE WebKit and WebKitGTK 59 * APIs. It is responsible for managing the drawing of the content and 60 * forwarding of events. You can load any URI into the #WebKitWebView or 61 * a data string. With #WebKitSettings you can control various aspects 62 * of the rendering and loading of the content. 63 * 64 * Note that in WebKitGTK, #WebKitWebView is scrollable by itself, so 65 * you don't need to embed it in a #GtkScrolledWindow. 66 */ 67 public class WebView : WebViewBase 68 { 69 alias getSettings = Widget.getSettings; 70 /** the main Gtk struct */ 71 protected WebKitWebView* webKitWebView; 72 73 /** Get the main Gtk struct */ 74 public WebKitWebView* getWebViewStruct(bool transferOwnership = false) 75 { 76 if (transferOwnership) 77 ownedRef = false; 78 return webKitWebView; 79 } 80 81 /** the main Gtk struct as a void* */ 82 protected override void* getStruct() 83 { 84 return cast(void*)webKitWebView; 85 } 86 87 /** 88 * Sets our main struct and passes it to the parent class. 89 */ 90 public this (WebKitWebView* webKitWebView, bool ownedRef = false) 91 { 92 this.webKitWebView = webKitWebView; 93 super(cast(WebKitWebViewBase*)webKitWebView, ownedRef); 94 } 95 96 97 /** */ 98 public static GType getType() 99 { 100 return webkit_web_view_get_type(); 101 } 102 103 /** 104 * Creates a new #WebKitWebView with the default #WebKitWebContext and 105 * no #WebKitUserContentManager associated with it. 106 * See also webkit_web_view_new_with_context(), 107 * webkit_web_view_new_with_user_content_manager(), and 108 * webkit_web_view_new_with_settings(). 109 * 110 * Returns: The newly created #WebKitWebView widget 111 * 112 * Throws: ConstructionException GTK+ fails to create the object. 113 */ 114 public this() 115 { 116 auto __p = webkit_web_view_new(); 117 118 if(__p is null) 119 { 120 throw new ConstructionException("null returned by new"); 121 } 122 123 this(cast(WebKitWebView*) __p); 124 } 125 126 /** 127 * Creates a new #WebKitWebView with the given #WebKitWebContext and 128 * no #WebKitUserContentManager associated with it. 129 * See also webkit_web_view_new_with_user_content_manager() and 130 * webkit_web_view_new_with_settings(). 131 * 132 * Params: 133 * context = the #WebKitWebContext to be used by the #WebKitWebView 134 * 135 * Returns: The newly created #WebKitWebView widget 136 * 137 * Throws: ConstructionException GTK+ fails to create the object. 138 */ 139 public this(WebContext context) 140 { 141 auto __p = webkit_web_view_new_with_context((context is null) ? null : context.getWebContextStruct()); 142 143 if(__p is null) 144 { 145 throw new ConstructionException("null returned by new_with_context"); 146 } 147 148 this(cast(WebKitWebView*) __p); 149 } 150 151 /** 152 * Creates a new #WebKitWebView sharing the same web process with @web_view. 153 * This method doesn't have any effect when %WEBKIT_PROCESS_MODEL_SHARED_SECONDARY_PROCESS 154 * process model is used, because a single web process is shared for all the web views in the 155 * same #WebKitWebContext. When using %WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES process model, 156 * this method should always be used when creating the #WebKitWebView in the #WebKitWebView::create signal. 157 * You can also use this method to implement other process models based on %WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES, 158 * like for example, sharing the same web process for all the views in the same security domain. 159 * 160 * The newly created #WebKitWebView will also have the same #WebKitUserContentManager, 161 * #WebKitSettings, and #WebKitWebsitePolicies as @web_view. 162 * 163 * Params: 164 * webView = the related #WebKitWebView 165 * 166 * Returns: The newly created #WebKitWebView widget 167 * 168 * Since: 2.4 169 * 170 * Throws: ConstructionException GTK+ fails to create the object. 171 */ 172 public this(WebView webView) 173 { 174 auto __p = webkit_web_view_new_with_related_view((webView is null) ? null : webView.getWebViewStruct()); 175 176 if(__p is null) 177 { 178 throw new ConstructionException("null returned by new_with_related_view"); 179 } 180 181 this(cast(WebKitWebView*) __p, true); 182 } 183 184 /** 185 * Creates a new #WebKitWebView with the given #WebKitSettings. 186 * See also webkit_web_view_new_with_context(), and 187 * webkit_web_view_new_with_user_content_manager(). 188 * 189 * Params: 190 * settings = a #WebKitSettings 191 * 192 * Returns: The newly created #WebKitWebView widget 193 * 194 * Since: 2.6 195 * 196 * Throws: ConstructionException GTK+ fails to create the object. 197 */ 198 public this(Settings settings) 199 { 200 auto __p = webkit_web_view_new_with_settings((settings is null) ? null : settings.getSettingsStruct()); 201 202 if(__p is null) 203 { 204 throw new ConstructionException("null returned by new_with_settings"); 205 } 206 207 this(cast(WebKitWebView*) __p); 208 } 209 210 /** 211 * Creates a new #WebKitWebView with the given #WebKitUserContentManager. 212 * The content loaded in the view may be affected by the content injected 213 * in the view by the user content manager. 214 * 215 * Params: 216 * userContentManager = a #WebKitUserContentManager. 217 * 218 * Returns: The newly created #WebKitWebView widget 219 * 220 * Since: 2.6 221 * 222 * Throws: ConstructionException GTK+ fails to create the object. 223 */ 224 public this(UserContentManager userContentManager) 225 { 226 auto __p = webkit_web_view_new_with_user_content_manager((userContentManager is null) ? null : userContentManager.getUserContentManagerStruct()); 227 228 if(__p is null) 229 { 230 throw new ConstructionException("null returned by new_with_user_content_manager"); 231 } 232 233 this(cast(WebKitWebView*) __p); 234 } 235 236 /** 237 * Asynchronously check if it is possible to execute the given editing command. 238 * 239 * When the operation is finished, @callback will be called. You can then call 240 * webkit_web_view_can_execute_editing_command_finish() to get the result of the operation. 241 * 242 * Params: 243 * command = the command to check 244 * cancellable = a #GCancellable or %NULL to ignore 245 * callback = a #GAsyncReadyCallback to call when the request is satisfied 246 * userData = the data to pass to callback function 247 */ 248 public void canExecuteEditingCommand(string command, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 249 { 250 webkit_web_view_can_execute_editing_command(webKitWebView, Str.toStringz(command), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 251 } 252 253 /** 254 * Finish an asynchronous operation started with webkit_web_view_can_execute_editing_command(). 255 * 256 * Params: 257 * result = a #GAsyncResult 258 * 259 * Returns: %TRUE if the editing command can be executed or %FALSE otherwise 260 * 261 * Throws: GException on failure. 262 */ 263 public bool canExecuteEditingCommandFinish(AsyncResultIF result) 264 { 265 GError* err = null; 266 267 auto __p = webkit_web_view_can_execute_editing_command_finish(webKitWebView, (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 268 269 if (err !is null) 270 { 271 throw new GException( new ErrorG(err) ); 272 } 273 274 return __p; 275 } 276 277 /** 278 * Determines whether @web_view has a previous history item. 279 * 280 * Returns: %TRUE if able to move back or %FALSE otherwise. 281 */ 282 public bool canGoBack() 283 { 284 return webkit_web_view_can_go_back(webKitWebView) != 0; 285 } 286 287 /** 288 * Determines whether @web_view has a next history item. 289 * 290 * Returns: %TRUE if able to move forward or %FALSE otherwise. 291 */ 292 public bool canGoForward() 293 { 294 return webkit_web_view_can_go_forward(webKitWebView) != 0; 295 } 296 297 /** 298 * Whether or not a MIME type can be displayed in @web_view. 299 * 300 * Params: 301 * mimeType = a MIME type 302 * 303 * Returns: %TRUE if the MIME type @mime_type can be displayed or %FALSE otherwise 304 */ 305 public bool canShowMimeType(string mimeType) 306 { 307 return webkit_web_view_can_show_mime_type(webKitWebView, Str.toStringz(mimeType)) != 0; 308 } 309 310 /** 311 * Requests downloading of the specified URI string for @web_view. 312 * 313 * Params: 314 * uri = the URI to download 315 * 316 * Returns: a new #WebKitDownload representing 317 * the download operation. 318 */ 319 public Download downloadUri(string uri) 320 { 321 auto __p = webkit_web_view_download_uri(webKitWebView, Str.toStringz(uri)); 322 323 if(__p is null) 324 { 325 return null; 326 } 327 328 return ObjectG.getDObject!(Download)(cast(WebKitDownload*) __p, true); 329 } 330 331 /** 332 * Request to execute the given @command for @web_view. You can use 333 * webkit_web_view_can_execute_editing_command() to check whether 334 * it's possible to execute the command. 335 * 336 * Params: 337 * command = the command to execute 338 */ 339 public void executeEditingCommand(string command) 340 { 341 webkit_web_view_execute_editing_command(webKitWebView, Str.toStringz(command)); 342 } 343 344 /** 345 * Request to execute the given @command with @argument for @web_view. You can use 346 * webkit_web_view_can_execute_editing_command() to check whether 347 * it's possible to execute the command. 348 * 349 * Params: 350 * command = the command to execute 351 * argument = the command argument 352 * 353 * Since: 2.10 354 */ 355 public void executeEditingCommandWithArgument(string command, string argument) 356 { 357 webkit_web_view_execute_editing_command_with_argument(webKitWebView, Str.toStringz(command), Str.toStringz(argument)); 358 } 359 360 /** 361 * Get the presentation type of #WebKitWebView when created for automation. 362 * 363 * Returns: a #WebKitAutomationBrowsingContextPresentation. 364 * 365 * Since: 2.28 366 */ 367 public WebKitAutomationBrowsingContextPresentation getAutomationPresentationType() 368 { 369 return webkit_web_view_get_automation_presentation_type(webKitWebView); 370 } 371 372 /** 373 * Obtains the #WebKitBackForwardList associated with the given #WebKitWebView. The 374 * #WebKitBackForwardList is owned by the #WebKitWebView. 375 * 376 * Returns: the #WebKitBackForwardList 377 */ 378 public BackForwardList getBackForwardList() 379 { 380 auto __p = webkit_web_view_get_back_forward_list(webKitWebView); 381 382 if(__p is null) 383 { 384 return null; 385 } 386 387 return ObjectG.getDObject!(BackForwardList)(cast(WebKitBackForwardList*) __p); 388 } 389 390 /** 391 * Gets the color that is used to draw the @web_view background before 392 * the actual contents are rendered. 393 * For more information see also webkit_web_view_set_background_color() 394 * 395 * Params: 396 * rgba = a #GdkRGBA to fill in with the background color 397 * 398 * Since: 2.8 399 */ 400 public void getBackgroundColor(out RGBA rgba) 401 { 402 GdkRGBA* outrgba = sliceNew!GdkRGBA(); 403 404 webkit_web_view_get_background_color(webKitWebView, outrgba); 405 406 rgba = ObjectG.getDObject!(RGBA)(outrgba, true); 407 } 408 409 /** 410 * Gets the web context of @web_view. 411 * 412 * Returns: the #WebKitWebContext of the view 413 */ 414 public WebContext getContext() 415 { 416 auto __p = webkit_web_view_get_context(webKitWebView); 417 418 if(__p is null) 419 { 420 return null; 421 } 422 423 return ObjectG.getDObject!(WebContext)(cast(WebKitWebContext*) __p); 424 } 425 426 /** 427 * Returns the current custom character encoding name of @web_view. 428 * 429 * Returns: the current custom character encoding name or %NULL if no 430 * custom character encoding has been set. 431 */ 432 public string getCustomCharset() 433 { 434 return Str.toString(webkit_web_view_get_custom_charset(webKitWebView)); 435 } 436 437 /** 438 * Gets the web editor state of @web_view. 439 * 440 * Returns: the #WebKitEditorState of the view 441 * 442 * Since: 2.10 443 */ 444 public EditorState getEditorState() 445 { 446 auto __p = webkit_web_view_get_editor_state(webKitWebView); 447 448 if(__p is null) 449 { 450 return null; 451 } 452 453 return ObjectG.getDObject!(EditorState)(cast(WebKitEditorState*) __p); 454 } 455 456 /** 457 * Gets the value of the #WebKitWebView:estimated-load-progress property. 458 * You can monitor the estimated progress of a load operation by 459 * connecting to the notify::estimated-load-progress signal of @web_view. 460 * 461 * Returns: an estimate of the of the percent complete for a document 462 * load as a range from 0.0 to 1.0. 463 */ 464 public double getEstimatedLoadProgress() 465 { 466 return webkit_web_view_get_estimated_load_progress(webKitWebView); 467 } 468 469 /** 470 * Returns favicon currently associated to @web_view, if any. You can 471 * connect to notify::favicon signal of @web_view to be notified when 472 * the favicon is available. 473 * 474 * Returns: a pointer to a #cairo_surface_t with the 475 * favicon or %NULL if there's no icon associated with @web_view. 476 */ 477 public Surface getFavicon() 478 { 479 auto __p = webkit_web_view_get_favicon(webKitWebView); 480 481 if(__p is null) 482 { 483 return null; 484 } 485 486 return new Surface(cast(cairo_surface_t*) __p); 487 } 488 489 /** 490 * Gets the #WebKitFindController that will allow the caller to query 491 * the #WebKitWebView for the text to look for. 492 * 493 * Returns: the #WebKitFindController associated to 494 * this particular #WebKitWebView. 495 */ 496 public FindController getFindController() 497 { 498 auto __p = webkit_web_view_get_find_controller(webKitWebView); 499 500 if(__p is null) 501 { 502 return null; 503 } 504 505 return ObjectG.getDObject!(FindController)(cast(WebKitFindController*) __p); 506 } 507 508 /** 509 * Get the #WebKitInputMethodContext currently in use by @web_view, or %NULL if no input method is being used. 510 * 511 * Returns: a #WebKitInputMethodContext, or %NULL 512 * 513 * Since: 2.28 514 */ 515 public InputMethodContext getInputMethodContext() 516 { 517 auto __p = webkit_web_view_get_input_method_context(webKitWebView); 518 519 if(__p is null) 520 { 521 return null; 522 } 523 524 return ObjectG.getDObject!(InputMethodContext)(cast(WebKitInputMethodContext*) __p); 525 } 526 527 /** 528 * Get the #WebKitWebInspector associated to @web_view 529 * 530 * Returns: the #WebKitWebInspector of @web_view 531 */ 532 public WebInspector getInspector() 533 { 534 auto __p = webkit_web_view_get_inspector(webKitWebView); 535 536 if(__p is null) 537 { 538 return null; 539 } 540 541 return ObjectG.getDObject!(WebInspector)(cast(WebKitWebInspector*) __p); 542 } 543 544 /** 545 * Gets the mute state of @web_view. 546 * 547 * Returns: %TRUE if @web_view audio is muted or %FALSE is audio is not muted. 548 * 549 * Since: 2.30 550 */ 551 public bool getIsMuted() 552 { 553 return webkit_web_view_get_is_muted(webKitWebView) != 0; 554 } 555 556 /** 557 * Get the global JavaScript context used by @web_view to deserialize the 558 * result values of scripts executed with webkit_web_view_run_javascript(). 559 * 560 * Deprecated: Use jsc_value_get_context() instead. 561 * 562 * Returns: the <function>JSGlobalContextRef</function> used by @web_view to deserialize 563 * the result values of scripts. 564 */ 565 public JSGlobalContextRef getJavascriptGlobalContext() 566 { 567 return webkit_web_view_get_javascript_global_context(webKitWebView); 568 } 569 570 /** 571 * Return the main resource of @web_view. 572 * 573 * Returns: the main #WebKitWebResource of the view 574 * or %NULL if nothing has been loaded. 575 */ 576 public WebResource getMainResource() 577 { 578 auto __p = webkit_web_view_get_main_resource(webKitWebView); 579 580 if(__p is null) 581 { 582 return null; 583 } 584 585 return ObjectG.getDObject!(WebResource)(cast(WebKitWebResource*) __p); 586 } 587 588 /** 589 * Get the identifier of the #WebKitWebPage corresponding to 590 * the #WebKitWebView 591 * 592 * Returns: the page ID of @web_view. 593 */ 594 public ulong getPageId() 595 { 596 return webkit_web_view_get_page_id(webKitWebView); 597 } 598 599 /** 600 * Gets the current session state of @web_view 601 * 602 * Returns: a #WebKitWebViewSessionState 603 * 604 * Since: 2.12 605 */ 606 public WebViewSessionState getSessionState() 607 { 608 auto __p = webkit_web_view_get_session_state(webKitWebView); 609 610 if(__p is null) 611 { 612 return null; 613 } 614 615 return ObjectG.getDObject!(WebViewSessionState)(cast(WebKitWebViewSessionState*) __p, true); 616 } 617 618 /** 619 * Gets the #WebKitSettings currently applied to @web_view. 620 * If no other #WebKitSettings have been explicitly applied to 621 * @web_view with webkit_web_view_set_settings(), the default 622 * #WebKitSettings will be returned. This method always returns 623 * a valid #WebKitSettings object. 624 * To modify any of the @web_view settings, you can either create 625 * a new #WebKitSettings object with webkit_settings_new(), setting 626 * the desired preferences, and then replace the existing @web_view 627 * settings with webkit_web_view_set_settings() or get the existing 628 * @web_view settings and update it directly. #WebKitSettings objects 629 * can be shared by multiple #WebKitWebView<!-- -->s, so modifying 630 * the settings of a #WebKitWebView would affect other 631 * #WebKitWebView<!-- -->s using the same #WebKitSettings. 632 * 633 * Returns: the #WebKitSettings attached to @web_view 634 */ 635 public Settings getSettings() 636 { 637 auto __p = webkit_web_view_get_settings(webKitWebView); 638 639 if(__p is null) 640 { 641 return null; 642 } 643 644 return ObjectG.getDObject!(Settings)(cast(WebKitSettings*) __p); 645 } 646 647 /** 648 * Asynchronously retrieves a snapshot of @web_view for @region. 649 * @options specifies how the snapshot should be rendered. 650 * 651 * When the operation is finished, @callback will be called. You must 652 * call webkit_web_view_get_snapshot_finish() to get the result of the 653 * operation. 654 * 655 * Params: 656 * region = the #WebKitSnapshotRegion for this snapshot 657 * options = #WebKitSnapshotOptions for the snapshot 658 * cancellable = a #GCancellable 659 * callback = a #GAsyncReadyCallback 660 * userData = user data 661 */ 662 public void getSnapshot(WebKitSnapshotRegion region, WebKitSnapshotOptions options, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 663 { 664 webkit_web_view_get_snapshot(webKitWebView, region, options, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 665 } 666 667 /** 668 * Finishes an asynchronous operation started with webkit_web_view_get_snapshot(). 669 * 670 * Params: 671 * result = a #GAsyncResult 672 * 673 * Returns: a #cairo_surface_t with the retrieved snapshot or %NULL in error. 674 * 675 * Throws: GException on failure. 676 */ 677 public Surface getSnapshotFinish(AsyncResultIF result) 678 { 679 GError* err = null; 680 681 auto __p = webkit_web_view_get_snapshot_finish(webKitWebView, (result is null) ? null : result.getAsyncResultStruct(), &err); 682 683 if (err !is null) 684 { 685 throw new GException( new ErrorG(err) ); 686 } 687 688 if(__p is null) 689 { 690 return null; 691 } 692 693 return new Surface(cast(cairo_surface_t*) __p); 694 } 695 696 /** 697 * Gets the value of the #WebKitWebView:title property. 698 * You can connect to notify::title signal of @web_view to 699 * be notified when the title has been received. 700 * 701 * Returns: The main frame document title of @web_view. 702 */ 703 public string getTitle() 704 { 705 return Str.toString(webkit_web_view_get_title(webKitWebView)); 706 } 707 708 /** 709 * Retrieves the #GTlsCertificate associated with the main resource of @web_view, 710 * and the #GTlsCertificateFlags showing what problems, if any, have been found 711 * with that certificate. 712 * If the connection is not HTTPS, this function returns %FALSE. 713 * This function should be called after a response has been received from the 714 * server, so you can connect to #WebKitWebView::load-changed and call this function 715 * when it's emitted with %WEBKIT_LOAD_COMMITTED event. 716 * 717 * Note that this function provides no information about the security of the web 718 * page if the current #WebKitTLSErrorsPolicy is @WEBKIT_TLS_ERRORS_POLICY_IGNORE, 719 * as subresources of the page may be controlled by an attacker. This function 720 * may safely be used to determine the security status of the current page only 721 * if the current #WebKitTLSErrorsPolicy is @WEBKIT_TLS_ERRORS_POLICY_FAIL, in 722 * which case subresources that fail certificate verification will be blocked. 723 * 724 * Params: 725 * certificate = return location for a #GTlsCertificate 726 * errors = return location for a #GTlsCertificateFlags the verification status of @certificate 727 * 728 * Returns: %TRUE if the @web_view connection uses HTTPS and a response has been received 729 * from the server, or %FALSE otherwise. 730 */ 731 public bool getTlsInfo(out TlsCertificate certificate, out GTlsCertificateFlags errors) 732 { 733 GTlsCertificate* outcertificate = null; 734 735 auto __p = webkit_web_view_get_tls_info(webKitWebView, &outcertificate, &errors) != 0; 736 737 certificate = ObjectG.getDObject!(TlsCertificate)(outcertificate); 738 739 return __p; 740 } 741 742 /** 743 * Returns the current active URI of @web_view. The active URI might change during 744 * a load operation: 745 * 746 * <orderedlist> 747 * <listitem><para> 748 * When nothing has been loaded yet on @web_view the active URI is %NULL. 749 * </para></listitem> 750 * <listitem><para> 751 * When a new load operation starts the active URI is the requested URI: 752 * <itemizedlist> 753 * <listitem><para> 754 * If the load operation was started by webkit_web_view_load_uri(), 755 * the requested URI is the given one. 756 * </para></listitem> 757 * <listitem><para> 758 * If the load operation was started by webkit_web_view_load_html(), 759 * the requested URI is "about:blank". 760 * </para></listitem> 761 * <listitem><para> 762 * If the load operation was started by webkit_web_view_load_alternate_html(), 763 * the requested URI is content URI provided. 764 * </para></listitem> 765 * <listitem><para> 766 * If the load operation was started by webkit_web_view_go_back() or 767 * webkit_web_view_go_forward(), the requested URI is the original URI 768 * of the previous/next item in the #WebKitBackForwardList of @web_view. 769 * </para></listitem> 770 * <listitem><para> 771 * If the load operation was started by 772 * webkit_web_view_go_to_back_forward_list_item(), the requested URI 773 * is the opriginal URI of the given #WebKitBackForwardListItem. 774 * </para></listitem> 775 * </itemizedlist> 776 * </para></listitem> 777 * <listitem><para> 778 * If there is a server redirection during the load operation, 779 * the active URI is the redirected URI. When the signal 780 * #WebKitWebView::load-changed is emitted with %WEBKIT_LOAD_REDIRECTED 781 * event, the active URI is already updated to the redirected URI. 782 * </para></listitem> 783 * <listitem><para> 784 * When the signal #WebKitWebView::load-changed is emitted 785 * with %WEBKIT_LOAD_COMMITTED event, the active URI is the final 786 * one and it will not change unless a new load operation is started 787 * or a navigation action within the same page is performed. 788 * </para></listitem> 789 * </orderedlist> 790 * 791 * You can monitor the active URI by connecting to the notify::uri 792 * signal of @web_view. 793 * 794 * Returns: the current active URI of @web_view or %NULL 795 * if nothing has been loaded yet. 796 */ 797 public string getUri() 798 { 799 return Str.toString(webkit_web_view_get_uri(webKitWebView)); 800 } 801 802 /** 803 * Gets the user content manager associated to @web_view. 804 * 805 * Returns: the #WebKitUserContentManager associated with the view 806 * 807 * Since: 2.6 808 */ 809 public UserContentManager getUserContentManager() 810 { 811 auto __p = webkit_web_view_get_user_content_manager(webKitWebView); 812 813 if(__p is null) 814 { 815 return null; 816 } 817 818 return ObjectG.getDObject!(UserContentManager)(cast(WebKitUserContentManager*) __p); 819 } 820 821 /** 822 * Get the #WebKitWebsiteDataManager associated to @web_view. If @web_view is not ephemeral, 823 * the returned #WebKitWebsiteDataManager will be the same as the #WebKitWebsiteDataManager 824 * of @web_view's #WebKitWebContext. 825 * 826 * Returns: a #WebKitWebsiteDataManager 827 * 828 * Since: 2.16 829 */ 830 public WebsiteDataManager getWebsiteDataManager() 831 { 832 auto __p = webkit_web_view_get_website_data_manager(webKitWebView); 833 834 if(__p is null) 835 { 836 return null; 837 } 838 839 return ObjectG.getDObject!(WebsiteDataManager)(cast(WebKitWebsiteDataManager*) __p); 840 } 841 842 /** 843 * Gets the default website policies set on construction in the 844 * @web_view. These can be overridden on a per-origin basis via the 845 * #WebKitWebView::decide-policy signal handler. 846 * 847 * See also webkit_policy_decision_use_with_policies(). 848 * 849 * Returns: the default #WebKitWebsitePolicies 850 * associated with the view. 851 * 852 * Since: 2.30 853 */ 854 public WebsitePolicies getWebsitePolicies() 855 { 856 auto __p = webkit_web_view_get_website_policies(webKitWebView); 857 858 if(__p is null) 859 { 860 return null; 861 } 862 863 return ObjectG.getDObject!(WebsitePolicies)(cast(WebKitWebsitePolicies*) __p); 864 } 865 866 /** 867 * Get the #WebKitWindowProperties object containing the properties 868 * that the window containing @web_view should have. 869 * 870 * Returns: the #WebKitWindowProperties of @web_view 871 */ 872 public WindowProperties getWindowProperties() 873 { 874 auto __p = webkit_web_view_get_window_properties(webKitWebView); 875 876 if(__p is null) 877 { 878 return null; 879 } 880 881 return ObjectG.getDObject!(WindowProperties)(cast(WebKitWindowProperties*) __p); 882 } 883 884 /** 885 * Get the zoom level of @web_view, i.e. the factor by which the 886 * view contents are scaled with respect to their original size. 887 * 888 * Returns: the current zoom level of @web_view 889 */ 890 public double getZoomLevel() 891 { 892 return webkit_web_view_get_zoom_level(webKitWebView); 893 } 894 895 /** 896 * Loads the previous history item. 897 * You can monitor the load operation by connecting to 898 * #WebKitWebView::load-changed signal. 899 */ 900 public void goBack() 901 { 902 webkit_web_view_go_back(webKitWebView); 903 } 904 905 /** 906 * Loads the next history item. 907 * You can monitor the load operation by connecting to 908 * #WebKitWebView::load-changed signal. 909 */ 910 public void goForward() 911 { 912 webkit_web_view_go_forward(webKitWebView); 913 } 914 915 /** 916 * Loads the specific history item @list_item. 917 * You can monitor the load operation by connecting to 918 * #WebKitWebView::load-changed signal. 919 * 920 * Params: 921 * listItem = a #WebKitBackForwardListItem 922 */ 923 public void goToBackForwardListItem(BackForwardListItem listItem) 924 { 925 webkit_web_view_go_to_back_forward_list_item(webKitWebView, (listItem is null) ? null : listItem.getBackForwardListItemStruct()); 926 } 927 928 /** 929 * Get whether a #WebKitWebView was created with #WebKitWebView:is-controlled-by-automation 930 * property enabled. Only #WebKitWebView<!-- -->s controlled by automation can be used in an 931 * automation session. 932 * 933 * Returns: %TRUE if @web_view is controlled by automation, or %FALSE otherwise. 934 * 935 * Since: 2.18 936 */ 937 public bool isControlledByAutomation() 938 { 939 return webkit_web_view_is_controlled_by_automation(webKitWebView) != 0; 940 } 941 942 /** */ 943 public bool isEditable() 944 { 945 return webkit_web_view_is_editable(webKitWebView) != 0; 946 } 947 948 /** 949 * Get whether a #WebKitWebView is ephemeral. To create an ephemeral #WebKitWebView you need to 950 * use g_object_new() and pass is-ephemeral property with %TRUE value. See 951 * #WebKitWebView:is-ephemeral for more details. 952 * If @web_view was created with a ephemeral #WebKitWebView:related-view or an 953 * ephemeral #WebKitWebView:web-context it will also be ephemeral. 954 * 955 * Returns: %TRUE if @web_view is ephemeral or %FALSE otherwise. 956 * 957 * Since: 2.16 958 */ 959 public bool isEphemeral() 960 { 961 return webkit_web_view_is_ephemeral(webKitWebView) != 0; 962 } 963 964 /** 965 * Gets the value of the #WebKitWebView:is-loading property. 966 * You can monitor when a #WebKitWebView is loading a page by connecting to 967 * notify::is-loading signal of @web_view. This is useful when you are 968 * interesting in knowing when the view is loading something but not in the 969 * details about the status of the load operation, for example to start a spinner 970 * when the view is loading a page and stop it when it finishes. 971 * 972 * Returns: %TRUE if @web_view is loading a page or %FALSE otherwise. 973 */ 974 public bool isLoading() 975 { 976 return webkit_web_view_is_loading(webKitWebView) != 0; 977 } 978 979 /** 980 * Gets the value of the #WebKitWebView:is-playing-audio property. 981 * You can monitor when a page in a #WebKitWebView is playing audio by 982 * connecting to the notify::is-playing-audio signal of @web_view. This 983 * is useful when the application wants to provide visual feedback when a 984 * page is producing sound. 985 * 986 * Returns: %TRUE if a page in @web_view is playing audio or %FALSE otherwise. 987 * 988 * Since: 2.8 989 */ 990 public bool isPlayingAudio() 991 { 992 return webkit_web_view_is_playing_audio(webKitWebView) != 0; 993 } 994 995 /** 996 * Load the given @content string for the URI @content_uri. 997 * This allows clients to display page-loading errors in the #WebKitWebView itself. 998 * When this method is called from #WebKitWebView::load-failed signal to show an 999 * error page, then the back-forward list is maintained appropriately. 1000 * For everything else this method works the same way as webkit_web_view_load_html(). 1001 * 1002 * Params: 1003 * content = the new content to display as the main page of the @web_view 1004 * contentUri = the URI for the alternate page content 1005 * baseUri = the base URI for relative locations or %NULL 1006 */ 1007 public void loadAlternateHtml(string content, string contentUri, string baseUri) 1008 { 1009 webkit_web_view_load_alternate_html(webKitWebView, Str.toStringz(content), Str.toStringz(contentUri), Str.toStringz(baseUri)); 1010 } 1011 1012 /** 1013 * Load the specified @bytes into @web_view using the given @mime_type and @encoding. 1014 * When @mime_type is %NULL, it defaults to "text/html". 1015 * When @encoding is %NULL, it defaults to "UTF-8". 1016 * When @base_uri is %NULL, it defaults to "about:blank". 1017 * You can monitor the load operation by connecting to #WebKitWebView::load-changed signal. 1018 * 1019 * Params: 1020 * bytes = input data to load 1021 * mimeType = the MIME type of @bytes, or %NULL 1022 * encoding = the character encoding of @bytes, or %NULL 1023 * baseUri = the base URI for relative locations or %NULL 1024 * 1025 * Since: 2.6 1026 */ 1027 public void loadBytes(Bytes bytes, string mimeType, string encoding, string baseUri) 1028 { 1029 webkit_web_view_load_bytes(webKitWebView, (bytes is null) ? null : bytes.getBytesStruct(), Str.toStringz(mimeType), Str.toStringz(encoding), Str.toStringz(baseUri)); 1030 } 1031 1032 /** 1033 * Load the given @content string with the specified @base_uri. 1034 * If @base_uri is not %NULL, relative URLs in the @content will be 1035 * resolved against @base_uri and absolute local paths must be children of the @base_uri. 1036 * For security reasons absolute local paths that are not children of @base_uri 1037 * will cause the web process to terminate. 1038 * If you need to include URLs in @content that are local paths in a different 1039 * directory than @base_uri you can build a data URI for them. When @base_uri is %NULL, 1040 * it defaults to "about:blank". The mime type of the document will be "text/html". 1041 * You can monitor the load operation by connecting to #WebKitWebView::load-changed signal. 1042 * 1043 * Params: 1044 * content = The HTML string to load 1045 * baseUri = The base URI for relative locations or %NULL 1046 */ 1047 public void loadHtml(string content, string baseUri) 1048 { 1049 webkit_web_view_load_html(webKitWebView, Str.toStringz(content), Str.toStringz(baseUri)); 1050 } 1051 1052 /** 1053 * Load the specified @plain_text string into @web_view. The mime type of 1054 * document will be "text/plain". You can monitor the load 1055 * operation by connecting to #WebKitWebView::load-changed signal. 1056 * 1057 * Params: 1058 * plainText = The plain text to load 1059 */ 1060 public void loadPlainText(string plainText) 1061 { 1062 webkit_web_view_load_plain_text(webKitWebView, Str.toStringz(plainText)); 1063 } 1064 1065 /** 1066 * Requests loading of the specified #WebKitURIRequest. 1067 * You can monitor the load operation by connecting to 1068 * #WebKitWebView::load-changed signal. 1069 * 1070 * Params: 1071 * request = a #WebKitURIRequest to load 1072 */ 1073 public void loadRequest(URIRequest request) 1074 { 1075 webkit_web_view_load_request(webKitWebView, (request is null) ? null : request.getURIRequestStruct()); 1076 } 1077 1078 /** 1079 * Requests loading of the specified URI string. 1080 * You can monitor the load operation by connecting to 1081 * #WebKitWebView::load-changed signal. 1082 * 1083 * Params: 1084 * uri = an URI string 1085 */ 1086 public void loadUri(string uri) 1087 { 1088 webkit_web_view_load_uri(webKitWebView, Str.toStringz(uri)); 1089 } 1090 1091 /** 1092 * Reloads the current contents of @web_view. 1093 * See also webkit_web_view_reload_bypass_cache(). 1094 */ 1095 public void reload() 1096 { 1097 webkit_web_view_reload(webKitWebView); 1098 } 1099 1100 /** 1101 * Reloads the current contents of @web_view without 1102 * using any cached data. 1103 */ 1104 public void reloadBypassCache() 1105 { 1106 webkit_web_view_reload_bypass_cache(webKitWebView); 1107 } 1108 1109 /** 1110 * Restore the @web_view session state from @state 1111 * 1112 * Params: 1113 * state = a #WebKitWebViewSessionState 1114 * 1115 * Since: 2.12 1116 */ 1117 public void restoreSessionState(WebViewSessionState state) 1118 { 1119 webkit_web_view_restore_session_state(webKitWebView, (state is null) ? null : state.getWebViewSessionStateStruct()); 1120 } 1121 1122 /** 1123 * Asynchronously run @script in the context of the current page in @web_view. If 1124 * WebKitSettings:enable-javascript is FALSE, this method will do nothing. 1125 * 1126 * When the operation is finished, @callback will be called. You can then call 1127 * webkit_web_view_run_javascript_finish() to get the result of the operation. 1128 * 1129 * Params: 1130 * script = the script to run 1131 * cancellable = a #GCancellable or %NULL to ignore 1132 * callback = a #GAsyncReadyCallback to call when the script finished 1133 * userData = the data to pass to callback function 1134 */ 1135 public void runJavascript(string script, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1136 { 1137 webkit_web_view_run_javascript(webKitWebView, Str.toStringz(script), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1138 } 1139 1140 /** 1141 * Finish an asynchronous operation started with webkit_web_view_run_javascript(). 1142 * 1143 * This is an example of using webkit_web_view_run_javascript() with a script returning 1144 * a string: 1145 * 1146 * <informalexample><programlisting> 1147 * static void 1148 * web_view_javascript_finished (GObject *object, 1149 * GAsyncResult *result, 1150 * gpointer user_data) 1151 * { 1152 * WebKitJavascriptResult *js_result; 1153 * JSCValue *value; 1154 * GError *error = NULL; 1155 * 1156 * js_result = webkit_web_view_run_javascript_finish (WEBKIT_WEB_VIEW (object), result, &error); 1157 * if (!js_result) { 1158 * g_warning ("Error running javascript: %s", error->message); 1159 * g_error_free (error); 1160 * return; 1161 * } 1162 * 1163 * value = webkit_javascript_result_get_js_value (js_result); 1164 * if (jsc_value_is_string (value)) { 1165 * JSCException *exception; 1166 * gchar *str_value; 1167 * 1168 * str_value = jsc_value_to_string (value); 1169 * exception = jsc_context_get_exception (jsc_value_get_context (value)); 1170 * if (exception) 1171 * g_warning ("Error running javascript: %s", jsc_exception_get_message (exception)); 1172 * else 1173 * g_print ("Script result: %s\n", str_value); 1174 * g_free (str_value); 1175 * } else { 1176 * g_warning ("Error running javascript: unexpected return value"); 1177 * } 1178 * webkit_javascript_result_unref (js_result); 1179 * } 1180 * 1181 * static void 1182 * web_view_get_link_url (WebKitWebView *web_view, 1183 * const gchar *link_id) 1184 * { 1185 * gchar *script; 1186 * 1187 * script = g_strdup_printf ("window.document.getElementById('%s').href;", link_id); 1188 * webkit_web_view_run_javascript (web_view, script, NULL, web_view_javascript_finished, NULL); 1189 * g_free (script); 1190 * } 1191 * </programlisting></informalexample> 1192 * 1193 * Params: 1194 * result = a #GAsyncResult 1195 * 1196 * Returns: a #WebKitJavascriptResult with the result of the last executed statement in @script 1197 * or %NULL in case of error 1198 * 1199 * Throws: GException on failure. 1200 */ 1201 public JavascriptResult runJavascriptFinish(AsyncResultIF result) 1202 { 1203 GError* err = null; 1204 1205 auto __p = webkit_web_view_run_javascript_finish(webKitWebView, (result is null) ? null : result.getAsyncResultStruct(), &err); 1206 1207 if (err !is null) 1208 { 1209 throw new GException( new ErrorG(err) ); 1210 } 1211 1212 if(__p is null) 1213 { 1214 return null; 1215 } 1216 1217 return ObjectG.getDObject!(JavascriptResult)(cast(WebKitJavascriptResult*) __p, true); 1218 } 1219 1220 /** 1221 * Asynchronously run the script from @resource in the context of the 1222 * current page in @web_view. 1223 * 1224 * When the operation is finished, @callback will be called. You can 1225 * then call webkit_web_view_run_javascript_from_gresource_finish() to get the result 1226 * of the operation. 1227 * 1228 * Params: 1229 * resource = the location of the resource to load 1230 * cancellable = a #GCancellable or %NULL to ignore 1231 * callback = a #GAsyncReadyCallback to call when the script finished 1232 * userData = the data to pass to callback function 1233 */ 1234 public void runJavascriptFromGresource(string resource, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1235 { 1236 webkit_web_view_run_javascript_from_gresource(webKitWebView, Str.toStringz(resource), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1237 } 1238 1239 /** 1240 * Finish an asynchronous operation started with webkit_web_view_run_javascript_from_gresource(). 1241 * 1242 * Check webkit_web_view_run_javascript_finish() for a usage example. 1243 * 1244 * Params: 1245 * result = a #GAsyncResult 1246 * 1247 * Returns: a #WebKitJavascriptResult with the result of the last executed statement in @script 1248 * or %NULL in case of error 1249 * 1250 * Throws: GException on failure. 1251 */ 1252 public JavascriptResult runJavascriptFromGresourceFinish(AsyncResultIF result) 1253 { 1254 GError* err = null; 1255 1256 auto __p = webkit_web_view_run_javascript_from_gresource_finish(webKitWebView, (result is null) ? null : result.getAsyncResultStruct(), &err); 1257 1258 if (err !is null) 1259 { 1260 throw new GException( new ErrorG(err) ); 1261 } 1262 1263 if(__p is null) 1264 { 1265 return null; 1266 } 1267 1268 return ObjectG.getDObject!(JavascriptResult)(cast(WebKitJavascriptResult*) __p, true); 1269 } 1270 1271 /** 1272 * Asynchronously run @script in the script world with name @world_name of the current page context in @web_view. 1273 * If WebKitSettings:enable-javascript is FALSE, this method will do nothing. 1274 * 1275 * When the operation is finished, @callback will be called. You can then call 1276 * webkit_web_view_run_javascript_in_world_finish() to get the result of the operation. 1277 * 1278 * Params: 1279 * script = the script to run 1280 * worldName = the name of a #WebKitScriptWorld 1281 * cancellable = a #GCancellable or %NULL to ignore 1282 * callback = a #GAsyncReadyCallback to call when the script finished 1283 * userData = the data to pass to callback function 1284 * 1285 * Since: 2.22 1286 */ 1287 public void runJavascriptInWorld(string script, string worldName, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1288 { 1289 webkit_web_view_run_javascript_in_world(webKitWebView, Str.toStringz(script), Str.toStringz(worldName), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1290 } 1291 1292 /** 1293 * Finish an asynchronous operation started with webkit_web_view_run_javascript_in_world(). 1294 * 1295 * Params: 1296 * result = a #GAsyncResult 1297 * 1298 * Returns: a #WebKitJavascriptResult with the result of the last executed statement in @script 1299 * or %NULL in case of error 1300 * 1301 * Since: 2.22 1302 * 1303 * Throws: GException on failure. 1304 */ 1305 public JavascriptResult runJavascriptInWorldFinish(AsyncResultIF result) 1306 { 1307 GError* err = null; 1308 1309 auto __p = webkit_web_view_run_javascript_in_world_finish(webKitWebView, (result is null) ? null : result.getAsyncResultStruct(), &err); 1310 1311 if (err !is null) 1312 { 1313 throw new GException( new ErrorG(err) ); 1314 } 1315 1316 if(__p is null) 1317 { 1318 return null; 1319 } 1320 1321 return ObjectG.getDObject!(JavascriptResult)(cast(WebKitJavascriptResult*) __p, true); 1322 } 1323 1324 /** 1325 * Asynchronously save the current web page associated to the 1326 * #WebKitWebView into a self-contained format using the mode 1327 * specified in @save_mode. 1328 * 1329 * When the operation is finished, @callback will be called. You can 1330 * then call webkit_web_view_save_finish() to get the result of the 1331 * operation. 1332 * 1333 * Params: 1334 * saveMode = the #WebKitSaveMode specifying how the web page should be saved. 1335 * cancellable = a #GCancellable or %NULL to ignore 1336 * callback = a #GAsyncReadyCallback to call when the request is satisfied 1337 * userData = the data to pass to callback function 1338 */ 1339 public void save(WebKitSaveMode saveMode, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1340 { 1341 webkit_web_view_save(webKitWebView, saveMode, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1342 } 1343 1344 /** 1345 * Finish an asynchronous operation started with webkit_web_view_save(). 1346 * 1347 * Params: 1348 * result = a #GAsyncResult 1349 * 1350 * Returns: a #GInputStream with the result of saving 1351 * the current web page or %NULL in case of error. 1352 * 1353 * Throws: GException on failure. 1354 */ 1355 public InputStream saveFinish(AsyncResultIF result) 1356 { 1357 GError* err = null; 1358 1359 auto __p = webkit_web_view_save_finish(webKitWebView, (result is null) ? null : result.getAsyncResultStruct(), &err); 1360 1361 if (err !is null) 1362 { 1363 throw new GException( new ErrorG(err) ); 1364 } 1365 1366 if(__p is null) 1367 { 1368 return null; 1369 } 1370 1371 return ObjectG.getDObject!(InputStream)(cast(GInputStream*) __p, true); 1372 } 1373 1374 /** 1375 * Asynchronously save the current web page associated to the 1376 * #WebKitWebView into a self-contained format using the mode 1377 * specified in @save_mode and writing it to @file. 1378 * 1379 * When the operation is finished, @callback will be called. You can 1380 * then call webkit_web_view_save_to_file_finish() to get the result of the 1381 * operation. 1382 * 1383 * Params: 1384 * file = the #GFile where the current web page should be saved to. 1385 * saveMode = the #WebKitSaveMode specifying how the web page should be saved. 1386 * cancellable = a #GCancellable or %NULL to ignore 1387 * callback = a #GAsyncReadyCallback to call when the request is satisfied 1388 * userData = the data to pass to callback function 1389 */ 1390 public void saveToFile(FileIF file, WebKitSaveMode saveMode, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1391 { 1392 webkit_web_view_save_to_file(webKitWebView, (file is null) ? null : file.getFileStruct(), saveMode, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1393 } 1394 1395 /** 1396 * Finish an asynchronous operation started with webkit_web_view_save_to_file(). 1397 * 1398 * Params: 1399 * result = a #GAsyncResult 1400 * 1401 * Returns: %TRUE if the web page was successfully saved to a file or %FALSE otherwise. 1402 * 1403 * Throws: GException on failure. 1404 */ 1405 public bool saveToFileFinish(AsyncResultIF result) 1406 { 1407 GError* err = null; 1408 1409 auto __p = webkit_web_view_save_to_file_finish(webKitWebView, (result is null) ? null : result.getAsyncResultStruct(), &err) != 0; 1410 1411 if (err !is null) 1412 { 1413 throw new GException( new ErrorG(err) ); 1414 } 1415 1416 return __p; 1417 } 1418 1419 /** 1420 * Send @message to the #WebKitWebPage corresponding to @web_view. If @message is floating, it's consumed. 1421 * 1422 * If you don't expect any reply, or you simply want to ignore it, you can pass %NULL as @callback. 1423 * When the operation is finished, @callback will be called. You can then call 1424 * webkit_web_view_send_message_to_page_finish() to get the message reply. 1425 * 1426 * Params: 1427 * message = a #WebKitUserMessage 1428 * cancellable = a #GCancellable or %NULL to ignore 1429 * callback = (nullable): A #GAsyncReadyCallback to call when the request is satisfied or %NULL 1430 * userData = the data to pass to callback function 1431 * 1432 * Since: 2.28 1433 */ 1434 public void sendMessageToPage(UserMessage message, Cancellable cancellable, GAsyncReadyCallback callback, void* userData) 1435 { 1436 webkit_web_view_send_message_to_page(webKitWebView, (message is null) ? null : message.getUserMessageStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData); 1437 } 1438 1439 /** 1440 * Finish an asynchronous operation started with webkit_web_view_send_message_to_page(). 1441 * 1442 * Params: 1443 * result = a #GAsyncResult 1444 * 1445 * Returns: a #WebKitUserMessage with the reply or %NULL in case of error. 1446 * 1447 * Since: 2.28 1448 * 1449 * Throws: GException on failure. 1450 */ 1451 public UserMessage sendMessageToPageFinish(AsyncResultIF result) 1452 { 1453 GError* err = null; 1454 1455 auto __p = webkit_web_view_send_message_to_page_finish(webKitWebView, (result is null) ? null : result.getAsyncResultStruct(), &err); 1456 1457 if (err !is null) 1458 { 1459 throw new GException( new ErrorG(err) ); 1460 } 1461 1462 if(__p is null) 1463 { 1464 return null; 1465 } 1466 1467 return ObjectG.getDObject!(UserMessage)(cast(WebKitUserMessage*) __p, true); 1468 } 1469 1470 /** 1471 * Sets the color that will be used to draw the @web_view background before 1472 * the actual contents are rendered. Note that if the web page loaded in @web_view 1473 * specifies a background color, it will take precedence over the @rgba color. 1474 * By default the @web_view background color is opaque white. 1475 * Note that the parent window must have a RGBA visual and 1476 * #GtkWidget:app-paintable property set to %TRUE for backgrounds colors to work. 1477 * 1478 * <informalexample><programlisting> 1479 * static void browser_window_set_background_color (BrowserWindow *window, 1480 * const GdkRGBA *rgba) 1481 * { 1482 * WebKitWebView *web_view; 1483 * GdkScreen *screen = gtk_window_get_screen (GTK_WINDOW (window)); 1484 * GdkVisual *rgba_visual = gdk_screen_get_rgba_visual (screen); 1485 * 1486 * if (!rgba_visual) 1487 * return; 1488 * 1489 * gtk_widget_set_visual (GTK_WIDGET (window), rgba_visual); 1490 * gtk_widget_set_app_paintable (GTK_WIDGET (window), TRUE); 1491 * 1492 * web_view = browser_window_get_web_view (window); 1493 * webkit_web_view_set_background_color (web_view, rgba); 1494 * } 1495 * </programlisting></informalexample> 1496 * 1497 * Params: 1498 * rgba = a #GdkRGBA 1499 * 1500 * Since: 2.8 1501 */ 1502 public void setBackgroundColor(RGBA rgba) 1503 { 1504 webkit_web_view_set_background_color(webKitWebView, (rgba is null) ? null : rgba.getRGBAStruct()); 1505 } 1506 1507 /** 1508 * Sets the current custom character encoding override of @web_view. The custom 1509 * character encoding will override any text encoding detected via HTTP headers or 1510 * META tags. Calling this method will stop any current load operation and reload the 1511 * current page. Setting the custom character encoding to %NULL removes the character 1512 * encoding override. 1513 * 1514 * Params: 1515 * charset = a character encoding name or %NULL 1516 */ 1517 public void setCustomCharset(string charset) 1518 { 1519 webkit_web_view_set_custom_charset(webKitWebView, Str.toStringz(charset)); 1520 } 1521 1522 /** 1523 * Sets whether the user is allowed to edit the HTML document. 1524 * 1525 * If @editable is %TRUE, @web_view allows the user to edit the HTML document. If 1526 * @editable is %FALSE, an element in @web_view's document can only be edited if the 1527 * CONTENTEDITABLE attribute has been set on the element or one of its parent 1528 * elements. By default a #WebKitWebView is not editable. 1529 * 1530 * Normally, a HTML document is not editable unless the elements within the 1531 * document are editable. This function provides a way to make the contents 1532 * of a #WebKitWebView editable without altering the document or DOM structure. 1533 * 1534 * Params: 1535 * editable = a #gboolean indicating the editable state 1536 * 1537 * Since: 2.8 1538 */ 1539 public void setEditable(bool editable) 1540 { 1541 webkit_web_view_set_editable(webKitWebView, editable); 1542 } 1543 1544 /** 1545 * Set the #WebKitInputMethodContext to be used by @web_view, or %NULL to not use any input method. 1546 * Note that the same #WebKitInputMethodContext can't be set on more than one #WebKitWebView at the same time. 1547 * 1548 * Params: 1549 * context = the #WebKitInputMethodContext to set, or %NULL 1550 * 1551 * Since: 2.28 1552 */ 1553 public void setInputMethodContext(InputMethodContext context) 1554 { 1555 webkit_web_view_set_input_method_context(webKitWebView, (context is null) ? null : context.getInputMethodContextStruct()); 1556 } 1557 1558 /** 1559 * Sets the mute state of @web_view. 1560 * 1561 * Params: 1562 * muted = mute flag 1563 * 1564 * Since: 2.30 1565 */ 1566 public void setIsMuted(bool muted) 1567 { 1568 webkit_web_view_set_is_muted(webKitWebView, muted); 1569 } 1570 1571 /** 1572 * Sets the #WebKitSettings to be applied to @web_view. The 1573 * existing #WebKitSettings of @web_view will be replaced by 1574 * @settings. New settings are applied immediately on @web_view. 1575 * The same #WebKitSettings object can be shared 1576 * by multiple #WebKitWebView<!-- -->s. 1577 * 1578 * Params: 1579 * settings = a #WebKitSettings 1580 */ 1581 public void setSettings(Settings settings) 1582 { 1583 webkit_web_view_set_settings(webKitWebView, (settings is null) ? null : settings.getSettingsStruct()); 1584 } 1585 1586 /** 1587 * Set the zoom level of @web_view, i.e. the factor by which the 1588 * view contents are scaled with respect to their original size. 1589 * 1590 * Params: 1591 * zoomLevel = the zoom level 1592 */ 1593 public void setZoomLevel(double zoomLevel) 1594 { 1595 webkit_web_view_set_zoom_level(webKitWebView, zoomLevel); 1596 } 1597 1598 /** 1599 * Stops any ongoing loading operation in @web_view. 1600 * This method does nothing if no content is being loaded. 1601 * If there is a loading operation in progress, it will be cancelled and 1602 * #WebKitWebView::load-failed signal will be emitted with 1603 * %WEBKIT_NETWORK_ERROR_CANCELLED error. 1604 */ 1605 public void stopLoading() 1606 { 1607 webkit_web_view_stop_loading(webKitWebView); 1608 } 1609 1610 /** 1611 * Tries to close the @web_view. This will fire the onbeforeunload event 1612 * to ask the user for confirmation to close the page. If there isn't an 1613 * onbeforeunload event handler or the user confirms to close the page, 1614 * the #WebKitWebView::close signal is emitted, otherwise nothing happens. 1615 * 1616 * Since: 2.12 1617 */ 1618 public void tryClose() 1619 { 1620 webkit_web_view_try_close(webKitWebView); 1621 } 1622 1623 /** 1624 * This signal is emitted when the user is challenged with HTTP 1625 * authentication. To let the application access or supply 1626 * the credentials as well as to allow the client application 1627 * to either cancel the request or perform the authentication, 1628 * the signal will pass an instance of the 1629 * #WebKitAuthenticationRequest in the @request argument. 1630 * To handle this signal asynchronously you should keep a ref 1631 * of the request and return %TRUE. To disable HTTP authentication 1632 * entirely, connect to this signal and simply return %TRUE. 1633 * 1634 * The default signal handler will run a default authentication 1635 * dialog asynchronously for the user to interact with. 1636 * 1637 * Params: 1638 * request = a #WebKitAuthenticationRequest 1639 * 1640 * Returns: %TRUE to stop other handlers from being invoked for the event. 1641 * %FALSE to propagate the event further. 1642 * 1643 * Since: 2.2 1644 */ 1645 gulong addOnAuthenticate(bool delegate(AuthenticationRequest, WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1646 { 1647 return Signals.connect(this, "authenticate", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1648 } 1649 1650 /** 1651 * Emitted when closing a #WebKitWebView is requested. This occurs when a 1652 * call is made from JavaScript's <function>window.close</function> function or 1653 * after trying to close the @web_view with webkit_web_view_try_close(). 1654 * It is the owner's responsibility to handle this signal to hide or 1655 * destroy the #WebKitWebView, if necessary. 1656 */ 1657 gulong addOnClose(void delegate(WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1658 { 1659 return Signals.connect(this, "close", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1660 } 1661 1662 /** 1663 * Emitted when a context menu is about to be displayed to give the application 1664 * a chance to customize the proposed menu, prevent the menu from being displayed, 1665 * or build its own context menu. 1666 * <itemizedlist> 1667 * <listitem><para> 1668 * To customize the proposed menu you can use webkit_context_menu_prepend(), 1669 * webkit_context_menu_append() or webkit_context_menu_insert() to add new 1670 * #WebKitContextMenuItem<!-- -->s to @context_menu, webkit_context_menu_move_item() 1671 * to reorder existing items, or webkit_context_menu_remove() to remove an 1672 * existing item. The signal handler should return %FALSE, and the menu represented 1673 * by @context_menu will be shown. 1674 * </para></listitem> 1675 * <listitem><para> 1676 * To prevent the menu from being displayed you can just connect to this signal 1677 * and return %TRUE so that the proposed menu will not be shown. 1678 * </para></listitem> 1679 * <listitem><para> 1680 * To build your own menu, you can remove all items from the proposed menu with 1681 * webkit_context_menu_remove_all(), add your own items and return %FALSE so 1682 * that the menu will be shown. You can also ignore the proposed #WebKitContextMenu, 1683 * build your own #GtkMenu and return %TRUE to prevent the proposed menu from being shown. 1684 * </para></listitem> 1685 * <listitem><para> 1686 * If you just want the default menu to be shown always, simply don't connect to this 1687 * signal because showing the proposed context menu is the default behaviour. 1688 * </para></listitem> 1689 * </itemizedlist> 1690 * 1691 * The @event is expected to be one of the following types: 1692 * <itemizedlist> 1693 * <listitem><para> 1694 * a #GdkEventButton of type %GDK_BUTTON_PRESS when the context menu 1695 * was triggered with mouse. 1696 * </para></listitem> 1697 * <listitem><para> 1698 * a #GdkEventKey of type %GDK_KEY_PRESS if the keyboard was used to show 1699 * the menu. 1700 * </para></listitem> 1701 * <listitem><para> 1702 * a generic #GdkEvent of type %GDK_NOTHING when the #GtkWidget::popup-menu 1703 * signal was used to show the context menu. 1704 * </para></listitem> 1705 * </itemizedlist> 1706 * 1707 * If the signal handler returns %FALSE the context menu represented by @context_menu 1708 * will be shown, if it return %TRUE the context menu will not be shown. 1709 * 1710 * The proposed #WebKitContextMenu passed in @context_menu argument is only valid 1711 * during the signal emission. 1712 * 1713 * Params: 1714 * contextMenu = the proposed #WebKitContextMenu 1715 * event = the #GdkEvent that triggered the context menu 1716 * hitTestResult = a #WebKitHitTestResult 1717 * 1718 * Returns: %TRUE to stop other handlers from being invoked for the event. 1719 * %FALSE to propagate the event further. 1720 */ 1721 gulong addOnContextMenu(bool delegate(ContextMenu, Event, HitTestResult, WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1722 { 1723 return Signals.connect(this, "context-menu", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1724 } 1725 1726 /** 1727 * Emitted after #WebKitWebView::context-menu signal, if the context menu is shown, 1728 * to notify that the context menu is dismissed. 1729 */ 1730 gulong addOnContextMenuDismissed(void delegate(WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1731 { 1732 return Signals.connect(this, "context-menu-dismissed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1733 } 1734 1735 /** 1736 * Emitted when the creation of a new #WebKitWebView is requested. 1737 * If this signal is handled the signal handler should return the 1738 * newly created #WebKitWebView. 1739 * 1740 * The #WebKitNavigationAction parameter contains information about the 1741 * navigation action that triggered this signal. 1742 * 1743 * The new #WebKitWebView must be related to @web_view, see 1744 * webkit_web_view_new_with_related_view() for more details. 1745 * 1746 * The new #WebKitWebView should not be displayed to the user 1747 * until the #WebKitWebView::ready-to-show signal is emitted. 1748 * 1749 * Params: 1750 * navigationAction = a #WebKitNavigationAction 1751 * 1752 * Returns: a newly allocated #WebKitWebView widget 1753 * or %NULL to propagate the event further. 1754 */ 1755 gulong addOnCreate(Widget delegate(NavigationAction, WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1756 { 1757 return Signals.connect(this, "create", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1758 } 1759 1760 /** 1761 * This signal is emitted when WebKit is requesting the client to decide a policy 1762 * decision, such as whether to navigate to a page, open a new window or whether or 1763 * not to download a resource. The #WebKitNavigationPolicyDecision passed in the 1764 * @decision argument is a generic type, but should be casted to a more 1765 * specific type when making the decision. For example: 1766 * 1767 * <informalexample><programlisting> 1768 * static gboolean 1769 * decide_policy_cb (WebKitWebView *web_view, 1770 * WebKitPolicyDecision *decision, 1771 * WebKitPolicyDecisionType type) 1772 * { 1773 * switch (type) { 1774 * case WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION: { 1775 * WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision); 1776 * /<!-- -->* Make a policy decision here. *<!-- -->/ 1777 * break; 1778 * } 1779 * case WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION: { 1780 * WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision); 1781 * /<!-- -->* Make a policy decision here. *<!-- -->/ 1782 * break; 1783 * } 1784 * case WEBKIT_POLICY_DECISION_TYPE_RESPONSE: 1785 * WebKitResponsePolicyDecision *response = WEBKIT_RESPONSE_POLICY_DECISION (decision); 1786 * /<!-- -->* Make a policy decision here. *<!-- -->/ 1787 * break; 1788 * default: 1789 * /<!-- -->* Making no decision results in webkit_policy_decision_use(). *<!-- -->/ 1790 * return FALSE; 1791 * } 1792 * return TRUE; 1793 * } 1794 * </programlisting></informalexample> 1795 * 1796 * It is possible to make policy decision asynchronously, by simply calling g_object_ref() 1797 * on the @decision argument and returning %TRUE to block the default signal handler. 1798 * If the last reference is removed on a #WebKitPolicyDecision and no decision has been 1799 * made explicitly, webkit_policy_decision_use() will be the default policy decision. The 1800 * default signal handler will simply call webkit_policy_decision_use(). Only the first 1801 * policy decision chosen for a given #WebKitPolicyDecision will have any affect. 1802 * 1803 * Params: 1804 * decision = the #WebKitPolicyDecision 1805 * decisionType = a #WebKitPolicyDecisionType denoting the type of @decision 1806 * 1807 * Returns: %TRUE to stop other handlers from being invoked for the event. 1808 * %FALSE to propagate the event further. 1809 */ 1810 gulong addOnDecidePolicy(bool delegate(PolicyDecision, WebKitPolicyDecisionType, WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1811 { 1812 return Signals.connect(this, "decide-policy", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1813 } 1814 1815 /** 1816 * Emitted when JavaScript code calls 1817 * <function>element.webkitRequestFullScreen</function>. If the 1818 * signal is not handled the #WebKitWebView will proceed to full screen 1819 * its top level window. This signal can be used by client code to 1820 * request permission to the user prior doing the full screen 1821 * transition and eventually prepare the top-level window 1822 * (e.g. hide some widgets that would otherwise be part of the 1823 * full screen window). 1824 * 1825 * Returns: %TRUE to stop other handlers from being invoked for the event. 1826 * %FALSE to continue emission of the event. 1827 */ 1828 gulong addOnEnterFullscreen(bool delegate(WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1829 { 1830 return Signals.connect(this, "enter-fullscreen", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1831 } 1832 1833 /** 1834 * This signal is emitted when insecure content has been detected 1835 * in a page loaded through a secure connection. This typically 1836 * means that a external resource from an unstrusted source has 1837 * been run or displayed, resulting in a mix of HTTPS and 1838 * non-HTTPS content. 1839 * 1840 * You can check the @event parameter to know exactly which kind 1841 * of event has been detected (see #WebKitInsecureContentEvent). 1842 * 1843 * Params: 1844 * event = the #WebKitInsecureContentEvent 1845 */ 1846 gulong addOnInsecureContentDetected(void delegate(WebKitInsecureContentEvent, WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1847 { 1848 return Signals.connect(this, "insecure-content-detected", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1849 } 1850 1851 /** 1852 * Emitted when the #WebKitWebView is about to restore its top level 1853 * window out of its full screen state. This signal can be used by 1854 * client code to restore widgets hidden during the 1855 * #WebKitWebView::enter-fullscreen stage for instance. 1856 * 1857 * Returns: %TRUE to stop other handlers from being invoked for the event. 1858 * %FALSE to continue emission of the event. 1859 */ 1860 gulong addOnLeaveFullscreen(bool delegate(WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1861 { 1862 return Signals.connect(this, "leave-fullscreen", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1863 } 1864 1865 /** 1866 * Emitted when a load operation in @web_view changes. 1867 * The signal is always emitted with %WEBKIT_LOAD_STARTED when a 1868 * new load request is made and %WEBKIT_LOAD_FINISHED when the load 1869 * finishes successfully or due to an error. When the ongoing load 1870 * operation fails #WebKitWebView::load-failed signal is emitted 1871 * before #WebKitWebView::load-changed is emitted with 1872 * %WEBKIT_LOAD_FINISHED. 1873 * If a redirection is received from the server, this signal is emitted 1874 * with %WEBKIT_LOAD_REDIRECTED after the initial emission with 1875 * %WEBKIT_LOAD_STARTED and before %WEBKIT_LOAD_COMMITTED. 1876 * When the page content starts arriving the signal is emitted with 1877 * %WEBKIT_LOAD_COMMITTED event. 1878 * 1879 * You can handle this signal and use a switch to track any ongoing 1880 * load operation. 1881 * 1882 * <informalexample><programlisting> 1883 * static void web_view_load_changed (WebKitWebView *web_view, 1884 * WebKitLoadEvent load_event, 1885 * gpointer user_data) 1886 * { 1887 * switch (load_event) { 1888 * case WEBKIT_LOAD_STARTED: 1889 * /<!-- -->* New load, we have now a provisional URI *<!-- -->/ 1890 * provisional_uri = webkit_web_view_get_uri (web_view); 1891 * /<!-- -->* Here we could start a spinner or update the 1892 * <!-- -->* location bar with the provisional URI *<!-- -->/ 1893 * break; 1894 * case WEBKIT_LOAD_REDIRECTED: 1895 * redirected_uri = webkit_web_view_get_uri (web_view); 1896 * break; 1897 * case WEBKIT_LOAD_COMMITTED: 1898 * /<!-- -->* The load is being performed. Current URI is 1899 * <!-- -->* the final one and it won't change unless a new 1900 * <!-- -->* load is requested or a navigation within the 1901 * <!-- -->* same page is performed *<!-- -->/ 1902 * uri = webkit_web_view_get_uri (web_view); 1903 * break; 1904 * case WEBKIT_LOAD_FINISHED: 1905 * /<!-- -->* Load finished, we can now stop the spinner *<!-- -->/ 1906 * break; 1907 * } 1908 * } 1909 * </programlisting></informalexample> 1910 * 1911 * Params: 1912 * loadEvent = the #WebKitLoadEvent 1913 */ 1914 gulong addOnLoadChanged(void delegate(WebKitLoadEvent, WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1915 { 1916 return Signals.connect(this, "load-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1917 } 1918 1919 /** 1920 * Emitted when an error occurs during a load operation. 1921 * If the error happened when starting to load data for a page 1922 * @load_event will be %WEBKIT_LOAD_STARTED. If it happened while 1923 * loading a committed data source @load_event will be %WEBKIT_LOAD_COMMITTED. 1924 * Since a load error causes the load operation to finish, the signal 1925 * WebKitWebView::load-changed will always be emitted with 1926 * %WEBKIT_LOAD_FINISHED event right after this one. 1927 * 1928 * By default, if the signal is not handled, a stock error page will be displayed. 1929 * You need to handle the signal if you want to provide your own error page. 1930 * 1931 * Params: 1932 * loadEvent = the #WebKitLoadEvent of the load operation 1933 * failingUri = the URI that failed to load 1934 * error = the #GError that was triggered 1935 * 1936 * Returns: %TRUE to stop other handlers from being invoked for the event. 1937 * %FALSE to propagate the event further. 1938 */ 1939 gulong addOnLoadFailed(bool delegate(WebKitLoadEvent, string, ErrorG, WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1940 { 1941 return Signals.connect(this, "load-failed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1942 } 1943 1944 /** 1945 * Emitted when a TLS error occurs during a load operation. 1946 * To allow an exception for this @certificate 1947 * and the host of @failing_uri use webkit_web_context_allow_tls_certificate_for_host(). 1948 * 1949 * To handle this signal asynchronously you should call g_object_ref() on @certificate 1950 * and return %TRUE. 1951 * 1952 * If %FALSE is returned, #WebKitWebView::load-failed will be emitted. The load 1953 * will finish regardless of the returned value. 1954 * 1955 * Params: 1956 * failingUri = the URI that failed to load 1957 * certificate = a #GTlsCertificate 1958 * errors = a #GTlsCertificateFlags with the verification status of @certificate 1959 * 1960 * Returns: %TRUE to stop other handlers from being invoked for the event. 1961 * %FALSE to propagate the event further. 1962 * 1963 * Since: 2.6 1964 */ 1965 gulong addOnLoadFailedWithTlsErrors(bool delegate(string, TlsCertificate, GTlsCertificateFlags, WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1966 { 1967 return Signals.connect(this, "load-failed-with-tls-errors", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1968 } 1969 1970 /** 1971 * This signal is emitted when the mouse cursor moves over an 1972 * element such as a link, image or a media element. To determine 1973 * what type of element the mouse cursor is over, a Hit Test is performed 1974 * on the current mouse coordinates and the result is passed in the 1975 * @hit_test_result argument. The @modifiers argument is a bitmask of 1976 * #GdkModifierType flags indicating the state of modifier keys. 1977 * The signal is emitted again when the mouse is moved out of the 1978 * current element with a new @hit_test_result. 1979 * 1980 * Params: 1981 * hitTestResult = a #WebKitHitTestResult 1982 * modifiers = a bitmask of #GdkModifierType 1983 */ 1984 gulong addOnMouseTargetChanged(void delegate(HitTestResult, uint, WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 1985 { 1986 return Signals.connect(this, "mouse-target-changed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 1987 } 1988 1989 /** 1990 * This signal is emitted when WebKit is requesting the client to 1991 * decide about a permission request, such as allowing the browser 1992 * to switch to fullscreen mode, sharing its location or similar 1993 * operations. 1994 * 1995 * A possible way to use this signal could be through a dialog 1996 * allowing the user decide what to do with the request: 1997 * 1998 * <informalexample><programlisting> 1999 * static gboolean permission_request_cb (WebKitWebView *web_view, 2000 * WebKitPermissionRequest *request, 2001 * GtkWindow *parent_window) 2002 * { 2003 * GtkWidget *dialog = gtk_message_dialog_new (parent_window, 2004 * GTK_DIALOG_MODAL, 2005 * GTK_MESSAGE_QUESTION, 2006 * GTK_BUTTONS_YES_NO, 2007 * "Allow Permission Request?"); 2008 * gtk_widget_show (dialog); 2009 * gint result = gtk_dialog_run (GTK_DIALOG (dialog)); 2010 * 2011 * switch (result) { 2012 * case GTK_RESPONSE_YES: 2013 * webkit_permission_request_allow (request); 2014 * break; 2015 * default: 2016 * webkit_permission_request_deny (request); 2017 * break; 2018 * } 2019 * gtk_widget_destroy (dialog); 2020 * 2021 * return TRUE; 2022 * } 2023 * </programlisting></informalexample> 2024 * 2025 * It is possible to handle permission requests asynchronously, by 2026 * simply calling g_object_ref() on the @request argument and 2027 * returning %TRUE to block the default signal handler. If the 2028 * last reference is removed on a #WebKitPermissionRequest and the 2029 * request has not been handled, webkit_permission_request_deny() 2030 * will be the default action. 2031 * 2032 * If the signal is not handled, the @request will be completed automatically 2033 * by the specific #WebKitPermissionRequest that could allow or deny it. Check the 2034 * documentation of classes implementing #WebKitPermissionRequest interface to know 2035 * their default action. 2036 * 2037 * Params: 2038 * request = the #WebKitPermissionRequest 2039 * 2040 * Returns: %TRUE to stop other handlers from being invoked for the event. 2041 * %FALSE to propagate the event further. 2042 */ 2043 gulong addOnPermissionRequest(bool delegate(PermissionRequestIF, WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2044 { 2045 return Signals.connect(this, "permission-request", dlg, connectFlags ^ ConnectFlags.SWAPPED); 2046 } 2047 2048 /** 2049 * Emitted when printing is requested on @web_view, usually by a JavaScript call, 2050 * before the print dialog is shown. This signal can be used to set the initial 2051 * print settings and page setup of @print_operation to be used as default values in 2052 * the print dialog. You can call webkit_print_operation_set_print_settings() and 2053 * webkit_print_operation_set_page_setup() and then return %FALSE to propagate the 2054 * event so that the print dialog is shown. 2055 * 2056 * You can connect to this signal and return %TRUE to cancel the print operation 2057 * or implement your own print dialog. 2058 * 2059 * Params: 2060 * printOperation = the #WebKitPrintOperation that will handle the print request 2061 * 2062 * Returns: %TRUE to stop other handlers from being invoked for the event. 2063 * %FALSE to propagate the event further. 2064 */ 2065 gulong addOnPrint(bool delegate(PrintOperation, WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2066 { 2067 return Signals.connect(this, "print", dlg, connectFlags ^ ConnectFlags.SWAPPED); 2068 } 2069 2070 /** 2071 * Emitted after #WebKitWebView::create on the newly created #WebKitWebView 2072 * when it should be displayed to the user. When this signal is emitted 2073 * all the information about how the window should look, including 2074 * size, position, whether the location, status and scrollbars 2075 * should be displayed, is already set on the #WebKitWindowProperties 2076 * of @web_view. See also webkit_web_view_get_window_properties(). 2077 */ 2078 gulong addOnReadyToShow(void delegate(WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2079 { 2080 return Signals.connect(this, "ready-to-show", dlg, connectFlags ^ ConnectFlags.SWAPPED); 2081 } 2082 2083 /** 2084 * Emitted when a new resource is going to be loaded. The @request parameter 2085 * contains the #WebKitURIRequest that will be sent to the server. 2086 * You can monitor the load operation by connecting to the different signals 2087 * of @resource. 2088 * 2089 * Params: 2090 * resource = a #WebKitWebResource 2091 * request = a #WebKitURIRequest 2092 */ 2093 gulong addOnResourceLoadStarted(void delegate(WebResource, URIRequest, WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2094 { 2095 return Signals.connect(this, "resource-load-started", dlg, connectFlags ^ ConnectFlags.SWAPPED); 2096 } 2097 2098 /** 2099 * Emitted after #WebKitWebView::ready-to-show on the newly 2100 * created #WebKitWebView when JavaScript code calls 2101 * <function>window.showModalDialog</function>. The purpose of 2102 * this signal is to allow the client application to prepare the 2103 * new view to behave as modal. Once the signal is emitted a new 2104 * main loop will be run to block user interaction in the parent 2105 * #WebKitWebView until the new dialog is closed. 2106 */ 2107 gulong addOnRunAsModal(void delegate(WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2108 { 2109 return Signals.connect(this, "run-as-modal", dlg, connectFlags ^ ConnectFlags.SWAPPED); 2110 } 2111 2112 /** 2113 * This signal is emitted when the user interacts with a <input 2114 * type='color' /> HTML element, requesting from WebKit to show 2115 * a dialog to select a color. To let the application know the details of 2116 * the color chooser, as well as to allow the client application to either 2117 * cancel the request or perform an actual color selection, the signal will 2118 * pass an instance of the #WebKitColorChooserRequest in the @request 2119 * argument. 2120 * 2121 * It is possible to handle this request asynchronously by increasing the 2122 * reference count of the request. 2123 * 2124 * The default signal handler will asynchronously run a regular 2125 * #GtkColorChooser for the user to interact with. 2126 * 2127 * Params: 2128 * request = a #WebKitColorChooserRequest 2129 * 2130 * Returns: %TRUE to stop other handlers from being invoked for the event. 2131 * %FALSE to propagate the event further. 2132 * 2133 * Since: 2.8 2134 */ 2135 gulong addOnRunColorChooser(bool delegate(ColorChooserRequest, WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2136 { 2137 return Signals.connect(this, "run-color-chooser", dlg, connectFlags ^ ConnectFlags.SWAPPED); 2138 } 2139 2140 /** 2141 * This signal is emitted when the user interacts with a <input 2142 * type='file' /> HTML element, requesting from WebKit to show 2143 * a dialog to select one or more files to be uploaded. To let the 2144 * application know the details of the file chooser, as well as to 2145 * allow the client application to either cancel the request or 2146 * perform an actual selection of files, the signal will pass an 2147 * instance of the #WebKitFileChooserRequest in the @request 2148 * argument. 2149 * 2150 * The default signal handler will asynchronously run a regular 2151 * #GtkFileChooserDialog for the user to interact with. 2152 * 2153 * Params: 2154 * request = a #WebKitFileChooserRequest 2155 * 2156 * Returns: %TRUE to stop other handlers from being invoked for the event. 2157 * %FALSE to propagate the event further. 2158 */ 2159 gulong addOnRunFileChooser(bool delegate(FileChooserRequest, WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2160 { 2161 return Signals.connect(this, "run-file-chooser", dlg, connectFlags ^ ConnectFlags.SWAPPED); 2162 } 2163 2164 /** 2165 * Emitted when JavaScript code calls <function>window.alert</function>, 2166 * <function>window.confirm</function> or <function>window.prompt</function>, 2167 * or when <function>onbeforeunload</function> event is fired. 2168 * The @dialog parameter should be used to build the dialog. 2169 * If the signal is not handled a different dialog will be built and shown depending 2170 * on the dialog type: 2171 * <itemizedlist> 2172 * <listitem><para> 2173 * %WEBKIT_SCRIPT_DIALOG_ALERT: message dialog with a single Close button. 2174 * </para></listitem> 2175 * <listitem><para> 2176 * %WEBKIT_SCRIPT_DIALOG_CONFIRM: message dialog with OK and Cancel buttons. 2177 * </para></listitem> 2178 * <listitem><para> 2179 * %WEBKIT_SCRIPT_DIALOG_PROMPT: message dialog with OK and Cancel buttons and 2180 * a text entry with the default text. 2181 * </para></listitem> 2182 * <listitem><para> 2183 * %WEBKIT_SCRIPT_DIALOG_BEFORE_UNLOAD_CONFIRM: message dialog with Stay and Leave buttons. 2184 * </para></listitem> 2185 * </itemizedlist> 2186 * 2187 * It is possible to handle the script dialog request asynchronously, by simply 2188 * caling webkit_script_dialog_ref() on the @dialog argument and calling 2189 * webkit_script_dialog_close() when done. 2190 * If the last reference is removed on a #WebKitScriptDialog and the dialog has not been 2191 * closed, webkit_script_dialog_close() will be called. 2192 * 2193 * Params: 2194 * dialog = the #WebKitScriptDialog to show 2195 * 2196 * Returns: %TRUE to stop other handlers from being invoked for the event. 2197 * %FALSE to propagate the event further. 2198 */ 2199 gulong addOnScriptDialog(bool delegate(ScriptDialog, WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2200 { 2201 return Signals.connect(this, "script-dialog", dlg, connectFlags ^ ConnectFlags.SWAPPED); 2202 } 2203 2204 /** 2205 * This signal is emitted when a notification should be presented to the 2206 * user. The @notification is kept alive until either: 1) the web page cancels it 2207 * or 2) a navigation happens. 2208 * 2209 * The default handler will emit a notification using libnotify, if built with 2210 * support for it. 2211 * 2212 * Params: 2213 * notification = a #WebKitNotification 2214 * 2215 * Returns: %TRUE to stop other handlers from being invoked. %FALSE otherwise. 2216 * 2217 * Since: 2.8 2218 */ 2219 gulong addOnShowNotification(bool delegate(Notification, WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2220 { 2221 return Signals.connect(this, "show-notification", dlg, connectFlags ^ ConnectFlags.SWAPPED); 2222 } 2223 2224 /** 2225 * This signal is emitted when a select element in @web_view needs to display a 2226 * dropdown menu. This signal can be used to show a custom menu, using @menu to get 2227 * the details of all items that should be displayed. The area of the element in the 2228 * #WebKitWebView is given as @rectangle parameter, it can be used to position the 2229 * menu. 2230 * To handle this signal asynchronously you should keep a ref of the @menu. 2231 * 2232 * Returns: %TRUE to stop other handlers from being invoked for the event. 2233 * %FALSE to propagate the event further. 2234 * 2235 * Since: 2.28 2236 */ 2237 gulong addOnShowOptionMenu(bool delegate(OptionMenu, Event, GdkRectangle*, WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2238 { 2239 return Signals.connect(this, "show-option-menu", dlg, connectFlags ^ ConnectFlags.SWAPPED); 2240 } 2241 2242 /** 2243 * This signal is emitted when a form is about to be submitted. The @request 2244 * argument passed contains information about the text fields of the form. This 2245 * is typically used to store login information that can be used later to 2246 * pre-fill the form. 2247 * The form will not be submitted until webkit_form_submission_request_submit() is called. 2248 * 2249 * It is possible to handle the form submission request asynchronously, by 2250 * simply calling g_object_ref() on the @request argument and calling 2251 * webkit_form_submission_request_submit() when done to continue with the form submission. 2252 * If the last reference is removed on a #WebKitFormSubmissionRequest and the 2253 * form has not been submitted, webkit_form_submission_request_submit() will be called. 2254 * 2255 * Params: 2256 * request = a #WebKitFormSubmissionRequest 2257 */ 2258 gulong addOnSubmitForm(void delegate(FormSubmissionRequest, WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2259 { 2260 return Signals.connect(this, "submit-form", dlg, connectFlags ^ ConnectFlags.SWAPPED); 2261 } 2262 2263 /** 2264 * This signal is emitted when a #WebKitUserMessage is received from the 2265 * #WebKitWebPage corresponding to @web_view. You can reply to the message 2266 * using webkit_user_message_send_reply(). 2267 * 2268 * You can handle the user message asynchronously by calling g_object_ref() on 2269 * @message and returning %TRUE. If the last reference of @message is removed 2270 * and the message has not been replied to, the operation in the #WebKitWebPage will 2271 * finish with error %WEBKIT_USER_MESSAGE_UNHANDLED_MESSAGE. 2272 * 2273 * Params: 2274 * message = the #WebKitUserMessage received 2275 * 2276 * Returns: %TRUE if the message was handled, or %FALSE otherwise. 2277 * 2278 * Since: 2.28 2279 */ 2280 gulong addOnUserMessageReceived(bool delegate(UserMessage, WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2281 { 2282 return Signals.connect(this, "user-message-received", dlg, connectFlags ^ ConnectFlags.SWAPPED); 2283 } 2284 2285 /** 2286 * This signal is emitted when the web process crashes. 2287 * 2288 * Deprecated: Use WebKitWebView::web-process-terminated instead. 2289 * 2290 * Returns: %TRUE to stop other handlers from being invoked for the event. 2291 * %FALSE to propagate the event further. 2292 */ 2293 gulong addOnWebProcessCrashed(bool delegate(WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2294 { 2295 return Signals.connect(this, "web-process-crashed", dlg, connectFlags ^ ConnectFlags.SWAPPED); 2296 } 2297 2298 /** 2299 * This signal is emitted when the web process terminates abnormally due 2300 * to @reason. 2301 * 2302 * Params: 2303 * reason = the a #WebKitWebProcessTerminationReason 2304 * 2305 * Since: 2.20 2306 */ 2307 gulong addOnWebProcessTerminated(void delegate(WebKitWebProcessTerminationReason, WebView) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0) 2308 { 2309 return Signals.connect(this, "web-process-terminated", dlg, connectFlags ^ ConnectFlags.SWAPPED); 2310 } 2311 }