2 * Copyright (C) 2011 Igalia S.L.
3 * Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
4 * Copyright (C) 2014 Collabora Ltd.
5 * Copyright (C) 2017 Igalia S.L.
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
24 #include "WebKitWebView.h"
27 #include "APINavigation.h"
28 #include "APISerializedScriptValue.h"
29 #include "DataReference.h"
30 #include "ImageOptions.h"
31 #include "WebCertificateInfo.h"
32 #include "WebContextMenuItem.h"
33 #include "WebContextMenuItemData.h"
34 #include "WebKitAuthenticationRequestPrivate.h"
35 #include "WebKitBackForwardListPrivate.h"
36 #include "WebKitContextMenuClient.h"
37 #include "WebKitContextMenuItemPrivate.h"
38 #include "WebKitContextMenuPrivate.h"
39 #include "WebKitDownloadPrivate.h"
40 #include "WebKitEditingCommands.h"
41 #include "WebKitEditorStatePrivate.h"
42 #include "WebKitEnumTypes.h"
43 #include "WebKitError.h"
44 #include "WebKitFaviconDatabasePrivate.h"
45 #include "WebKitFormClient.h"
46 #include "WebKitHitTestResultPrivate.h"
47 #include "WebKitIconLoadingClient.h"
48 #include "WebKitInstallMissingMediaPluginsPermissionRequestPrivate.h"
49 #include "WebKitJavascriptResultPrivate.h"
50 #include "WebKitNavigationClient.h"
51 #include "WebKitNotificationPrivate.h"
52 #include "WebKitPrivate.h"
53 #include "WebKitResponsePolicyDecision.h"
54 #include "WebKitScriptDialogPrivate.h"
55 #include "WebKitSettingsPrivate.h"
56 #include "WebKitUIClient.h"
57 #include "WebKitURIRequestPrivate.h"
58 #include "WebKitURIResponsePrivate.h"
59 #include "WebKitWebContextPrivate.h"
60 #include "WebKitWebResourcePrivate.h"
61 #include "WebKitWebViewPrivate.h"
62 #include "WebKitWebViewSessionStatePrivate.h"
63 #include "WebKitWebsiteDataManagerPrivate.h"
64 #include "WebKitWindowPropertiesPrivate.h"
65 #include <JavaScriptCore/APICast.h>
66 #include <JavaScriptCore/JSRetainPtr.h>
67 #include <jsc/JSCContextPrivate.h>
68 #include <WebCore/CertificateInfo.h>
69 #include <WebCore/GUniquePtrSoup.h>
70 #include <WebCore/JSDOMExceptionHandling.h>
71 #include <WebCore/RefPtrCairo.h>
72 #include <WebCore/URL.h>
73 #include <glib/gi18n-lib.h>
74 #include <wtf/SetForScope.h>
75 #include <wtf/glib/GRefPtr.h>
76 #include <wtf/glib/WTFGType.h>
77 #include <wtf/text/CString.h>
78 #include <wtf/text/StringBuilder.h>
81 #include "WebKitPrintOperationPrivate.h"
82 #include "WebKitWebInspectorPrivate.h"
83 #include "WebKitWebViewBasePrivate.h"
84 #include <WebCore/GUniquePtrGtk.h>
88 #include "APIViewClient.h"
90 #include "WebKitWebViewBackendPrivate.h"
94 #include <libnotify/notify.h>
97 using namespace WebKit;
98 using namespace WebCore;
101 * SECTION: WebKitWebView
102 * @Short_description: The central class of the WebKit2GTK+ API
103 * @Title: WebKitWebView
105 * #WebKitWebView is the central class of the WebKit2GTK+ API. It is
106 * responsible for managing the drawing of the content and forwarding
107 * of events. You can load any URI into the #WebKitWebView or a data
108 * string. With #WebKitSettings you can control various aspects of the
109 * rendering and loading of the content.
111 * Note that #WebKitWebView is scrollable by itself, so you don't need
112 * to embed it in a #GtkScrolledWindow.
118 LOAD_FAILED_WITH_TLS_ERRORS,
130 MOUSE_TARGET_CHANGED,
136 RESOURCE_LOAD_STARTED,
144 CONTEXT_MENU_DISMISSED,
148 INSECURE_CONTENT_DETECTED,
153 WEB_PROCESS_TERMINATED,
178 PROP_USER_CONTENT_MANAGER,
180 PROP_ESTIMATED_LOAD_PROGRESS,
189 PROP_IS_PLAYING_AUDIO,
191 PROP_IS_CONTROLLED_BY_AUTOMATION,
195 typedef HashMap<uint64_t, GRefPtr<WebKitWebResource> > LoadingResourcesMap;
196 typedef HashMap<uint64_t, GRefPtr<GTask> > SnapshotResultsMap;
198 class PageLoadStateObserver;
200 struct _WebKitWebViewPrivate {
201 ~_WebKitWebViewPrivate()
203 // For modal dialogs, make sure the main loop is stopped when finalizing the webView.
204 if (modalLoop && g_main_loop_is_running(modalLoop.get()))
205 g_main_loop_quit(modalLoop.get());
209 GRefPtr<WebKitWebViewBackend> backend;
210 std::unique_ptr<WKWPE::View> view;
213 WebKitWebView* relatedView;
215 CString customTextEncoding;
219 bool isControlledByAutomation;
221 std::unique_ptr<PageLoadStateObserver> loadObserver;
223 GRefPtr<WebKitBackForwardList> backForwardList;
224 GRefPtr<WebKitSettings> settings;
225 GRefPtr<WebKitUserContentManager> userContentManager;
226 GRefPtr<WebKitWebContext> context;
227 GRefPtr<WebKitWindowProperties> windowProperties;
228 GRefPtr<WebKitEditorState> editorState;
230 GRefPtr<GMainLoop> modalLoop;
232 GRefPtr<WebKitHitTestResult> mouseTargetHitTestResult;
233 WebEvent::Modifiers mouseTargetModifiers;
235 GRefPtr<WebKitFindController> findController;
237 GRefPtr<WebKitWebResource> mainResource;
238 LoadingResourcesMap loadingResourcesMap;
240 WebKitScriptDialog* currentScriptDialog;
243 GRefPtr<JSCContext> jsContext;
245 GRefPtr<WebKitWebInspector> inspector;
247 RefPtr<cairo_surface_t> favicon;
248 GRefPtr<GCancellable> faviconCancellable;
251 unsigned long faviconChangedHandlerID;
253 SnapshotResultsMap snapshotResultsMap;
256 GRefPtr<WebKitAuthenticationRequest> authenticationRequest;
258 GRefPtr<WebKitWebsiteDataManager> websiteDataManager;
261 static guint signals[LAST_SIGNAL] = { 0, };
264 WEBKIT_DEFINE_TYPE(WebKitWebView, webkit_web_view, WEBKIT_TYPE_WEB_VIEW_BASE)
266 WEBKIT_DEFINE_TYPE(WebKitWebView, webkit_web_view, G_TYPE_OBJECT)
269 static inline WebPageProxy& getPage(WebKitWebView* webView)
272 auto* page = webkitWebViewBaseGetPage(reinterpret_cast<WebKitWebViewBase*>(webView));
276 ASSERT(webView->priv->view);
277 return webView->priv->view->page();
281 static void webkitWebViewSetIsLoading(WebKitWebView* webView, bool isLoading)
283 if (webView->priv->isLoading == isLoading)
286 webView->priv->isLoading = isLoading;
287 g_object_notify(G_OBJECT(webView), "is-loading");
290 void webkitWebViewIsPlayingAudioChanged(WebKitWebView* webView)
292 g_object_notify(G_OBJECT(webView), "is-playing-audio");
295 class PageLoadStateObserver final : public PageLoadState::Observer {
297 PageLoadStateObserver(WebKitWebView* webView)
303 void willChangeIsLoading() override
305 g_object_freeze_notify(G_OBJECT(m_webView));
307 void didChangeIsLoading() override
309 webkitWebViewSetIsLoading(m_webView, getPage(m_webView).pageLoadState().isLoading());
310 g_object_thaw_notify(G_OBJECT(m_webView));
313 void willChangeTitle() override
315 g_object_freeze_notify(G_OBJECT(m_webView));
317 void didChangeTitle() override
319 m_webView->priv->title = getPage(m_webView).pageLoadState().title().utf8();
320 g_object_notify(G_OBJECT(m_webView), "title");
321 g_object_thaw_notify(G_OBJECT(m_webView));
324 void willChangeActiveURL() override
326 g_object_freeze_notify(G_OBJECT(m_webView));
328 void didChangeActiveURL() override
330 m_webView->priv->activeURI = getPage(m_webView).pageLoadState().activeURL().utf8();
331 g_object_notify(G_OBJECT(m_webView), "uri");
332 g_object_thaw_notify(G_OBJECT(m_webView));
335 void willChangeHasOnlySecureContent() override { }
336 void didChangeHasOnlySecureContent() override { }
338 void willChangeEstimatedProgress() override
340 g_object_freeze_notify(G_OBJECT(m_webView));
342 void didChangeEstimatedProgress() override
344 g_object_notify(G_OBJECT(m_webView), "estimated-load-progress");
345 g_object_thaw_notify(G_OBJECT(m_webView));
348 void willChangeCanGoBack() override { }
349 void didChangeCanGoBack() override { }
350 void willChangeCanGoForward() override { }
351 void didChangeCanGoForward() override { }
352 void willChangeNetworkRequestsInProgress() override { }
353 void didChangeNetworkRequestsInProgress() override { }
354 void willChangeCertificateInfo() override { }
355 void didChangeCertificateInfo() override { }
356 void willChangeWebProcessIsResponsive() override { }
357 void didChangeWebProcessIsResponsive() override { }
359 WebKitWebView* m_webView;
363 class WebViewClient final : public API::ViewClient {
365 explicit WebViewClient(WebKitWebView* webView)
371 void handleDownloadRequest(WKWPE::View&, DownloadProxy& downloadProxy) override
373 webkitWebViewHandleDownloadRequest(m_webView, &downloadProxy);
376 WebKitWebView* m_webView;
380 static gboolean webkitWebViewLoadFail(WebKitWebView* webView, WebKitLoadEvent, const char* failingURI, GError* error)
382 if (g_error_matches(error, WEBKIT_NETWORK_ERROR, WEBKIT_NETWORK_ERROR_CANCELLED)
383 || g_error_matches(error, WEBKIT_POLICY_ERROR, WEBKIT_POLICY_ERROR_FRAME_LOAD_INTERRUPTED_BY_POLICY_CHANGE)
384 || g_error_matches(error, WEBKIT_PLUGIN_ERROR, WEBKIT_PLUGIN_ERROR_WILL_HANDLE_LOAD))
387 GUniquePtr<char> htmlString(g_strdup_printf("<html><body>%s</body></html>", error->message));
388 webkit_web_view_load_alternate_html(webView, htmlString.get(), failingURI, 0);
394 static GtkWidget* webkitWebViewCreate(WebKitWebView*, WebKitNavigationAction*)
399 static WebKitWebView* webkitWebViewCreate(WebKitWebView*, WebKitNavigationAction*)
405 static gboolean webkitWebViewDecidePolicy(WebKitWebView*, WebKitPolicyDecision* decision, WebKitPolicyDecisionType decisionType)
407 if (decisionType != WEBKIT_POLICY_DECISION_TYPE_RESPONSE) {
408 webkit_policy_decision_use(decision);
412 WebKitURIResponse* response = webkit_response_policy_decision_get_response(WEBKIT_RESPONSE_POLICY_DECISION(decision));
413 const ResourceResponse& resourceResponse = webkitURIResponseGetResourceResponse(response);
414 if (resourceResponse.isAttachment()) {
415 webkit_policy_decision_download(decision);
419 if (webkit_response_policy_decision_is_mime_type_supported(WEBKIT_RESPONSE_POLICY_DECISION(decision)))
420 webkit_policy_decision_use(decision);
422 webkit_policy_decision_ignore(decision);
427 static gboolean webkitWebViewPermissionRequest(WebKitWebView*, WebKitPermissionRequest* request)
429 webkit_permission_request_deny(request);
433 static void allowModalDialogsChanged(WebKitSettings* settings, GParamSpec*, WebKitWebView* webView)
435 getPage(webView).setCanRunModal(webkit_settings_get_allow_modal_dialogs(settings));
438 static void zoomTextOnlyChanged(WebKitSettings* settings, GParamSpec*, WebKitWebView* webView)
440 auto& page = getPage(webView);
441 gboolean zoomTextOnly = webkit_settings_get_zoom_text_only(settings);
442 gdouble pageZoomLevel = zoomTextOnly ? 1 : page.textZoomFactor();
443 gdouble textZoomLevel = zoomTextOnly ? page.pageZoomFactor() : 1;
444 page.setPageAndTextZoomFactors(pageZoomLevel, textZoomLevel);
447 static void userAgentChanged(WebKitSettings* settings, GParamSpec*, WebKitWebView* webView)
449 getPage(webView).setCustomUserAgent(String::fromUTF8(webkit_settings_get_user_agent(settings)));
453 static void webkitWebViewUpdateFavicon(WebKitWebView* webView, cairo_surface_t* favicon)
455 WebKitWebViewPrivate* priv = webView->priv;
456 if (priv->favicon.get() == favicon)
459 priv->favicon = favicon;
460 g_object_notify(G_OBJECT(webView), "favicon");
463 static void webkitWebViewCancelFaviconRequest(WebKitWebView* webView)
465 if (!webView->priv->faviconCancellable)
468 g_cancellable_cancel(webView->priv->faviconCancellable.get());
469 webView->priv->faviconCancellable = 0;
472 static void gotFaviconCallback(GObject* object, GAsyncResult* result, gpointer userData)
474 GUniqueOutPtr<GError> error;
475 RefPtr<cairo_surface_t> favicon = adoptRef(webkit_favicon_database_get_favicon_finish(WEBKIT_FAVICON_DATABASE(object), result, &error.outPtr()));
476 if (g_error_matches(error.get(), G_IO_ERROR, G_IO_ERROR_CANCELLED))
479 WebKitWebView* webView = WEBKIT_WEB_VIEW(userData);
480 webkitWebViewUpdateFavicon(webView, favicon.get());
481 webView->priv->faviconCancellable = 0;
484 static void webkitWebViewRequestFavicon(WebKitWebView* webView)
486 webkitWebViewCancelFaviconRequest(webView);
488 WebKitWebViewPrivate* priv = webView->priv;
489 priv->faviconCancellable = adoptGRef(g_cancellable_new());
490 WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(priv->context.get());
491 webkit_favicon_database_get_favicon(database, priv->activeURI.data(), priv->faviconCancellable.get(), gotFaviconCallback, webView);
494 static void webkitWebViewUpdateFaviconURI(WebKitWebView* webView, const char* faviconURI)
496 if (webView->priv->faviconURI == faviconURI)
499 webView->priv->faviconURI = faviconURI;
500 webkitWebViewRequestFavicon(webView);
503 static void faviconChangedCallback(WebKitFaviconDatabase*, const char* pageURI, const char* faviconURI, WebKitWebView* webView)
505 if (webView->priv->activeURI != pageURI)
508 webkitWebViewUpdateFaviconURI(webView, faviconURI);
512 static bool webkitWebViewIsConstructed(WebKitWebView* webView)
514 // The loadObserver is set in webkitWebViewConstructed, right after the
515 // WebPageProxy is created, so we use it to check if the view has been
516 // constructed instead of adding a boolean member only for that.
517 return !!webView->priv->loadObserver;
520 static void webkitWebViewUpdateSettings(WebKitWebView* webView)
522 // The "settings" property is set on construction, and in that
523 // case webkit_web_view_set_settings() will be called *before* the
524 // WebPageProxy has been created so we should do an early return.
525 if (!webkitWebViewIsConstructed(webView))
528 auto& page = getPage(webView);
529 WebKitSettings* settings = webView->priv->settings.get();
530 page.setPreferences(*webkitSettingsGetPreferences(settings));
531 page.setCanRunModal(webkit_settings_get_allow_modal_dialogs(settings));
532 page.setCustomUserAgent(String::fromUTF8(webkit_settings_get_user_agent(settings)));
534 g_signal_connect(settings, "notify::allow-modal-dialogs", G_CALLBACK(allowModalDialogsChanged), webView);
535 g_signal_connect(settings, "notify::zoom-text-only", G_CALLBACK(zoomTextOnlyChanged), webView);
536 g_signal_connect(settings, "notify::user-agent", G_CALLBACK(userAgentChanged), webView);
539 static void webkitWebViewDisconnectSettingsSignalHandlers(WebKitWebView* webView)
541 if (!webkitWebViewIsConstructed(webView))
544 WebKitSettings* settings = webView->priv->settings.get();
545 g_signal_handlers_disconnect_by_func(settings, reinterpret_cast<gpointer>(allowModalDialogsChanged), webView);
546 g_signal_handlers_disconnect_by_func(settings, reinterpret_cast<gpointer>(zoomTextOnlyChanged), webView);
547 g_signal_handlers_disconnect_by_func(settings, reinterpret_cast<gpointer>(userAgentChanged), webView);
551 static void webkitWebViewWatchForChangesInFavicon(WebKitWebView* webView)
553 WebKitWebViewPrivate* priv = webView->priv;
554 if (priv->faviconChangedHandlerID)
557 WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(priv->context.get());
558 priv->faviconChangedHandlerID = g_signal_connect(database, "favicon-changed", G_CALLBACK(faviconChangedCallback), webView);
561 static void webkitWebViewDisconnectFaviconDatabaseSignalHandlers(WebKitWebView* webView)
563 WebKitWebViewPrivate* priv = webView->priv;
564 if (priv->faviconChangedHandlerID)
565 g_signal_handler_disconnect(webkit_web_context_get_favicon_database(priv->context.get()), priv->faviconChangedHandlerID);
566 priv->faviconChangedHandlerID = 0;
571 static const char* gNotifyNotificationID = "wk-notify-notification";
573 static void notifyNotificationClosed(NotifyNotification*, WebKitNotification* webNotification)
575 g_object_set_data(G_OBJECT(webNotification), gNotifyNotificationID, nullptr);
576 webkit_notification_close(webNotification);
579 static void notifyNotificationClicked(NotifyNotification*, char*, WebKitNotification* webNotification)
581 webkit_notification_clicked(webNotification);
584 static void webNotificationClosed(WebKitNotification* webNotification)
586 NotifyNotification* notification = NOTIFY_NOTIFICATION(g_object_get_data(G_OBJECT(webNotification), gNotifyNotificationID));
590 notify_notification_close(notification, nullptr);
591 g_object_set_data(G_OBJECT(webNotification), gNotifyNotificationID, nullptr);
593 #endif // USE(LIBNOTIFY)
595 static gboolean webkitWebViewShowNotification(WebKitWebView*, WebKitNotification* webNotification)
598 if (!notify_is_initted())
599 notify_init(g_get_prgname());
601 NotifyNotification* notification = NOTIFY_NOTIFICATION(g_object_get_data(G_OBJECT(webNotification), gNotifyNotificationID));
603 notification = notify_notification_new(webkit_notification_get_title(webNotification),
604 webkit_notification_get_body(webNotification), nullptr);
606 notify_notification_add_action(notification, "default", _("Acknowledge"), NOTIFY_ACTION_CALLBACK(notifyNotificationClicked), webNotification, nullptr);
608 g_signal_connect_object(notification, "closed", G_CALLBACK(notifyNotificationClosed), webNotification, static_cast<GConnectFlags>(0));
609 g_signal_connect(webNotification, "closed", G_CALLBACK(webNotificationClosed), nullptr);
610 g_object_set_data_full(G_OBJECT(webNotification), gNotifyNotificationID, notification, static_cast<GDestroyNotify>(g_object_unref));
612 notify_notification_update(notification, webkit_notification_get_title(webNotification),
613 webkit_notification_get_body(webNotification), nullptr);
616 notify_notification_show(notification, nullptr);
619 UNUSED_PARAM(webNotification);
624 static void webkitWebViewConstructed(GObject* object)
626 G_OBJECT_CLASS(webkit_web_view_parent_class)->constructed(object);
628 WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
629 WebKitWebViewPrivate* priv = webView->priv;
630 if (priv->relatedView) {
631 priv->context = webkit_web_view_get_context(priv->relatedView);
632 priv->isEphemeral = webkit_web_view_is_ephemeral(priv->relatedView);
633 priv->isControlledByAutomation = webkit_web_view_is_controlled_by_automation(priv->relatedView);
634 } else if (!priv->context)
635 priv->context = webkit_web_context_get_default();
636 else if (!priv->isEphemeral)
637 priv->isEphemeral = webkit_web_context_is_ephemeral(priv->context.get());
640 priv->settings = adoptGRef(webkit_settings_new());
642 if (!priv->userContentManager)
643 priv->userContentManager = adoptGRef(webkit_user_content_manager_new());
645 if (priv->isEphemeral && !webkit_web_context_is_ephemeral(priv->context.get())) {
646 priv->websiteDataManager = adoptGRef(webkit_website_data_manager_new_ephemeral());
647 webkitWebsiteDataManagerAddProcessPool(priv->websiteDataManager.get(), webkitWebContextGetProcessPool(priv->context.get()));
650 webkitWebContextCreatePageForWebView(priv->context.get(), webView, priv->userContentManager.get(), priv->relatedView);
652 priv->loadObserver = std::make_unique<PageLoadStateObserver>(webView);
653 getPage(webView).pageLoadState().addObserver(*priv->loadObserver);
655 // The related view is only valid during the construction.
656 priv->relatedView = nullptr;
658 attachNavigationClientToView(webView);
659 attachUIClientToView(webView);
660 attachContextMenuClientToView(webView);
661 attachFormClientToView(webView);
664 attachIconLoadingClientToView(webView);
668 priv->view->setClient(std::make_unique<WebViewClient>(webView));
671 // This needs to be after attachUIClientToView() because WebPageProxy::setUIClient() calls setCanRunModal() with true.
672 // See https://bugs.webkit.org/show_bug.cgi?id=135412.
673 webkitWebViewUpdateSettings(webView);
675 priv->backForwardList = adoptGRef(webkitBackForwardListCreate(&getPage(webView).backForwardList()));
676 priv->windowProperties = adoptGRef(webkitWindowPropertiesCreate());
679 static void webkitWebViewSetProperty(GObject* object, guint propId, const GValue* value, GParamSpec* paramSpec)
681 WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
686 gpointer backend = g_value_get_boxed(value);
687 webView->priv->backend = backend ? adoptGRef(static_cast<WebKitWebViewBackend*>(backend)) : nullptr;
691 case PROP_WEB_CONTEXT: {
692 gpointer webContext = g_value_get_object(value);
693 webView->priv->context = webContext ? WEBKIT_WEB_CONTEXT(webContext) : nullptr;
696 case PROP_RELATED_VIEW: {
697 gpointer relatedView = g_value_get_object(value);
698 webView->priv->relatedView = relatedView ? WEBKIT_WEB_VIEW(relatedView) : nullptr;
701 case PROP_SETTINGS: {
702 if (gpointer settings = g_value_get_object(value))
703 webkit_web_view_set_settings(webView, WEBKIT_SETTINGS(settings));
706 case PROP_USER_CONTENT_MANAGER: {
707 gpointer userContentManager = g_value_get_object(value);
708 webView->priv->userContentManager = userContentManager ? WEBKIT_USER_CONTENT_MANAGER(userContentManager) : nullptr;
711 case PROP_ZOOM_LEVEL:
712 webkit_web_view_set_zoom_level(webView, g_value_get_double(value));
714 case PROP_IS_EPHEMERAL:
715 webView->priv->isEphemeral = g_value_get_boolean(value);
717 case PROP_IS_CONTROLLED_BY_AUTOMATION:
718 webView->priv->isControlledByAutomation = g_value_get_boolean(value);
721 webkit_web_view_set_editable(webView, g_value_get_boolean(value));
724 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
728 static void webkitWebViewGetProperty(GObject* object, guint propId, GValue* value, GParamSpec* paramSpec)
730 WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
735 g_value_set_static_boxed(value, webView->priv->backend.get());
738 case PROP_WEB_CONTEXT:
739 g_value_set_object(value, webView->priv->context.get());
742 g_value_set_object(value, webkit_web_view_get_settings(webView));
744 case PROP_USER_CONTENT_MANAGER:
745 g_value_set_object(value, webkit_web_view_get_user_content_manager(webView));
748 g_value_set_string(value, webView->priv->title.data());
750 case PROP_ESTIMATED_LOAD_PROGRESS:
751 g_value_set_double(value, webkit_web_view_get_estimated_load_progress(webView));
755 g_value_set_pointer(value, webkit_web_view_get_favicon(webView));
759 g_value_set_string(value, webkit_web_view_get_uri(webView));
761 case PROP_ZOOM_LEVEL:
762 g_value_set_double(value, webkit_web_view_get_zoom_level(webView));
764 case PROP_IS_LOADING:
765 g_value_set_boolean(value, webkit_web_view_is_loading(webView));
767 case PROP_IS_PLAYING_AUDIO:
768 g_value_set_boolean(value, webkit_web_view_is_playing_audio(webView));
770 case PROP_IS_EPHEMERAL:
771 g_value_set_boolean(value, webkit_web_view_is_ephemeral(webView));
773 case PROP_IS_CONTROLLED_BY_AUTOMATION:
774 g_value_set_boolean(value, webkit_web_view_is_controlled_by_automation(webView));
777 g_value_set_boolean(value, webkit_web_view_is_editable(webView));
780 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
784 static void webkitWebViewDispose(GObject* object)
786 WebKitWebView* webView = WEBKIT_WEB_VIEW(object);
789 webkitWebViewCancelFaviconRequest(webView);
790 webkitWebViewDisconnectFaviconDatabaseSignalHandlers(webView);
793 webkitWebViewDisconnectSettingsSignalHandlers(webView);
795 if (webView->priv->loadObserver) {
796 getPage(webView).pageLoadState().removeObserver(*webView->priv->loadObserver);
797 webView->priv->loadObserver.reset();
799 // We notify the context here to ensure it's called only once. Ideally we should
800 // call this in finalize, not dispose, but finalize is used internally and we don't
801 // have access to the instance pointer from the private struct destructor.
802 webkitWebContextWebViewDestroyed(webView->priv->context.get(), webView);
805 if (webView->priv->websiteDataManager) {
806 webkitWebsiteDataManagerRemoveProcessPool(webView->priv->websiteDataManager.get(), webkitWebContextGetProcessPool(webView->priv->context.get()));
807 webView->priv->websiteDataManager = nullptr;
811 webView->priv->view->close();
814 G_OBJECT_CLASS(webkit_web_view_parent_class)->dispose(object);
817 static gboolean webkitWebViewAccumulatorObjectHandled(GSignalInvocationHint*, GValue* returnValue, const GValue* handlerReturn, gpointer)
819 void* object = g_value_get_object(handlerReturn);
821 g_value_set_object(returnValue, object);
826 static void webkit_web_view_class_init(WebKitWebViewClass* webViewClass)
828 GObjectClass* gObjectClass = G_OBJECT_CLASS(webViewClass);
830 gObjectClass->constructed = webkitWebViewConstructed;
831 gObjectClass->set_property = webkitWebViewSetProperty;
832 gObjectClass->get_property = webkitWebViewGetProperty;
833 gObjectClass->dispose = webkitWebViewDispose;
835 webViewClass->load_failed = webkitWebViewLoadFail;
836 webViewClass->create = webkitWebViewCreate;
837 webViewClass->script_dialog = webkitWebViewScriptDialog;
838 webViewClass->decide_policy = webkitWebViewDecidePolicy;
839 webViewClass->permission_request = webkitWebViewPermissionRequest;
840 webViewClass->run_file_chooser = webkitWebViewRunFileChooser;
841 webViewClass->authenticate = webkitWebViewAuthenticate;
842 webViewClass->show_notification = webkitWebViewShowNotification;
846 * WebKitWebView:backend:
848 * The #WebKitWebViewBackend of the view.
852 g_object_class_install_property(
858 _("The backend for the web view"),
859 WEBKIT_TYPE_WEB_VIEW_BACKEND,
860 static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
864 * WebKitWebView:web-context:
866 * The #WebKitWebContext of the view.
868 g_object_class_install_property(gObjectClass,
870 g_param_spec_object("web-context",
872 _("The web context for the view"),
873 WEBKIT_TYPE_WEB_CONTEXT,
874 static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
876 * WebKitWebView:related-view:
878 * The related #WebKitWebView used when creating the view to share the
879 * same web process. This property is not readable because the related
880 * web view is only valid during the object construction.
884 g_object_class_install_property(
889 _("Related WebView"),
890 _("The related WebKitWebView used when creating the view to share the same web process"),
891 WEBKIT_TYPE_WEB_VIEW,
892 static_cast<GParamFlags>(WEBKIT_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)));
895 * WebKitWebView:settings:
897 * The #WebKitSettings of the view.
901 g_object_class_install_property(
906 _("WebView settings"),
907 _("The WebKitSettings of the view"),
908 WEBKIT_TYPE_SETTINGS,
909 static_cast<GParamFlags>(WEBKIT_PARAM_WRITABLE | G_PARAM_CONSTRUCT)));
912 * WebKitWebView:user-content-manager:
914 * The #WebKitUserContentManager of the view.
918 g_object_class_install_property(
920 PROP_USER_CONTENT_MANAGER,
922 "user-content-manager",
923 _("WebView user content manager"),
924 _("The WebKitUserContentManager of the view"),
925 WEBKIT_TYPE_USER_CONTENT_MANAGER,
926 static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
929 * WebKitWebView:title:
931 * The main frame document title of this #WebKitWebView. If
932 * the title has not been received yet, it will be %NULL.
934 g_object_class_install_property(gObjectClass,
936 g_param_spec_string("title",
938 _("Main frame document title"),
940 WEBKIT_PARAM_READABLE));
943 * WebKitWebView:estimated-load-progress:
945 * An estimate of the percent completion for the current loading operation.
946 * This value will range from 0.0 to 1.0 and, once a load completes,
947 * will remain at 1.0 until a new load starts, at which point it
948 * will be reset to 0.0.
949 * The value is an estimate based on the total number of bytes expected
950 * to be received for a document, including all its possible subresources
951 * and child documents.
953 g_object_class_install_property(gObjectClass,
954 PROP_ESTIMATED_LOAD_PROGRESS,
955 g_param_spec_double("estimated-load-progress",
956 _("Estimated Load Progress"),
957 _("An estimate of the percent completion for a document load"),
959 WEBKIT_PARAM_READABLE));
962 * WebKitWebView:favicon:
964 * The favicon currently associated to the #WebKitWebView.
965 * See webkit_web_view_get_favicon() for more details.
967 g_object_class_install_property(gObjectClass,
969 g_param_spec_pointer("favicon",
971 _("The favicon associated to the view, if any"),
972 WEBKIT_PARAM_READABLE));
978 * The current active URI of the #WebKitWebView.
979 * See webkit_web_view_get_uri() for more details.
981 g_object_class_install_property(gObjectClass,
983 g_param_spec_string("uri",
985 _("The current active URI of the view"),
987 WEBKIT_PARAM_READABLE));
990 * WebKitWebView:zoom-level:
992 * The zoom level of the #WebKitWebView content.
993 * See webkit_web_view_set_zoom_level() for more details.
995 g_object_class_install_property(
1001 _("The zoom level of the view content"),
1003 WEBKIT_PARAM_READWRITE));
1006 * WebKitWebView:is-loading:
1008 * Whether the #WebKitWebView is currently loading a page. This property becomes
1009 * %TRUE as soon as a new load operation is requested and before the
1010 * #WebKitWebView::load-changed signal is emitted with %WEBKIT_LOAD_STARTED and
1011 * at that point the active URI is the requested one.
1012 * When the load operation finishes the property is set to %FALSE before
1013 * #WebKitWebView::load-changed is emitted with %WEBKIT_LOAD_FINISHED.
1015 g_object_class_install_property(
1018 g_param_spec_boolean(
1021 _("Whether the view is loading a page"),
1023 WEBKIT_PARAM_READABLE));
1026 * WebKitWebView:is-playing-audio:
1028 * Whether the #WebKitWebView is currently playing audio from a page.
1029 * This property becomes %TRUE as soon as web content starts playing any
1030 * kind of audio. When a page is no longer playing any kind of sound,
1031 * the property is set back to %FALSE.
1035 g_object_class_install_property(
1037 PROP_IS_PLAYING_AUDIO,
1038 g_param_spec_boolean(
1041 _("Whether the view is playing audio"),
1043 WEBKIT_PARAM_READABLE));
1046 * WebKitWebView:is-ephemeral:
1048 * Whether the #WebKitWebView is ephemeral. An ephemeral web view never writes
1049 * website data to the client storage, no matter what #WebKitWebsiteDataManager
1050 * its context is using. This is normally used to implement private browsing mode.
1051 * This is a %G_PARAM_CONSTRUCT_ONLY property, so you have to create a ephemeral
1052 * #WebKitWebView and it can't be changed. Note that all #WebKitWebView<!-- -->s
1053 * created with an ephemeral #WebKitWebContext will be ephemeral automatically.
1054 * See also webkit_web_context_new_ephemeral().
1058 g_object_class_install_property(
1061 g_param_spec_boolean(
1064 _("Whether the web view is ephemeral"),
1066 static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
1069 * WebKitWebView:is-controlled-by-automation:
1071 * Whether the #WebKitWebView is controlled by automation. This should only be used when
1072 * creating a new #WebKitWebView as a response to #WebKitAutomationSession::create-web-view
1077 g_object_class_install_property(
1079 PROP_IS_CONTROLLED_BY_AUTOMATION,
1080 g_param_spec_boolean(
1081 "is-controlled-by-automation",
1082 "Is Controlled By Automation",
1083 _("Whether the web view is controlled by automation"),
1085 static_cast<GParamFlags>(WEBKIT_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)));
1088 * WebKitWebView:editable:
1090 * Whether the pages loaded inside #WebKitWebView are editable. For more
1091 * information see webkit_web_view_set_editable().
1095 g_object_class_install_property(
1098 g_param_spec_boolean(
1101 _("Whether the content can be modified by the user."),
1103 WEBKIT_PARAM_READWRITE));
1106 * WebKitWebView::load-changed:
1107 * @web_view: the #WebKitWebView on which the signal is emitted
1108 * @load_event: the #WebKitLoadEvent
1110 * Emitted when a load operation in @web_view changes.
1111 * The signal is always emitted with %WEBKIT_LOAD_STARTED when a
1112 * new load request is made and %WEBKIT_LOAD_FINISHED when the load
1113 * finishes successfully or due to an error. When the ongoing load
1114 * operation fails #WebKitWebView::load-failed signal is emitted
1115 * before #WebKitWebView::load-changed is emitted with
1116 * %WEBKIT_LOAD_FINISHED.
1117 * If a redirection is received from the server, this signal is emitted
1118 * with %WEBKIT_LOAD_REDIRECTED after the initial emission with
1119 * %WEBKIT_LOAD_STARTED and before %WEBKIT_LOAD_COMMITTED.
1120 * When the page content starts arriving the signal is emitted with
1121 * %WEBKIT_LOAD_COMMITTED event.
1123 * You can handle this signal and use a switch to track any ongoing
1126 * <informalexample><programlisting>
1127 * static void web_view_load_changed (WebKitWebView *web_view,
1128 * WebKitLoadEvent load_event,
1129 * gpointer user_data)
1131 * switch (load_event) {
1132 * case WEBKIT_LOAD_STARTED:
1133 * /<!-- -->* New load, we have now a provisional URI *<!-- -->/
1134 * provisional_uri = webkit_web_view_get_uri (web_view);
1135 * /<!-- -->* Here we could start a spinner or update the
1136 * <!-- -->* location bar with the provisional URI *<!-- -->/
1138 * case WEBKIT_LOAD_REDIRECTED:
1139 * redirected_uri = webkit_web_view_get_uri (web_view);
1141 * case WEBKIT_LOAD_COMMITTED:
1142 * /<!-- -->* The load is being performed. Current URI is
1143 * <!-- -->* the final one and it won't change unless a new
1144 * <!-- -->* load is requested or a navigation within the
1145 * <!-- -->* same page is performed *<!-- -->/
1146 * uri = webkit_web_view_get_uri (web_view);
1148 * case WEBKIT_LOAD_FINISHED:
1149 * /<!-- -->* Load finished, we can now stop the spinner *<!-- -->/
1153 * </programlisting></informalexample>
1155 signals[LOAD_CHANGED] =
1156 g_signal_new("load-changed",
1157 G_TYPE_FROM_CLASS(webViewClass),
1159 G_STRUCT_OFFSET(WebKitWebViewClass, load_changed),
1161 g_cclosure_marshal_VOID__ENUM,
1163 WEBKIT_TYPE_LOAD_EVENT);
1166 * WebKitWebView::load-failed:
1167 * @web_view: the #WebKitWebView on which the signal is emitted
1168 * @load_event: the #WebKitLoadEvent of the load operation
1169 * @failing_uri: the URI that failed to load
1170 * @error: the #GError that was triggered
1172 * Emitted when an error occurs during a load operation.
1173 * If the error happened when starting to load data for a page
1174 * @load_event will be %WEBKIT_LOAD_STARTED. If it happened while
1175 * loading a committed data source @load_event will be %WEBKIT_LOAD_COMMITTED.
1176 * Since a load error causes the load operation to finish, the signal
1177 * WebKitWebView::load-changed will always be emitted with
1178 * %WEBKIT_LOAD_FINISHED event right after this one.
1180 * By default, if the signal is not handled, a stock error page will be displayed.
1181 * You need to handle the signal if you want to provide your own error page.
1183 * Returns: %TRUE to stop other handlers from being invoked for the event.
1184 * %FALSE to propagate the event further.
1186 signals[LOAD_FAILED] =
1189 G_TYPE_FROM_CLASS(webViewClass),
1191 G_STRUCT_OFFSET(WebKitWebViewClass, load_failed),
1192 g_signal_accumulator_true_handled, 0,
1193 g_cclosure_marshal_generic,
1195 WEBKIT_TYPE_LOAD_EVENT,
1197 G_TYPE_ERROR | G_SIGNAL_TYPE_STATIC_SCOPE);
1200 * WebKitWebView::load-failed-with-tls-errors:
1201 * @web_view: the #WebKitWebView on which the signal is emitted
1202 * @failing_uri: the URI that failed to load
1203 * @certificate: a #GTlsCertificate
1204 * @errors: a #GTlsCertificateFlags with the verification status of @certificate
1206 * Emitted when a TLS error occurs during a load operation.
1207 * To allow an exception for this @certificate
1208 * and the host of @failing_uri use webkit_web_context_allow_tls_certificate_for_host().
1210 * To handle this signal asynchronously you should call g_object_ref() on @certificate
1213 * If %FALSE is returned, #WebKitWebView::load-failed will be emitted. The load
1214 * will finish regardless of the returned value.
1216 * Returns: %TRUE to stop other handlers from being invoked for the event.
1217 * %FALSE to propagate the event further.
1221 signals[LOAD_FAILED_WITH_TLS_ERRORS] =
1222 g_signal_new("load-failed-with-tls-errors",
1223 G_TYPE_FROM_CLASS(webViewClass),
1225 G_STRUCT_OFFSET(WebKitWebViewClass, load_failed_with_tls_errors),
1226 g_signal_accumulator_true_handled, 0 /* accumulator data */,
1227 g_cclosure_marshal_generic,
1230 G_TYPE_TLS_CERTIFICATE,
1231 G_TYPE_TLS_CERTIFICATE_FLAGS);
1234 * WebKitWebView::create:
1235 * @web_view: the #WebKitWebView on which the signal is emitted
1236 * @navigation_action: a #WebKitNavigationAction
1238 * Emitted when the creation of a new #WebKitWebView is requested.
1239 * If this signal is handled the signal handler should return the
1240 * newly created #WebKitWebView.
1242 * The #WebKitNavigationAction parameter contains information about the
1243 * navigation action that triggered this signal.
1245 * When using %WEBKIT_PROCESS_MODEL_MULTIPLE_SECONDARY_PROCESSES
1246 * process model, the new #WebKitWebView should be related to
1247 * @web_view to share the same web process, see webkit_web_view_new_with_related_view()
1250 * The new #WebKitWebView should not be displayed to the user
1251 * until the #WebKitWebView::ready-to-show signal is emitted.
1253 * Returns: (transfer full): a newly allocated #WebKitWebView widget
1254 * or %NULL to propagate the event further.
1256 signals[CREATE] = g_signal_new(
1258 G_TYPE_FROM_CLASS(webViewClass),
1260 G_STRUCT_OFFSET(WebKitWebViewClass, create),
1261 webkitWebViewAccumulatorObjectHandled, 0,
1262 g_cclosure_marshal_generic,
1266 WEBKIT_TYPE_WEB_VIEW,
1269 WEBKIT_TYPE_NAVIGATION_ACTION | G_SIGNAL_TYPE_STATIC_SCOPE);
1272 * WebKitWebView::ready-to-show:
1273 * @web_view: the #WebKitWebView on which the signal is emitted
1275 * Emitted after #WebKitWebView::create on the newly created #WebKitWebView
1276 * when it should be displayed to the user. When this signal is emitted
1277 * all the information about how the window should look, including
1278 * size, position, whether the location, status and scrollbars
1279 * should be displayed, is already set on the #WebKitWindowProperties
1280 * of @web_view. See also webkit_web_view_get_window_properties().
1282 signals[READY_TO_SHOW] =
1283 g_signal_new("ready-to-show",
1284 G_TYPE_FROM_CLASS(webViewClass),
1286 G_STRUCT_OFFSET(WebKitWebViewClass, ready_to_show),
1288 g_cclosure_marshal_VOID__VOID,
1292 * WebKitWebView::run-as-modal:
1293 * @web_view: the #WebKitWebView on which the signal is emitted
1295 * Emitted after #WebKitWebView::ready-to-show on the newly
1296 * created #WebKitWebView when JavaScript code calls
1297 * <function>window.showModalDialog</function>. The purpose of
1298 * this signal is to allow the client application to prepare the
1299 * new view to behave as modal. Once the signal is emitted a new
1300 * main loop will be run to block user interaction in the parent
1301 * #WebKitWebView until the new dialog is closed.
1303 signals[RUN_AS_MODAL] =
1304 g_signal_new("run-as-modal",
1305 G_TYPE_FROM_CLASS(webViewClass),
1307 G_STRUCT_OFFSET(WebKitWebViewClass, run_as_modal),
1309 g_cclosure_marshal_VOID__VOID,
1313 * WebKitWebView::close:
1314 * @web_view: the #WebKitWebView on which the signal is emitted
1316 * Emitted when closing a #WebKitWebView is requested. This occurs when a
1317 * call is made from JavaScript's <function>window.close</function> function or
1318 * after trying to close the @web_view with webkit_web_view_try_close().
1319 * It is the owner's responsibility to handle this signal to hide or
1320 * destroy the #WebKitWebView, if necessary.
1323 g_signal_new("close",
1324 G_TYPE_FROM_CLASS(webViewClass),
1326 G_STRUCT_OFFSET(WebKitWebViewClass, close),
1328 g_cclosure_marshal_VOID__VOID,
1332 * WebKitWebView::script-dialog:
1333 * @web_view: the #WebKitWebView on which the signal is emitted
1334 * @dialog: the #WebKitScriptDialog to show
1336 * Emitted when JavaScript code calls <function>window.alert</function>,
1337 * <function>window.confirm</function> or <function>window.prompt</function>,
1338 * or when <function>onbeforeunload</function> event is fired.
1339 * The @dialog parameter should be used to build the dialog.
1340 * If the signal is not handled a different dialog will be built and shown depending
1341 * on the dialog type:
1344 * %WEBKIT_SCRIPT_DIALOG_ALERT: message dialog with a single Close button.
1345 * </para></listitem>
1347 * %WEBKIT_SCRIPT_DIALOG_CONFIRM: message dialog with OK and Cancel buttons.
1348 * </para></listitem>
1350 * %WEBKIT_SCRIPT_DIALOG_PROMPT: message dialog with OK and Cancel buttons and
1351 * a text entry with the default text.
1352 * </para></listitem>
1354 * %WEBKIT_SCRIPT_DIALOG_BEFORE_UNLOAD_CONFIRM: message dialog with Stay and Leave buttons.
1355 * </para></listitem>
1358 * Returns: %TRUE to stop other handlers from being invoked for the event.
1359 * %FALSE to propagate the event further.
1361 signals[SCRIPT_DIALOG] = g_signal_new(
1363 G_TYPE_FROM_CLASS(webViewClass),
1365 G_STRUCT_OFFSET(WebKitWebViewClass, script_dialog),
1366 g_signal_accumulator_true_handled, nullptr,
1367 g_cclosure_marshal_generic,
1369 WEBKIT_TYPE_SCRIPT_DIALOG | G_SIGNAL_TYPE_STATIC_SCOPE);
1372 * WebKitWebView::decide-policy:
1373 * @web_view: the #WebKitWebView on which the signal is emitted
1374 * @decision: the #WebKitPolicyDecision
1375 * @decision_type: a #WebKitPolicyDecisionType denoting the type of @decision
1377 * This signal is emitted when WebKit is requesting the client to decide a policy
1378 * decision, such as whether to navigate to a page, open a new window or whether or
1379 * not to download a resource. The #WebKitNavigationPolicyDecision passed in the
1380 * @decision argument is a generic type, but should be casted to a more
1381 * specific type when making the decision. For example:
1383 * <informalexample><programlisting>
1385 * decide_policy_cb (WebKitWebView *web_view,
1386 * WebKitPolicyDecision *decision,
1387 * WebKitPolicyDecisionType type)
1390 * case WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION: {
1391 * WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision);
1392 * /<!-- -->* Make a policy decision here. *<!-- -->/
1395 * case WEBKIT_POLICY_DECISION_TYPE_NEW_WINDOW_ACTION: {
1396 * WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision);
1397 * /<!-- -->* Make a policy decision here. *<!-- -->/
1400 * case WEBKIT_POLICY_DECISION_TYPE_RESPONSE:
1401 * WebKitResponsePolicyDecision *response = WEBKIT_RESPONSE_POLICY_DECISION (decision);
1402 * /<!-- -->* Make a policy decision here. *<!-- -->/
1405 * /<!-- -->* Making no decision results in webkit_policy_decision_use(). *<!-- -->/
1410 * </programlisting></informalexample>
1412 * It is possible to make policy decision asynchronously, by simply calling g_object_ref()
1413 * on the @decision argument and returning %TRUE to block the default signal handler.
1414 * If the last reference is removed on a #WebKitPolicyDecision and no decision has been
1415 * made explicitly, webkit_policy_decision_use() will be the default policy decision. The
1416 * default signal handler will simply call webkit_policy_decision_use(). Only the first
1417 * policy decision chosen for a given #WebKitPolicyDecision will have any affect.
1419 * Returns: %TRUE to stop other handlers from being invoked for the event.
1420 * %FALSE to propagate the event further.
1423 signals[DECIDE_POLICY] = g_signal_new(
1425 G_TYPE_FROM_CLASS(webViewClass),
1427 G_STRUCT_OFFSET(WebKitWebViewClass, decide_policy),
1428 g_signal_accumulator_true_handled, nullptr /* accumulator data */,
1429 g_cclosure_marshal_generic,
1430 G_TYPE_BOOLEAN, 2, /* number of parameters */
1431 WEBKIT_TYPE_POLICY_DECISION,
1432 WEBKIT_TYPE_POLICY_DECISION_TYPE);
1435 * WebKitWebView::permission-request:
1436 * @web_view: the #WebKitWebView on which the signal is emitted
1437 * @request: the #WebKitPermissionRequest
1439 * This signal is emitted when WebKit is requesting the client to
1440 * decide about a permission request, such as allowing the browser
1441 * to switch to fullscreen mode, sharing its location or similar
1444 * A possible way to use this signal could be through a dialog
1445 * allowing the user decide what to do with the request:
1447 * <informalexample><programlisting>
1448 * static gboolean permission_request_cb (WebKitWebView *web_view,
1449 * WebKitPermissionRequest *request,
1450 * GtkWindow *parent_window)
1452 * GtkWidget *dialog = gtk_message_dialog_new (parent_window,
1454 * GTK_MESSAGE_QUESTION,
1455 * GTK_BUTTONS_YES_NO,
1456 * "Allow Permission Request?");
1457 * gtk_widget_show (dialog);
1458 * gint result = gtk_dialog_run (GTK_DIALOG (dialog));
1461 * case GTK_RESPONSE_YES:
1462 * webkit_permission_request_allow (request);
1465 * webkit_permission_request_deny (request);
1468 * gtk_widget_destroy (dialog);
1472 * </programlisting></informalexample>
1474 * It is possible to handle permission requests asynchronously, by
1475 * simply calling g_object_ref() on the @request argument and
1476 * returning %TRUE to block the default signal handler. If the
1477 * last reference is removed on a #WebKitPermissionRequest and the
1478 * request has not been handled, webkit_permission_request_deny()
1479 * will be the default action.
1481 * If the signal is not handled, the @request will be completed automatically
1482 * by the specific #WebKitPermissionRequest that could allow or deny it. Check the
1483 * documentation of classes implementing #WebKitPermissionRequest interface to know
1484 * their default action.
1486 * Returns: %TRUE to stop other handlers from being invoked for the event.
1487 * %FALSE to propagate the event further.
1490 signals[PERMISSION_REQUEST] = g_signal_new(
1491 "permission-request",
1492 G_TYPE_FROM_CLASS(webViewClass),
1494 G_STRUCT_OFFSET(WebKitWebViewClass, permission_request),
1495 g_signal_accumulator_true_handled, nullptr /* accumulator data */,
1496 g_cclosure_marshal_generic,
1497 G_TYPE_BOOLEAN, 1, /* number of parameters */
1498 WEBKIT_TYPE_PERMISSION_REQUEST);
1500 * WebKitWebView::mouse-target-changed:
1501 * @web_view: the #WebKitWebView on which the signal is emitted
1502 * @hit_test_result: a #WebKitHitTestResult
1503 * @modifiers: a bitmask of #GdkModifierType
1505 * This signal is emitted when the mouse cursor moves over an
1506 * element such as a link, image or a media element. To determine
1507 * what type of element the mouse cursor is over, a Hit Test is performed
1508 * on the current mouse coordinates and the result is passed in the
1509 * @hit_test_result argument. The @modifiers argument is a bitmask of
1510 * #GdkModifierType flags indicating the state of modifier keys.
1511 * The signal is emitted again when the mouse is moved out of the
1512 * current element with a new @hit_test_result.
1514 signals[MOUSE_TARGET_CHANGED] = g_signal_new(
1515 "mouse-target-changed",
1516 G_TYPE_FROM_CLASS(webViewClass),
1518 G_STRUCT_OFFSET(WebKitWebViewClass, mouse_target_changed),
1520 g_cclosure_marshal_generic,
1522 WEBKIT_TYPE_HIT_TEST_RESULT,
1527 * WebKitWebView::print:
1528 * @web_view: the #WebKitWebView on which the signal is emitted
1529 * @print_operation: the #WebKitPrintOperation that will handle the print request
1531 * Emitted when printing is requested on @web_view, usually by a JavaScript call,
1532 * before the print dialog is shown. This signal can be used to set the initial
1533 * print settings and page setup of @print_operation to be used as default values in
1534 * the print dialog. You can call webkit_print_operation_set_print_settings() and
1535 * webkit_print_operation_set_page_setup() and then return %FALSE to propagate the
1536 * event so that the print dialog is shown.
1538 * You can connect to this signal and return %TRUE to cancel the print operation
1539 * or implement your own print dialog.
1541 * Returns: %TRUE to stop other handlers from being invoked for the event.
1542 * %FALSE to propagate the event further.
1544 signals[PRINT] = g_signal_new(
1546 G_TYPE_FROM_CLASS(webViewClass),
1548 G_STRUCT_OFFSET(WebKitWebViewClass, print),
1549 g_signal_accumulator_true_handled, nullptr,
1550 g_cclosure_marshal_generic,
1552 WEBKIT_TYPE_PRINT_OPERATION);
1553 #endif // PLATFORM(GTK)
1556 * WebKitWebView::resource-load-started:
1557 * @web_view: the #WebKitWebView on which the signal is emitted
1558 * @resource: a #WebKitWebResource
1559 * @request: a #WebKitURIRequest
1561 * Emitted when a new resource is going to be loaded. The @request parameter
1562 * contains the #WebKitURIRequest that will be sent to the server.
1563 * You can monitor the load operation by connecting to the different signals
1566 signals[RESOURCE_LOAD_STARTED] = g_signal_new(
1567 "resource-load-started",
1568 G_TYPE_FROM_CLASS(webViewClass),
1570 G_STRUCT_OFFSET(WebKitWebViewClass, resource_load_started),
1572 g_cclosure_marshal_generic,
1574 WEBKIT_TYPE_WEB_RESOURCE,
1575 WEBKIT_TYPE_URI_REQUEST);
1578 * WebKitWebView::enter-fullscreen:
1579 * @web_view: the #WebKitWebView on which the signal is emitted.
1581 * Emitted when JavaScript code calls
1582 * <function>element.webkitRequestFullScreen</function>. If the
1583 * signal is not handled the #WebKitWebView will proceed to full screen
1584 * its top level window. This signal can be used by client code to
1585 * request permission to the user prior doing the full screen
1586 * transition and eventually prepare the top-level window
1587 * (e.g. hide some widgets that would otherwise be part of the
1588 * full screen window).
1590 * Returns: %TRUE to stop other handlers from being invoked for the event.
1591 * %FALSE to continue emission of the event.
1593 signals[ENTER_FULLSCREEN] = g_signal_new(
1595 G_TYPE_FROM_CLASS(webViewClass),
1597 G_STRUCT_OFFSET(WebKitWebViewClass, enter_fullscreen),
1598 g_signal_accumulator_true_handled, nullptr,
1599 g_cclosure_marshal_generic,
1603 * WebKitWebView::leave-fullscreen:
1604 * @web_view: the #WebKitWebView on which the signal is emitted.
1606 * Emitted when the #WebKitWebView is about to restore its top level
1607 * window out of its full screen state. This signal can be used by
1608 * client code to restore widgets hidden during the
1609 * #WebKitWebView::enter-fullscreen stage for instance.
1611 * Returns: %TRUE to stop other handlers from being invoked for the event.
1612 * %FALSE to continue emission of the event.
1614 signals[LEAVE_FULLSCREEN] = g_signal_new(
1616 G_TYPE_FROM_CLASS(webViewClass),
1618 G_STRUCT_OFFSET(WebKitWebViewClass, leave_fullscreen),
1619 g_signal_accumulator_true_handled, nullptr,
1620 g_cclosure_marshal_generic,
1624 * WebKitWebView::run-file-chooser:
1625 * @web_view: the #WebKitWebView on which the signal is emitted
1626 * @request: a #WebKitFileChooserRequest
1628 * This signal is emitted when the user interacts with a <input
1629 * type='file' /> HTML element, requesting from WebKit to show
1630 * a dialog to select one or more files to be uploaded. To let the
1631 * application know the details of the file chooser, as well as to
1632 * allow the client application to either cancel the request or
1633 * perform an actual selection of files, the signal will pass an
1634 * instance of the #WebKitFileChooserRequest in the @request
1637 * The default signal handler will asynchronously run a regular
1638 * #GtkFileChooserDialog for the user to interact with.
1640 * Returns: %TRUE to stop other handlers from being invoked for the event.
1641 * %FALSE to propagate the event further.
1644 signals[RUN_FILE_CHOOSER] = g_signal_new(
1646 G_TYPE_FROM_CLASS(webViewClass),
1648 G_STRUCT_OFFSET(WebKitWebViewClass, run_file_chooser),
1649 g_signal_accumulator_true_handled, nullptr /* accumulator data */,
1650 g_cclosure_marshal_generic,
1651 G_TYPE_BOOLEAN, 1, /* number of parameters */
1652 WEBKIT_TYPE_FILE_CHOOSER_REQUEST);
1655 * WebKitWebView::context-menu:
1656 * @web_view: the #WebKitWebView on which the signal is emitted
1657 * @context_menu: the proposed #WebKitContextMenu
1658 * @event: the #GdkEvent that triggered the context menu
1659 * @hit_test_result: a #WebKitHitTestResult
1661 * Emitted when a context menu is about to be displayed to give the application
1662 * a chance to customize the proposed menu, prevent the menu from being displayed,
1663 * or build its own context menu.
1666 * To customize the proposed menu you can use webkit_context_menu_prepend(),
1667 * webkit_context_menu_append() or webkit_context_menu_insert() to add new
1668 * #WebKitContextMenuItem<!-- -->s to @context_menu, webkit_context_menu_move_item()
1669 * to reorder existing items, or webkit_context_menu_remove() to remove an
1670 * existing item. The signal handler should return %FALSE, and the menu represented
1671 * by @context_menu will be shown.
1672 * </para></listitem>
1674 * To prevent the menu from being displayed you can just connect to this signal
1675 * and return %TRUE so that the proposed menu will not be shown.
1676 * </para></listitem>
1678 * To build your own menu, you can remove all items from the proposed menu with
1679 * webkit_context_menu_remove_all(), add your own items and return %FALSE so
1680 * that the menu will be shown. You can also ignore the proposed #WebKitContextMenu,
1681 * build your own #GtkMenu and return %TRUE to prevent the proposed menu from being shown.
1682 * </para></listitem>
1684 * If you just want the default menu to be shown always, simply don't connect to this
1685 * signal because showing the proposed context menu is the default behaviour.
1686 * </para></listitem>
1689 * The @event is expected to be one of the following types:
1692 * a #GdkEventButton of type %GDK_BUTTON_PRESS when the context menu
1693 * was triggered with mouse.
1694 * </para></listitem>
1696 * a #GdkEventKey of type %GDK_KEY_PRESS if the keyboard was used to show
1698 * </para></listitem>
1700 * a generic #GdkEvent of type %GDK_NOTHING when the #GtkWidget::popup-menu
1701 * signal was used to show the context menu.
1702 * </para></listitem>
1705 * If the signal handler returns %FALSE the context menu represented by @context_menu
1706 * will be shown, if it return %TRUE the context menu will not be shown.
1708 * The proposed #WebKitContextMenu passed in @context_menu argument is only valid
1709 * during the signal emission.
1711 * Returns: %TRUE to stop other handlers from being invoked for the event.
1712 * %FALSE to propagate the event further.
1714 signals[CONTEXT_MENU] = g_signal_new(
1716 G_TYPE_FROM_CLASS(webViewClass),
1718 G_STRUCT_OFFSET(WebKitWebViewClass, context_menu),
1719 g_signal_accumulator_true_handled, nullptr,
1720 g_cclosure_marshal_generic,
1722 WEBKIT_TYPE_CONTEXT_MENU,
1724 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE,
1726 G_TYPE_POINTER, // FIXME: use a wpe thing here. I'm not sure we want to expose libwpe in the API.
1728 WEBKIT_TYPE_HIT_TEST_RESULT);
1731 * WebKitWebView::context-menu-dismissed:
1732 * @web_view: the #WebKitWebView on which the signal is emitted
1734 * Emitted after #WebKitWebView::context-menu signal, if the context menu is shown,
1735 * to notify that the context menu is dismissed.
1737 signals[CONTEXT_MENU_DISMISSED] =
1738 g_signal_new("context-menu-dismissed",
1739 G_TYPE_FROM_CLASS(webViewClass),
1741 G_STRUCT_OFFSET(WebKitWebViewClass, context_menu_dismissed),
1743 g_cclosure_marshal_VOID__VOID,
1747 * WebKitWebView::submit-form:
1748 * @web_view: the #WebKitWebView on which the signal is emitted
1749 * @request: a #WebKitFormSubmissionRequest
1751 * This signal is emitted when a form is about to be submitted. The @request
1752 * argument passed contains information about the text fields of the form. This
1753 * is typically used to store login information that can be used later to
1754 * pre-fill the form.
1755 * The form will not be submitted until webkit_form_submission_request_submit() is called.
1757 * It is possible to handle the form submission request asynchronously, by
1758 * simply calling g_object_ref() on the @request argument and calling
1759 * webkit_form_submission_request_submit() when done to continue with the form submission.
1760 * If the last reference is removed on a #WebKitFormSubmissionRequest and the
1761 * form has not been submitted, webkit_form_submission_request_submit() will be called.
1763 signals[SUBMIT_FORM] =
1764 g_signal_new("submit-form",
1765 G_TYPE_FROM_CLASS(webViewClass),
1767 G_STRUCT_OFFSET(WebKitWebViewClass, submit_form),
1769 g_cclosure_marshal_VOID__OBJECT,
1771 WEBKIT_TYPE_FORM_SUBMISSION_REQUEST);
1774 * WebKitWebView::insecure-content-detected:
1775 * @web_view: the #WebKitWebView on which the signal is emitted
1776 * @event: the #WebKitInsecureContentEvent
1778 * This signal is emitted when insecure content has been detected
1779 * in a page loaded through a secure connection. This typically
1780 * means that a external resource from an unstrusted source has
1781 * been run or displayed, resulting in a mix of HTTPS and
1782 * non-HTTPS content.
1784 * You can check the @event parameter to know exactly which kind
1785 * of event has been detected (see #WebKitInsecureContentEvent).
1787 signals[INSECURE_CONTENT_DETECTED] =
1788 g_signal_new("insecure-content-detected",
1789 G_TYPE_FROM_CLASS(webViewClass),
1791 G_STRUCT_OFFSET(WebKitWebViewClass, insecure_content_detected),
1793 g_cclosure_marshal_VOID__ENUM,
1795 WEBKIT_TYPE_INSECURE_CONTENT_EVENT);
1799 * WebKitWebView::web-process-crashed:
1800 * @web_view: the #WebKitWebView
1802 * This signal is emitted when the web process crashes.
1804 * Returns: %TRUE to stop other handlers from being invoked for the event.
1805 * %FALSE to propagate the event further.
1807 * Deprecated: 2.20: Use WebKitWebView::web-process-terminated instead.
1809 signals[WEB_PROCESS_CRASHED] = g_signal_new(
1810 "web-process-crashed",
1811 G_TYPE_FROM_CLASS(webViewClass),
1813 G_STRUCT_OFFSET(WebKitWebViewClass, web_process_crashed),
1814 g_signal_accumulator_true_handled, nullptr,
1815 g_cclosure_marshal_generic,
1820 * WebKitWebView::web-process-terminated:
1821 * @web_view: the #WebKitWebView
1822 * @reason: the a #WebKitWebProcessTerminationReason
1824 * This signal is emitted when the web process terminates abnormally due
1829 signals[WEB_PROCESS_TERMINATED] = g_signal_new(
1830 "web-process-terminated",
1831 G_TYPE_FROM_CLASS(webViewClass),
1833 G_STRUCT_OFFSET(WebKitWebViewClass, web_process_terminated),
1835 g_cclosure_marshal_VOID__ENUM,
1837 WEBKIT_TYPE_WEB_PROCESS_TERMINATION_REASON);
1840 * WebKitWebView::authenticate:
1841 * @web_view: the #WebKitWebView on which the signal is emitted
1842 * @request: a #WebKitAuthenticationRequest
1844 * This signal is emitted when the user is challenged with HTTP
1845 * authentication. To let the application access or supply
1846 * the credentials as well as to allow the client application
1847 * to either cancel the request or perform the authentication,
1848 * the signal will pass an instance of the
1849 * #WebKitAuthenticationRequest in the @request argument.
1850 * To handle this signal asynchronously you should keep a ref
1851 * of the request and return %TRUE. To disable HTTP authentication
1852 * entirely, connect to this signal and simply return %TRUE.
1854 * The default signal handler will run a default authentication
1855 * dialog asynchronously for the user to interact with.
1857 * Returns: %TRUE to stop other handlers from being invoked for the event.
1858 * %FALSE to propagate the event further.
1862 signals[AUTHENTICATE] = g_signal_new(
1864 G_TYPE_FROM_CLASS(webViewClass),
1866 G_STRUCT_OFFSET(WebKitWebViewClass, authenticate),
1867 g_signal_accumulator_true_handled, nullptr /* accumulator data */,
1868 g_cclosure_marshal_generic,
1869 G_TYPE_BOOLEAN, 1, /* number of parameters */
1870 WEBKIT_TYPE_AUTHENTICATION_REQUEST);
1873 * WebKitWebView::show-notification:
1874 * @web_view: the #WebKitWebView
1875 * @notification: a #WebKitNotification
1877 * This signal is emitted when a notification should be presented to the
1878 * user. The @notification is kept alive until either: 1) the web page cancels it
1879 * or 2) a navigation happens.
1881 * The default handler will emit a notification using libnotify, if built with
1884 * Returns: %TRUE to stop other handlers from being invoked. %FALSE otherwise.
1888 signals[SHOW_NOTIFICATION] = g_signal_new(
1889 "show-notification",
1890 G_TYPE_FROM_CLASS(gObjectClass),
1892 G_STRUCT_OFFSET(WebKitWebViewClass, show_notification),
1893 g_signal_accumulator_true_handled, nullptr /* accumulator data */,
1894 g_cclosure_marshal_generic,
1896 WEBKIT_TYPE_NOTIFICATION);
1900 * WebKitWebView::run-color-chooser:
1901 * @web_view: the #WebKitWebView on which the signal is emitted
1902 * @request: a #WebKitColorChooserRequest
1904 * This signal is emitted when the user interacts with a <input
1905 * type='color' /> HTML element, requesting from WebKit to show
1906 * a dialog to select a color. To let the application know the details of
1907 * the color chooser, as well as to allow the client application to either
1908 * cancel the request or perform an actual color selection, the signal will
1909 * pass an instance of the #WebKitColorChooserRequest in the @request
1912 * It is possible to handle this request asynchronously by increasing the
1913 * reference count of the request.
1915 * The default signal handler will asynchronously run a regular
1916 * #GtkColorChooser for the user to interact with.
1918 * Returns: %TRUE to stop other handlers from being invoked for the event.
1919 * %FALSE to propagate the event further.
1923 signals[RUN_COLOR_CHOOSER] = g_signal_new(
1924 "run-color-chooser",
1925 G_TYPE_FROM_CLASS(webViewClass),
1927 G_STRUCT_OFFSET(WebKitWebViewClass, run_color_chooser),
1928 g_signal_accumulator_true_handled, nullptr,
1929 g_cclosure_marshal_generic,
1931 WEBKIT_TYPE_COLOR_CHOOSER_REQUEST);
1934 * WebKitWebView::show-option-menu:
1935 * @web_view: the #WebKitWebView on which the signal is emitted
1936 * @menu: the #WebKitOptionMenu
1937 * @event: the #GdkEvent that triggered the menu, or %NULL
1938 * @rectangle: the option element area
1940 * This signal is emitted when a select element in @web_view needs to display a
1941 * dropdown menu. This signal can be used to show a custom menu, using @menu to get
1942 * the details of all items that should be displayed. The area of the element in the
1943 * #WebKitWebView is given as @rectangle parameter, it can be used to position the
1944 * menu. If this was triggered by a user interaction, like a mouse click,
1945 * @event parameter provides the #GdkEvent.
1946 * To handle this signal asynchronously you should keep a ref of the @menu.
1948 * The default signal handler will pop up a #GtkMenu.
1950 * Returns: %TRUE to stop other handlers from being invoked for the event.
1951 * %FALSE to propagate the event further.
1955 signals[SHOW_OPTION_MENU] = g_signal_new(
1957 G_TYPE_FROM_CLASS(webViewClass),
1959 G_STRUCT_OFFSET(WebKitWebViewClass, show_option_menu),
1960 g_signal_accumulator_true_handled, nullptr,
1961 g_cclosure_marshal_generic,
1963 WEBKIT_TYPE_OPTION_MENU,
1964 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE,
1965 GDK_TYPE_RECTANGLE | G_SIGNAL_TYPE_STATIC_SCOPE);
1966 #endif // PLATFORM(GTK)
1969 static void webkitWebViewCancelAuthenticationRequest(WebKitWebView* webView)
1971 if (!webView->priv->authenticationRequest)
1974 webkit_authentication_request_cancel(webView->priv->authenticationRequest.get());
1975 webView->priv->authenticationRequest.clear();
1978 void webkitWebViewCreatePage(WebKitWebView* webView, Ref<API::PageConfiguration>&& configuration)
1981 webkitWebViewBaseCreateWebPage(WEBKIT_WEB_VIEW_BASE(webView), WTFMove(configuration));
1983 webView->priv->view.reset(WKWPE::View::create(webkit_web_view_backend_get_wpe_backend(webView->priv->backend.get()), configuration.get()));
1987 WebPageProxy& webkitWebViewGetPage(WebKitWebView* webView)
1989 return getPage(webView);
1992 void webkitWebViewLoadChanged(WebKitWebView* webView, WebKitLoadEvent loadEvent)
1994 WebKitWebViewPrivate* priv = webView->priv;
1995 switch (loadEvent) {
1996 case WEBKIT_LOAD_STARTED:
1998 webkitWebViewCancelFaviconRequest(webView);
1999 webkitWebViewWatchForChangesInFavicon(webView);
2001 webkitWebViewCancelAuthenticationRequest(webView);
2002 priv->loadingResourcesMap.clear();
2003 priv->mainResource = nullptr;
2006 case WEBKIT_LOAD_COMMITTED: {
2007 WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(priv->context.get());
2008 GUniquePtr<char> faviconURI(webkit_favicon_database_get_favicon_uri(database, priv->activeURI.data()));
2009 webkitWebViewUpdateFaviconURI(webView, faviconURI.get());
2013 case WEBKIT_LOAD_FINISHED:
2014 webkitWebViewCancelAuthenticationRequest(webView);
2020 g_signal_emit(webView, signals[LOAD_CHANGED], 0, loadEvent);
2023 void webkitWebViewLoadFailed(WebKitWebView* webView, WebKitLoadEvent loadEvent, const char* failingURI, GError *error)
2025 webkitWebViewCancelAuthenticationRequest(webView);
2027 gboolean returnValue;
2028 g_signal_emit(webView, signals[LOAD_FAILED], 0, loadEvent, failingURI, error, &returnValue);
2029 g_signal_emit(webView, signals[LOAD_CHANGED], 0, WEBKIT_LOAD_FINISHED);
2032 void webkitWebViewLoadFailedWithTLSErrors(WebKitWebView* webView, const char* failingURI, GError* error, GTlsCertificateFlags tlsErrors, GTlsCertificate* certificate)
2034 webkitWebViewCancelAuthenticationRequest(webView);
2036 WebKitTLSErrorsPolicy tlsErrorsPolicy = webkit_web_context_get_tls_errors_policy(webView->priv->context.get());
2037 if (tlsErrorsPolicy == WEBKIT_TLS_ERRORS_POLICY_FAIL) {
2038 gboolean returnValue;
2039 g_signal_emit(webView, signals[LOAD_FAILED_WITH_TLS_ERRORS], 0, failingURI, certificate, tlsErrors, &returnValue);
2041 g_signal_emit(webView, signals[LOAD_FAILED], 0, WEBKIT_LOAD_STARTED, failingURI, error, &returnValue);
2044 g_signal_emit(webView, signals[LOAD_CHANGED], 0, WEBKIT_LOAD_FINISHED);
2048 void webkitWebViewGetLoadDecisionForIcon(WebKitWebView* webView, const LinkIcon& icon, Function<void(bool)>&& completionHandler)
2050 WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(webView->priv->context.get());
2051 webkitFaviconDatabaseGetLoadDecisionForIcon(database, icon, getPage(webView).pageLoadState().activeURL(), WTFMove(completionHandler));
2054 void webkitWebViewSetIcon(WebKitWebView* webView, const LinkIcon& icon, API::Data& iconData)
2056 WebKitFaviconDatabase* database = webkit_web_context_get_favicon_database(webView->priv->context.get());
2057 webkitFaviconDatabaseSetIconForPageURL(database, icon, iconData, getPage(webView).pageLoadState().activeURL());
2061 WebPageProxy* webkitWebViewCreateNewPage(WebKitWebView* webView, const WindowFeatures& windowFeatures, WebKitNavigationAction* navigationAction)
2063 WebKitWebView* newWebView;
2064 g_signal_emit(webView, signals[CREATE], 0, navigationAction, &newWebView);
2068 webkitWindowPropertiesUpdateFromWebWindowFeatures(newWebView->priv->windowProperties.get(), windowFeatures);
2070 RefPtr<WebPageProxy> newPage = &getPage(newWebView);
2071 return newPage.leakRef();
2074 void webkitWebViewReadyToShowPage(WebKitWebView* webView)
2076 g_signal_emit(webView, signals[READY_TO_SHOW], 0, NULL);
2079 void webkitWebViewRunAsModal(WebKitWebView* webView)
2081 g_signal_emit(webView, signals[RUN_AS_MODAL], 0, NULL);
2083 webView->priv->modalLoop = adoptGRef(g_main_loop_new(0, FALSE));
2086 // This is to suppress warnings about gdk_threads_leave and gdk_threads_enter.
2087 #pragma GCC diagnostic push
2088 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
2089 gdk_threads_leave();
2092 g_main_loop_run(webView->priv->modalLoop.get());
2095 gdk_threads_enter();
2096 #pragma GCC diagnostic pop
2100 void webkitWebViewClosePage(WebKitWebView* webView)
2102 g_signal_emit(webView, signals[CLOSE], 0, NULL);
2105 void webkitWebViewRunJavaScriptAlert(WebKitWebView* webView, const CString& message)
2107 WebKitScriptDialog dialog(WEBKIT_SCRIPT_DIALOG_ALERT, message);
2108 SetForScope<WebKitScriptDialog*> change(webView->priv->currentScriptDialog, &dialog);
2109 gboolean returnValue;
2110 g_signal_emit(webView, signals[SCRIPT_DIALOG], 0, &dialog, &returnValue);
2113 bool webkitWebViewRunJavaScriptConfirm(WebKitWebView* webView, const CString& message)
2115 WebKitScriptDialog dialog(WEBKIT_SCRIPT_DIALOG_CONFIRM, message);
2116 SetForScope<WebKitScriptDialog*> change(webView->priv->currentScriptDialog, &dialog);
2117 gboolean returnValue;
2118 g_signal_emit(webView, signals[SCRIPT_DIALOG], 0, &dialog, &returnValue);
2119 return dialog.confirmed;
2122 CString webkitWebViewRunJavaScriptPrompt(WebKitWebView* webView, const CString& message, const CString& defaultText)
2124 WebKitScriptDialog dialog(WEBKIT_SCRIPT_DIALOG_PROMPT, message, defaultText);
2125 SetForScope<WebKitScriptDialog*> change(webView->priv->currentScriptDialog, &dialog);
2126 gboolean returnValue;
2127 g_signal_emit(webView, signals[SCRIPT_DIALOG], 0, &dialog, &returnValue);
2131 bool webkitWebViewRunJavaScriptBeforeUnloadConfirm(WebKitWebView* webView, const CString& message)
2133 WebKitScriptDialog dialog(WEBKIT_SCRIPT_DIALOG_BEFORE_UNLOAD_CONFIRM, message);
2134 SetForScope<WebKitScriptDialog*> change(webView->priv->currentScriptDialog, &dialog);
2135 gboolean returnValue;
2136 g_signal_emit(webView, signals[SCRIPT_DIALOG], 0, &dialog, &returnValue);
2137 return dialog.confirmed;
2140 bool webkitWebViewIsShowingScriptDialog(WebKitWebView* webView)
2142 if (!webView->priv->currentScriptDialog)
2145 // FIXME: Add API to ask the user in case default implementation is not being used.
2146 return webkitScriptDialogIsRunning(webView->priv->currentScriptDialog);
2149 String webkitWebViewGetCurrentScriptDialogMessage(WebKitWebView* webView)
2151 if (!webView->priv->currentScriptDialog)
2154 return String::fromUTF8(webView->priv->currentScriptDialog->message);
2157 void webkitWebViewSetCurrentScriptDialogUserInput(WebKitWebView* webView, const String& userInput)
2159 if (!webView->priv->currentScriptDialog)
2162 // FIXME: Add API to ask the user in case default implementation is not being used.
2163 if (webkitScriptDialogIsRunning(webView->priv->currentScriptDialog))
2164 webkitScriptDialogSetUserInput(webView->priv->currentScriptDialog, userInput);
2167 void webkitWebViewAcceptCurrentScriptDialog(WebKitWebView* webView)
2169 if (!webView->priv->currentScriptDialog)
2172 // FIXME: Add API to ask the user in case default implementation is not being used.
2173 if (webkitScriptDialogIsRunning(webView->priv->currentScriptDialog))
2174 webkitScriptDialogAccept(webView->priv->currentScriptDialog);
2177 void webkitWebViewDismissCurrentScriptDialog(WebKitWebView* webView)
2179 if (!webView->priv->currentScriptDialog)
2182 // FIXME: Add API to ask the user in case default implementation is not being used.
2183 if (webkitScriptDialogIsRunning(webView->priv->currentScriptDialog))
2184 webkitScriptDialogDismiss(webView->priv->currentScriptDialog);
2187 std::optional<WebKitScriptDialogType> webkitWebViewGetCurrentScriptDialogType(WebKitWebView* webView)
2189 if (!webView->priv->currentScriptDialog)
2190 return std::nullopt;
2192 return static_cast<WebKitScriptDialogType>(webView->priv->currentScriptDialog->type);
2195 void webkitWebViewMakePolicyDecision(WebKitWebView* webView, WebKitPolicyDecisionType type, WebKitPolicyDecision* decision)
2197 gboolean returnValue;
2198 g_signal_emit(webView, signals[DECIDE_POLICY], 0, decision, type, &returnValue);
2201 void webkitWebViewMakePermissionRequest(WebKitWebView* webView, WebKitPermissionRequest* request)
2203 gboolean returnValue;
2204 g_signal_emit(webView, signals[PERMISSION_REQUEST], 0, request, &returnValue);
2207 void webkitWebViewMouseTargetChanged(WebKitWebView* webView, const WebHitTestResultData& hitTestResult, WebEvent::Modifiers modifiers)
2210 webkitWebViewBaseSetTooltipArea(WEBKIT_WEB_VIEW_BASE(webView), hitTestResult.elementBoundingBox);
2213 WebKitWebViewPrivate* priv = webView->priv;
2214 if (priv->mouseTargetHitTestResult
2215 && priv->mouseTargetModifiers == modifiers
2216 && webkitHitTestResultCompare(priv->mouseTargetHitTestResult.get(), hitTestResult))
2219 priv->mouseTargetModifiers = modifiers;
2220 priv->mouseTargetHitTestResult = adoptGRef(webkitHitTestResultCreate(hitTestResult));
2221 g_signal_emit(webView, signals[MOUSE_TARGET_CHANGED], 0, priv->mouseTargetHitTestResult.get(), toPlatformModifiers(modifiers));
2224 void webkitWebViewHandleDownloadRequest(WebKitWebView* webView, DownloadProxy* downloadProxy)
2226 ASSERT(downloadProxy);
2227 GRefPtr<WebKitDownload> download = webkitWebContextGetOrCreateDownload(downloadProxy);
2228 webkitDownloadSetWebView(download.get(), webView);
2232 void webkitWebViewPrintFrame(WebKitWebView* webView, WebFrameProxy* frame)
2234 auto printOperation = adoptGRef(webkit_print_operation_new(webView));
2235 webkitPrintOperationSetPrintMode(printOperation.get(), PrintInfo::PrintModeSync);
2236 gboolean returnValue;
2237 g_signal_emit(webView, signals[PRINT], 0, printOperation.get(), &returnValue);
2241 WebKitPrintOperationResponse response = webkitPrintOperationRunDialogForFrame(printOperation.get(), 0, frame);
2242 if (response == WEBKIT_PRINT_OPERATION_RESPONSE_CANCEL)
2244 g_signal_connect(printOperation.leakRef(), "finished", G_CALLBACK(g_object_unref), 0);
2248 void webkitWebViewResourceLoadStarted(WebKitWebView* webView, WebFrameProxy* frame, uint64_t resourceIdentifier, WebKitURIRequest* request)
2250 WebKitWebViewPrivate* priv = webView->priv;
2251 bool isMainResource = frame->isMainFrame() && !priv->mainResource;
2252 WebKitWebResource* resource = webkitWebResourceCreate(frame, request, isMainResource);
2254 priv->mainResource = resource;
2255 priv->loadingResourcesMap.set(resourceIdentifier, adoptGRef(resource));
2256 g_signal_emit(webView, signals[RESOURCE_LOAD_STARTED], 0, resource, request);
2259 WebKitWebResource* webkitWebViewGetLoadingWebResource(WebKitWebView* webView, uint64_t resourceIdentifier)
2261 GRefPtr<WebKitWebResource> resource = webView->priv->loadingResourcesMap.get(resourceIdentifier);
2262 return resource.get();
2265 void webkitWebViewRemoveLoadingWebResource(WebKitWebView* webView, uint64_t resourceIdentifier)
2267 WebKitWebViewPrivate* priv = webView->priv;
2268 ASSERT(priv->loadingResourcesMap.contains(resourceIdentifier));
2269 priv->loadingResourcesMap.remove(resourceIdentifier);
2272 void webkitWebViewEnterFullScreen(WebKitWebView* webView)
2274 #if ENABLE(FULLSCREEN_API)
2275 gboolean returnValue;
2276 g_signal_emit(webView, signals[ENTER_FULLSCREEN], 0, &returnValue);
2279 webkitWebViewBaseEnterFullScreen(WEBKIT_WEB_VIEW_BASE(webView));
2284 void webkitWebViewExitFullScreen(WebKitWebView* webView)
2286 #if ENABLE(FULLSCREEN_API)
2287 gboolean returnValue;
2288 g_signal_emit(webView, signals[LEAVE_FULLSCREEN], 0, &returnValue);
2291 webkitWebViewBaseExitFullScreen(WEBKIT_WEB_VIEW_BASE(webView));
2296 void webkitWebViewRunFileChooserRequest(WebKitWebView* webView, WebKitFileChooserRequest* request)
2298 gboolean returnValue;
2299 g_signal_emit(webView, signals[RUN_FILE_CHOOSER], 0, request, &returnValue);
2303 static void contextMenuDismissed(GtkMenuShell*, WebKitWebView* webView)
2305 g_signal_emit(webView, signals[CONTEXT_MENU_DISMISSED], 0, NULL);
2308 void webkitWebViewPopulateContextMenu(WebKitWebView* webView, const Vector<WebContextMenuItemData>& proposedMenu, const WebHitTestResultData& hitTestResultData, GVariant* userData)
2310 WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(webView);
2311 WebContextMenuProxyGtk* contextMenuProxy = webkitWebViewBaseGetActiveContextMenuProxy(webViewBase);
2312 ASSERT(contextMenuProxy);
2314 GRefPtr<WebKitContextMenu> contextMenu = adoptGRef(webkitContextMenuCreate(proposedMenu));
2316 webkit_context_menu_set_user_data(WEBKIT_CONTEXT_MENU(contextMenu.get()), userData);
2318 GRefPtr<WebKitHitTestResult> hitTestResult = adoptGRef(webkitHitTestResultCreate(hitTestResultData));
2319 GUniquePtr<GdkEvent> contextMenuEvent(webkitWebViewBaseTakeContextMenuEvent(webViewBase));
2320 gboolean returnValue;
2321 g_signal_emit(webView, signals[CONTEXT_MENU], 0, contextMenu.get(), contextMenuEvent.get(), hitTestResult.get(), &returnValue);
2325 Vector<WebContextMenuItemGlib> contextMenuItems;
2326 webkitContextMenuPopulate(contextMenu.get(), contextMenuItems);
2327 contextMenuProxy->populate(contextMenuItems);
2329 g_signal_connect(contextMenuProxy->gtkMenu(), "deactivate", G_CALLBACK(contextMenuDismissed), webView);
2331 // Clear the menu to make sure it's useless after signal emission.
2332 webkit_context_menu_remove_all(contextMenu.get());
2335 void webkitWebViewPopulateContextMenu(WebKitWebView* webView, const Vector<WebContextMenuItemData>& proposedMenu, const WebHitTestResultData& hitTestResultData, GVariant* userData)
2337 GRefPtr<WebKitContextMenu> contextMenu = adoptGRef(webkitContextMenuCreate(proposedMenu));
2339 webkit_context_menu_set_user_data(WEBKIT_CONTEXT_MENU(contextMenu.get()), userData);
2340 GRefPtr<WebKitHitTestResult> hitTestResult = adoptGRef(webkitHitTestResultCreate(hitTestResultData));
2341 gboolean returnValue;
2342 g_signal_emit(webView, signals[CONTEXT_MENU], 0, contextMenu.get(), nullptr, hitTestResult.get(), &returnValue);
2346 void webkitWebViewSubmitFormRequest(WebKitWebView* webView, WebKitFormSubmissionRequest* request)
2348 g_signal_emit(webView, signals[SUBMIT_FORM], 0, request);
2351 void webkitWebViewHandleAuthenticationChallenge(WebKitWebView* webView, AuthenticationChallengeProxy* authenticationChallenge)
2354 G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
2355 gboolean privateBrowsingEnabled = webView->priv->isEphemeral || webkit_settings_get_enable_private_browsing(webView->priv->settings.get());
2356 G_GNUC_END_IGNORE_DEPRECATIONS;
2358 gboolean privateBrowsingEnabled = webView->priv->isEphemeral;
2360 webView->priv->authenticationRequest = adoptGRef(webkitAuthenticationRequestCreate(authenticationChallenge, privateBrowsingEnabled));
2361 gboolean returnValue;
2362 g_signal_emit(webView, signals[AUTHENTICATE], 0, webView->priv->authenticationRequest.get(), &returnValue);
2365 void webkitWebViewInsecureContentDetected(WebKitWebView* webView, WebKitInsecureContentEvent type)
2367 g_signal_emit(webView, signals[INSECURE_CONTENT_DETECTED], 0, type);
2370 bool webkitWebViewEmitShowNotification(WebKitWebView* webView, WebKitNotification* webNotification)
2373 g_signal_emit(webView, signals[SHOW_NOTIFICATION], 0, webNotification, &handled);
2378 bool webkitWebViewEmitRunColorChooser(WebKitWebView* webView, WebKitColorChooserRequest* request)
2381 g_signal_emit(webView, signals[RUN_COLOR_CHOOSER], 0, request, &handled);
2386 void webkitWebViewSelectionDidChange(WebKitWebView* webView)
2388 if (!webView->priv->editorState)
2391 webkitEditorStateChanged(webView->priv->editorState.get(), getPage(webView).editorState());
2394 void webkitWebViewRequestInstallMissingMediaPlugins(WebKitWebView* webView, InstallMissingMediaPluginsPermissionRequest& request)
2397 GRefPtr<WebKitInstallMissingMediaPluginsPermissionRequest> installMediaPluginsPermissionRequest = adoptGRef(webkitInstallMissingMediaPluginsPermissionRequestCreate(request));
2398 webkitWebViewMakePermissionRequest(webView, WEBKIT_PERMISSION_REQUEST(installMediaPluginsPermissionRequest.get()));
2400 ASSERT_NOT_REACHED();
2404 WebKitWebsiteDataManager* webkitWebViewGetWebsiteDataManager(WebKitWebView* webView)
2406 return webView->priv->websiteDataManager.get();
2410 bool webkitWebViewShowOptionMenu(WebKitWebView* webView, const IntRect& rect, WebKitOptionMenu* menu, const GdkEvent* event)
2412 GdkRectangle menuRect = rect;
2414 g_signal_emit(webView, signals[SHOW_OPTION_MENU], 0, menu, event, &menuRect, &handled);
2421 * webkit_web_view_get_backend:
2422 * @web_view: a #WebKitWebView
2424 * Get the #WebKitWebViewBackend of @web_view
2426 * Returns: (transfer none): the #WebKitWebViewBackend of @web_view
2430 WebKitWebViewBackend* webkit_web_view_get_backend(WebKitWebView* webView)
2432 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), nullptr);
2434 return webView->priv->backend.get();
2439 * webkit_web_view_get_context:
2440 * @web_view: a #WebKitWebView
2442 * Gets the web context of @web_view.
2444 * Returns: (transfer none): the #WebKitWebContext of the view
2446 WebKitWebContext* webkit_web_view_get_context(WebKitWebView *webView)
2448 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
2450 return webView->priv->context.get();
2454 * webkit_web_view_get_user_content_manager:
2455 * @web_view: a #WebKitWebView
2457 * Gets the user content manager associated to @web_view.
2459 * Returns: (transfer none): the #WebKitUserContentManager associated with the view
2463 WebKitUserContentManager* webkit_web_view_get_user_content_manager(WebKitWebView* webView)
2465 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), nullptr);
2467 return webView->priv->userContentManager.get();
2471 * webkit_web_view_is_ephemeral:
2472 * @web_view: a #WebKitWebView
2474 * Get whether a #WebKitWebView is ephemeral. To create an ephemeral #WebKitWebView you need to
2475 * use g_object_new() and pass is-ephemeral property with %TRUE value. See
2476 * #WebKitWebView:is-ephemeral for more details.
2477 * If @web_view was created with a ephemeral #WebKitWebView:related-view or an
2478 * ephemeral #WebKitWebView:web-context it will also be ephemeral.
2480 * Returns: %TRUE if @web_view is ephemeral or %FALSE otherwise.
2484 gboolean webkit_web_view_is_ephemeral(WebKitWebView* webView)
2486 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
2488 return webView->priv->isEphemeral;
2492 * webkit_web_view_is_controlled_by_automation:
2493 * @web_view: a #WebKitWebView
2495 * Get whether a #WebKitWebView was created with #WebKitWebView:is-controlled-by-automation
2496 * property enabled. Only #WebKitWebView<!-- -->s controlled by automation can be used in an
2497 * automation session.
2499 * Returns: %TRUE if @web_view is controlled by automation, or %FALSE otherwise.
2503 gboolean webkit_web_view_is_controlled_by_automation(WebKitWebView* webView)
2505 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
2507 return webView->priv->isControlledByAutomation;
2511 * webkit_web_view_get_website_data_manager:
2512 * @web_view: a #WebKitWebView
2514 * Get the #WebKitWebsiteDataManager associated to @web_view. If @web_view is not ephemeral,
2515 * the returned #WebKitWebsiteDataManager will be the same as the #WebKitWebsiteDataManager
2516 * of @web_view's #WebKitWebContext.
2518 * Returns: (transfer none): a #WebKitWebsiteDataManager
2522 WebKitWebsiteDataManager* webkit_web_view_get_website_data_manager(WebKitWebView* webView)
2524 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), nullptr);
2526 if (webView->priv->websiteDataManager)
2527 return webView->priv->websiteDataManager.get();
2529 return webkit_web_context_get_website_data_manager(webView->priv->context.get());
2533 * webkit_web_view_try_close:
2534 * @web_view: a #WebKitWebView
2536 * Tries to close the @web_view. This will fire the onbeforeunload event
2537 * to ask the user for confirmation to close the page. If there isn't an
2538 * onbeforeunload event handler or the user confirms to close the page,
2539 * the #WebKitWebView::close signal is emitted, otherwise nothing happens.
2543 void webkit_web_view_try_close(WebKitWebView *webView)
2545 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
2546 if (getPage(webView).tryClose())
2547 webkitWebViewClosePage(webView);
2551 * webkit_web_view_load_uri:
2552 * @web_view: a #WebKitWebView
2553 * @uri: an URI string
2555 * Requests loading of the specified URI string.
2556 * You can monitor the load operation by connecting to
2557 * #WebKitWebView::load-changed signal.
2559 void webkit_web_view_load_uri(WebKitWebView* webView, const gchar* uri)
2561 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
2562 g_return_if_fail(uri);
2564 GUniquePtr<SoupURI> soupURI(soup_uri_new(uri));
2565 getPage(webView).loadRequest(URL(soupURI.get()));
2569 * webkit_web_view_load_html:
2570 * @web_view: a #WebKitWebView
2571 * @content: The HTML string to load
2572 * @base_uri: (allow-none): The base URI for relative locations or %NULL
2574 * Load the given @content string with the specified @base_uri.
2575 * If @base_uri is not %NULL, relative URLs in the @content will be
2576 * resolved against @base_uri and absolute local paths must be children of the @base_uri.
2577 * For security reasons absolute local paths that are not children of @base_uri
2578 * will cause the web process to terminate.
2579 * If you need to include URLs in @content that are local paths in a different
2580 * directory than @base_uri you can build a data URI for them. When @base_uri is %NULL,
2581 * it defaults to "about:blank". The mime type of the document will be "text/html".
2582 * You can monitor the load operation by connecting to #WebKitWebView::load-changed signal.
2584 void webkit_web_view_load_html(WebKitWebView* webView, const gchar* content, const gchar* baseURI)
2586 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
2587 g_return_if_fail(content);
2589 getPage(webView).loadData({ reinterpret_cast<const uint8_t*>(content), content ? strlen(content) : 0 }, "text/html"_s, "UTF-8"_s, String::fromUTF8(baseURI));
2593 * webkit_web_view_load_alternate_html:
2594 * @web_view: a #WebKitWebView
2595 * @content: the new content to display as the main page of the @web_view
2596 * @content_uri: the URI for the alternate page content
2597 * @base_uri: (allow-none): the base URI for relative locations or %NULL
2599 * Load the given @content string for the URI @content_uri.
2600 * This allows clients to display page-loading errors in the #WebKitWebView itself.
2601 * When this method is called from #WebKitWebView::load-failed signal to show an
2602 * error page, then the back-forward list is maintained appropriately.
2603 * For everything else this method works the same way as webkit_web_view_load_html().
2605 void webkit_web_view_load_alternate_html(WebKitWebView* webView, const gchar* content, const gchar* contentURI, const gchar* baseURI)
2607 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
2608 g_return_if_fail(content);
2609 g_return_if_fail(contentURI);
2611 getPage(webView).loadAlternateHTML({ reinterpret_cast<const uint8_t*>(content), content ? strlen(content) : 0 }, "UTF-8"_s, URL(URL(), String::fromUTF8(baseURI)), URL(URL(), String::fromUTF8(contentURI)));
2615 * webkit_web_view_load_plain_text:
2616 * @web_view: a #WebKitWebView
2617 * @plain_text: The plain text to load
2619 * Load the specified @plain_text string into @web_view. The mime type of
2620 * document will be "text/plain". You can monitor the load
2621 * operation by connecting to #WebKitWebView::load-changed signal.
2623 void webkit_web_view_load_plain_text(WebKitWebView* webView, const gchar* plainText)
2625 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
2626 g_return_if_fail(plainText);
2628 getPage(webView).loadData({ reinterpret_cast<const uint8_t*>(plainText), plainText ? strlen(plainText) : 0 }, "text/plain"_s, "UTF-8"_s, blankURL().string());
2632 * webkit_web_view_load_bytes:
2633 * @web_view: a #WebKitWebView
2634 * @bytes: input data to load
2635 * @mime_type: (allow-none): the MIME type of @bytes, or %NULL
2636 * @encoding: (allow-none): the character encoding of @bytes, or %NULL
2637 * @base_uri: (allow-none): the base URI for relative locations or %NULL
2639 * Load the specified @bytes into @web_view using the given @mime_type and @encoding.
2640 * When @mime_type is %NULL, it defaults to "text/html".
2641 * When @encoding is %NULL, it defaults to "UTF-8".
2642 * When @base_uri is %NULL, it defaults to "about:blank".
2643 * You can monitor the load operation by connecting to #WebKitWebView::load-changed signal.
2647 void webkit_web_view_load_bytes(WebKitWebView* webView, GBytes* bytes, const char* mimeType, const char* encoding, const char* baseURI)
2649 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
2650 g_return_if_fail(bytes);
2652 gsize bytesDataSize;
2653 gconstpointer bytesData = g_bytes_get_data(bytes, &bytesDataSize);
2654 g_return_if_fail(bytesDataSize);
2656 getPage(webView).loadData({ reinterpret_cast<const uint8_t*>(bytesData), bytesDataSize }, mimeType ? String::fromUTF8(mimeType) : String::fromUTF8("text/html"),
2657 encoding ? String::fromUTF8(encoding) : String::fromUTF8("UTF-8"), String::fromUTF8(baseURI));
2661 * webkit_web_view_load_request:
2662 * @web_view: a #WebKitWebView
2663 * @request: a #WebKitURIRequest to load
2665 * Requests loading of the specified #WebKitURIRequest.
2666 * You can monitor the load operation by connecting to
2667 * #WebKitWebView::load-changed signal.
2669 void webkit_web_view_load_request(WebKitWebView* webView, WebKitURIRequest* request)
2671 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
2672 g_return_if_fail(WEBKIT_IS_URI_REQUEST(request));
2674 ResourceRequest resourceRequest;
2675 webkitURIRequestGetResourceRequest(request, resourceRequest);
2676 getPage(webView).loadRequest(WTFMove(resourceRequest));
2680 * webkit_web_view_get_page_id:
2681 * @web_view: a #WebKitWebView
2683 * Get the identifier of the #WebKitWebPage corresponding to
2684 * the #WebKitWebView
2686 * Returns: the page ID of @web_view.
2688 guint64 webkit_web_view_get_page_id(WebKitWebView* webView)
2690 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
2692 return getPage(webView).pageID();
2696 * webkit_web_view_get_title:
2697 * @web_view: a #WebKitWebView
2699 * Gets the value of the #WebKitWebView:title property.
2700 * You can connect to notify::title signal of @web_view to
2701 * be notified when the title has been received.
2703 * Returns: The main frame document title of @web_view.
2705 const gchar* webkit_web_view_get_title(WebKitWebView* webView)
2707 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
2709 return webView->priv->title.data();
2713 * webkit_web_view_reload:
2714 * @web_view: a #WebKitWebView
2716 * Reloads the current contents of @web_view.
2717 * See also webkit_web_view_reload_bypass_cache().
2719 void webkit_web_view_reload(WebKitWebView* webView)
2721 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
2723 getPage(webView).reload({ });
2727 * webkit_web_view_reload_bypass_cache:
2728 * @web_view: a #WebKitWebView
2730 * Reloads the current contents of @web_view without
2731 * using any cached data.
2733 void webkit_web_view_reload_bypass_cache(WebKitWebView* webView)
2735 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
2737 getPage(webView).reload(ReloadOption::FromOrigin);
2741 * webkit_web_view_stop_loading:
2742 * @web_view: a #WebKitWebView
2744 * Stops any ongoing loading operation in @web_view.
2745 * This method does nothing if no content is being loaded.
2746 * If there is a loading operation in progress, it will be cancelled and
2747 * #WebKitWebView::load-failed signal will be emitted with
2748 * %WEBKIT_NETWORK_ERROR_CANCELLED error.
2750 void webkit_web_view_stop_loading(WebKitWebView* webView)
2752 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
2754 getPage(webView).stopLoading();
2758 * webkit_web_view_is_loading:
2759 * @web_view: a #WebKitWebView
2761 * Gets the value of the #WebKitWebView:is-loading property.
2762 * You can monitor when a #WebKitWebView is loading a page by connecting to
2763 * notify::is-loading signal of @web_view. This is useful when you are
2764 * interesting in knowing when the view is loading something but not in the
2765 * details about the status of the load operation, for example to start a spinner
2766 * when the view is loading a page and stop it when it finishes.
2768 * Returns: %TRUE if @web_view is loading a page or %FALSE otherwise.
2770 gboolean webkit_web_view_is_loading(WebKitWebView* webView)
2772 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
2774 return webView->priv->isLoading;
2778 * webkit_web_view_is_playing_audio:
2779 * @web_view: a #WebKitWebView
2781 * Gets the value of the #WebKitWebView:is-playing-audio property.
2782 * You can monitor when a page in a #WebKitWebView is playing audio by
2783 * connecting to the notify::is-playing-audio signal of @web_view. This
2784 * is useful when the application wants to provide visual feedback when a
2785 * page is producing sound.
2787 * Returns: %TRUE if a page in @web_view is playing audio or %FALSE otherwise.
2791 gboolean webkit_web_view_is_playing_audio(WebKitWebView* webView)
2793 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
2795 return getPage(webView).isPlayingAudio();
2799 * webkit_web_view_go_back:
2800 * @web_view: a #WebKitWebView
2802 * Loads the previous history item.
2803 * You can monitor the load operation by connecting to
2804 * #WebKitWebView::load-changed signal.
2806 void webkit_web_view_go_back(WebKitWebView* webView)
2808 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
2810 getPage(webView).goBack();
2814 * webkit_web_view_can_go_back:
2815 * @web_view: a #WebKitWebView
2817 * Determines whether @web_view has a previous history item.
2819 * Returns: %TRUE if able to move back or %FALSE otherwise.
2821 gboolean webkit_web_view_can_go_back(WebKitWebView* webView)
2823 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
2825 return !!getPage(webView).backForwardList().backItem();
2829 * webkit_web_view_go_forward:
2830 * @web_view: a #WebKitWebView
2832 * Loads the next history item.
2833 * You can monitor the load operation by connecting to
2834 * #WebKitWebView::load-changed signal.
2836 void webkit_web_view_go_forward(WebKitWebView* webView)
2838 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
2840 getPage(webView).goForward();
2844 * webkit_web_view_can_go_forward:
2845 * @web_view: a #WebKitWebView
2847 * Determines whether @web_view has a next history item.
2849 * Returns: %TRUE if able to move forward or %FALSE otherwise.
2851 gboolean webkit_web_view_can_go_forward(WebKitWebView* webView)
2853 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
2855 return !!getPage(webView).backForwardList().forwardItem();
2859 * webkit_web_view_get_uri:
2860 * @web_view: a #WebKitWebView
2862 * Returns the current active URI of @web_view. The active URI might change during
2867 * When nothing has been loaded yet on @web_view the active URI is %NULL.
2868 * </para></listitem>
2870 * When a new load operation starts the active URI is the requested URI:
2873 * If the load operation was started by webkit_web_view_load_uri(),
2874 * the requested URI is the given one.
2875 * </para></listitem>
2877 * If the load operation was started by webkit_web_view_load_html(),
2878 * the requested URI is "about:blank".
2879 * </para></listitem>
2881 * If the load operation was started by webkit_web_view_load_alternate_html(),
2882 * the requested URI is content URI provided.
2883 * </para></listitem>
2885 * If the load operation was started by webkit_web_view_go_back() or
2886 * webkit_web_view_go_forward(), the requested URI is the original URI
2887 * of the previous/next item in the #WebKitBackForwardList of @web_view.
2888 * </para></listitem>
2890 * If the load operation was started by
2891 * webkit_web_view_go_to_back_forward_list_item(), the requested URI
2892 * is the opriginal URI of the given #WebKitBackForwardListItem.
2893 * </para></listitem>
2895 * </para></listitem>
2897 * If there is a server redirection during the load operation,
2898 * the active URI is the redirected URI. When the signal
2899 * #WebKitWebView::load-changed is emitted with %WEBKIT_LOAD_REDIRECTED
2900 * event, the active URI is already updated to the redirected URI.
2901 * </para></listitem>
2903 * When the signal #WebKitWebView::load-changed is emitted
2904 * with %WEBKIT_LOAD_COMMITTED event, the active URI is the final
2905 * one and it will not change unless a new load operation is started
2906 * or a navigation action within the same page is performed.
2907 * </para></listitem>
2910 * You can monitor the active URI by connecting to the notify::uri
2911 * signal of @web_view.
2913 * Returns: the current active URI of @web_view or %NULL
2914 * if nothing has been loaded yet.
2916 const gchar* webkit_web_view_get_uri(WebKitWebView* webView)
2918 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
2920 return webView->priv->activeURI.data();
2925 * webkit_web_view_get_favicon:
2926 * @web_view: a #WebKitWebView
2928 * Returns favicon currently associated to @web_view, if any. You can
2929 * connect to notify::favicon signal of @web_view to be notified when
2930 * the favicon is available.
2932 * Returns: (transfer none): a pointer to a #cairo_surface_t with the
2933 * favicon or %NULL if there's no icon associated with @web_view.
2935 cairo_surface_t* webkit_web_view_get_favicon(WebKitWebView* webView)
2937 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
2938 if (webView->priv->activeURI.isNull())
2941 return webView->priv->favicon.get();
2946 * webkit_web_view_get_custom_charset:
2947 * @web_view: a #WebKitWebView
2949 * Returns the current custom character encoding name of @web_view.
2951 * Returns: the current custom character encoding name or %NULL if no
2952 * custom character encoding has been set.
2954 const gchar* webkit_web_view_get_custom_charset(WebKitWebView* webView)
2956 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
2958 String customTextEncoding = getPage(webView).customTextEncodingName();
2959 if (customTextEncoding.isEmpty())
2962 webView->priv->customTextEncoding = customTextEncoding.utf8();
2963 return webView->priv->customTextEncoding.data();
2967 * webkit_web_view_set_custom_charset:
2968 * @web_view: a #WebKitWebView
2969 * @charset: (allow-none): a character encoding name or %NULL
2971 * Sets the current custom character encoding override of @web_view. The custom
2972 * character encoding will override any text encoding detected via HTTP headers or
2973 * META tags. Calling this method will stop any current load operation and reload the
2974 * current page. Setting the custom character encoding to %NULL removes the character
2975 * encoding override.
2977 void webkit_web_view_set_custom_charset(WebKitWebView* webView, const gchar* charset)
2979 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
2981 getPage(webView).setCustomTextEncodingName(String::fromUTF8(charset));
2985 * webkit_web_view_get_estimated_load_progress:
2986 * @web_view: a #WebKitWebView
2988 * Gets the value of the #WebKitWebView:estimated-load-progress property.
2989 * You can monitor the estimated progress of a load operation by
2990 * connecting to the notify::estimated-load-progress signal of @web_view.
2992 * Returns: an estimate of the of the percent complete for a document
2993 * load as a range from 0.0 to 1.0.
2995 gdouble webkit_web_view_get_estimated_load_progress(WebKitWebView* webView)
2997 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
2998 return getPage(webView).pageLoadState().estimatedProgress();
3002 * webkit_web_view_get_back_forward_list:
3003 * @web_view: a #WebKitWebView
3005 * Obtains the #WebKitBackForwardList associated with the given #WebKitWebView. The
3006 * #WebKitBackForwardList is owned by the #WebKitWebView.
3008 * Returns: (transfer none): the #WebKitBackForwardList
3010 WebKitBackForwardList* webkit_web_view_get_back_forward_list(WebKitWebView* webView)
3012 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
3014 return webView->priv->backForwardList.get();
3018 * webkit_web_view_go_to_back_forward_list_item:
3019 * @web_view: a #WebKitWebView
3020 * @list_item: a #WebKitBackForwardListItem
3022 * Loads the specific history item @list_item.
3023 * You can monitor the load operation by connecting to
3024 * #WebKitWebView::load-changed signal.
3026 void webkit_web_view_go_to_back_forward_list_item(WebKitWebView* webView, WebKitBackForwardListItem* listItem)
3028 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
3029 g_return_if_fail(WEBKIT_IS_BACK_FORWARD_LIST_ITEM(listItem));
3031 getPage(webView).goToBackForwardItem(*webkitBackForwardListItemGetItem(listItem));
3035 * webkit_web_view_set_settings:
3036 * @web_view: a #WebKitWebView
3037 * @settings: a #WebKitSettings
3039 * Sets the #WebKitSettings to be applied to @web_view. The
3040 * existing #WebKitSettings of @web_view will be replaced by
3041 * @settings. New settings are applied immediately on @web_view.
3042 * The same #WebKitSettings object can be shared
3043 * by multiple #WebKitWebView<!-- -->s.
3045 void webkit_web_view_set_settings(WebKitWebView* webView, WebKitSettings* settings)
3047 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
3048 g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
3050 if (webView->priv->settings == settings)
3053 // The "settings" property is set on construction, and in that
3054 // case webkit_web_view_set_settings() will be called *before*
3055 // any settings have been assigned. In that case there are no
3056 // signal handlers to disconnect.
3057 if (webView->priv->settings)
3058 webkitWebViewDisconnectSettingsSignalHandlers(webView);
3060 webView->priv->settings = settings;
3061 webkitWebViewUpdateSettings(webView);
3062 g_object_notify(G_OBJECT(webView), "settings");
3066 * webkit_web_view_get_settings:
3067 * @web_view: a #WebKitWebView
3069 * Gets the #WebKitSettings currently applied to @web_view.
3070 * If no other #WebKitSettings have been explicitly applied to
3071 * @web_view with webkit_web_view_set_settings(), the default
3072 * #WebKitSettings will be returned. This method always returns
3073 * a valid #WebKitSettings object.
3074 * To modify any of the @web_view settings, you can either create
3075 * a new #WebKitSettings object with webkit_settings_new(), setting
3076 * the desired preferences, and then replace the existing @web_view
3077 * settings with webkit_web_view_set_settings() or get the existing
3078 * @web_view settings and update it directly. #WebKitSettings objects
3079 * can be shared by multiple #WebKitWebView<!-- -->s, so modifying
3080 * the settings of a #WebKitWebView would affect other
3081 * #WebKitWebView<!-- -->s using the same #WebKitSettings.
3083 * Returns: (transfer none): the #WebKitSettings attached to @web_view
3085 WebKitSettings* webkit_web_view_get_settings(WebKitWebView* webView)
3087 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), nullptr);
3088 return webView->priv->settings.get();
3092 * webkit_web_view_get_window_properties:
3093 * @web_view: a #WebKitWebView
3095 * Get the #WebKitWindowProperties object containing the properties
3096 * that the window containing @web_view should have.
3098 * Returns: (transfer none): the #WebKitWindowProperties of @web_view
3100 WebKitWindowProperties* webkit_web_view_get_window_properties(WebKitWebView* webView)
3102 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
3104 return webView->priv->windowProperties.get();
3108 * webkit_web_view_set_zoom_level:
3109 * @web_view: a #WebKitWebView
3110 * @zoom_level: the zoom level
3112 * Set the zoom level of @web_view, i.e. the factor by which the
3113 * view contents are scaled with respect to their original size.
3115 void webkit_web_view_set_zoom_level(WebKitWebView* webView, gdouble zoomLevel)
3117 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
3119 if (webkit_web_view_get_zoom_level(webView) == zoomLevel)
3122 auto& page = getPage(webView);
3123 page.scalePage(1.0, IntPoint()); // Reset page scale when zoom level is changed
3124 if (webkit_settings_get_zoom_text_only(webView->priv->settings.get()))
3125 page.setTextZoomFactor(zoomLevel);
3127 page.setPageZoomFactor(zoomLevel);
3128 g_object_notify(G_OBJECT(webView), "zoom-level");
3132 * webkit_web_view_get_zoom_level:
3133 * @web_view: a #WebKitWebView
3135 * Get the zoom level of @web_view, i.e. the factor by which the
3136 * view contents are scaled with respect to their original size.
3138 * Returns: the current zoom level of @web_view
3140 gdouble webkit_web_view_get_zoom_level(WebKitWebView* webView)
3142 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 1);
3144 auto& page = getPage(webView);
3145 gboolean zoomTextOnly = webkit_settings_get_zoom_text_only(webView->priv->settings.get());
3146 return zoomTextOnly ? page.textZoomFactor() : page.pageZoomFactor();
3150 * webkit_web_view_can_execute_editing_command:
3151 * @web_view: a #WebKitWebView
3152 * @command: the command to check
3153 * @cancellable: (allow-none): a #GCancellable or %NULL to ignore
3154 * @callback: (scope async): a #GAsyncReadyCallback to call when the request is satisfied
3155 * @user_data: (closure): the data to pass to callback function
3157 * Asynchronously check if it is possible to execute the given editing command.
3159 * When the operation is finished, @callback will be called. You can then call
3160 * webkit_web_view_can_execute_editing_command_finish() to get the result of the operation.
3162 void webkit_web_view_can_execute_editing_command(WebKitWebView* webView, const char* command, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData)
3164 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
3165 g_return_if_fail(command);
3167 GRefPtr<GTask> task = adoptGRef(g_task_new(webView, cancellable, callback, userData));
3168 getPage(webView).validateCommand(String::fromUTF8(command), [task = WTFMove(task)](const String&, bool isEnabled, int32_t, WebKit::CallbackBase::Error) {
3169 g_task_return_boolean(task.get(), isEnabled);
3174 * webkit_web_view_can_execute_editing_command_finish:
3175 * @web_view: a #WebKitWebView
3176 * @result: a #GAsyncResult
3177 * @error: return location for error or %NULL to ignore
3179 * Finish an asynchronous operation started with webkit_web_view_can_execute_editing_command().
3181 * Returns: %TRUE if the editing command can be executed or %FALSE otherwise
3183 gboolean webkit_web_view_can_execute_editing_command_finish(WebKitWebView* webView, GAsyncResult* result, GError** error)
3185 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), FALSE);
3186 g_return_val_if_fail(g_task_is_valid(result, webView), FALSE);
3188 return g_task_propagate_boolean(G_TASK(result), error);
3192 * webkit_web_view_execute_editing_command:
3193 * @web_view: a #WebKitWebView
3194 * @command: the command to execute
3196 * Request to execute the given @command for @web_view. You can use
3197 * webkit_web_view_can_execute_editing_command() to check whether
3198 * it's possible to execute the command.
3200 void webkit_web_view_execute_editing_command(WebKitWebView* webView, const char* command)
3202 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
3203 g_return_if_fail(command);
3205 getPage(webView).executeEditCommand(String::fromUTF8(command));
3209 * webkit_web_view_execute_editing_command_with_argument:
3210 * @web_view: a #WebKitWebView
3211 * @command: the command to execute
3212 * @argument: the command argument
3214 * Request to execute the given @command with @argument for @web_view. You can use
3215 * webkit_web_view_can_execute_editing_command() to check whether
3216 * it's possible to execute the command.
3220 void webkit_web_view_execute_editing_command_with_argument(WebKitWebView* webView, const char* command, const char* argument)
3222 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
3223 g_return_if_fail(command);
3224 g_return_if_fail(argument);
3226 getPage(webView).executeEditCommand(String::fromUTF8(command), String::fromUTF8(argument));
3230 * webkit_web_view_get_find_controller:
3231 * @web_view: the #WebKitWebView
3233 * Gets the #WebKitFindController that will allow the caller to query
3234 * the #WebKitWebView for the text to look for.
3236 * Returns: (transfer none): the #WebKitFindController associated to
3237 * this particular #WebKitWebView.
3239 WebKitFindController* webkit_web_view_get_find_controller(WebKitWebView* webView)
3241 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), 0);
3243 if (!webView->priv->findController)
3244 webView->priv->findController = adoptGRef(WEBKIT_FIND_CONTROLLER(g_object_new(WEBKIT_TYPE_FIND_CONTROLLER, "web-view", webView, NULL)));
3246 return webView->priv->findController.get();
3251 * webkit_web_view_get_javascript_global_context: (skip)
3252 * @web_view: a #WebKitWebView
3254 * Get the global JavaScript context used by @web_view to deserialize the
3255 * result values of scripts executed with webkit_web_view_run_javascript().
3257 * Returns: the <function>JSGlobalContextRef</function> used by @web_view to deserialize
3258 * the result values of scripts.
3260 * Deprecated: 2.22: Use jsc_value_get_context() instead.
3262 JSGlobalContextRef webkit_web_view_get_javascript_global_context(WebKitWebView* webView)
3264 g_return_val_if_fail(WEBKIT_IS_WEB_VIEW(webView), nullptr);
3266 // We keep a reference to the js context in the view only when this method is called
3267 // for backwards compatibility.
3268 if (!webView->priv->jsContext)
3269 webView->priv->jsContext = SharedJavascriptContext::singleton().getOrCreateContext();
3270 return jscContextGetJSContext(webView->priv->jsContext.get());
3274 static void webkitWebViewRunJavaScriptCallback(API::SerializedScriptValue* wkSerializedScriptValue, const ExceptionDetails& exceptionDetails, GTask* task)
3276 if (g_task_return_error_if_cancelled(task))
3279 if (!wkSerializedScriptValue) {
3280 StringBuilder builder;
3281 if (!exceptionDetails.sourceURL.isEmpty()) {
3282 builder.append(exceptionDetails.sourceURL);
3283 if (exceptionDetails.lineNumber > 0) {
3284 builder.append(':');
3285 builder.appendNumber(exceptionDetails.lineNumber);
3287 if (exceptionDetails.columnNumber > 0) {
3288 builder.append(':');
3289 builder.appendNumber(exceptionDetails.columnNumber);
3291 builder.appendLiteral(": ");
3293 builder.append(exceptionDetails.message);
3294 g_task_return_new_error(task, WEBKIT_JAVASCRIPT_ERROR, WEBKIT_JAVASCRIPT_ERROR_SCRIPT_FAILED,
3295 "%s", builder.toString().utf8().data());
3299 g_task_return_pointer(task, webkitJavascriptResultCreate(wkSerializedScriptValue->internalRepresentation()),
3300 reinterpret_cast<GDestroyNotify>(webkit_javascript_result_unref));
3304 * webkit_web_view_run_javascript:
3305 * @web_view: a #WebKitWebView
3306 * @script: the script to run
3307 * @cancellable: (allow-none): a #GCancellable or %NULL to ignore
3308 * @callback: (scope async): a #GAsyncReadyCallback to call when the script finished
3309 * @user_data: (closure): the data to pass to callback function
3311 * Asynchronously run @script in the context of the current page in @web_view. If
3312 * WebKitSettings:enable-javascript is FALSE, this method will do nothing.
3314 * When the operation is finished, @callback will be called. You can then call
3315 * webkit_web_view_run_javascript_finish() to get the result of the operation.
3317 void webkit_web_view_run_javascript(WebKitWebView* webView, const gchar* script, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer userData)
3319 g_return_if_fail(WEBKIT_IS_WEB_VIEW(webView));
3320 g_return_if_fail(script);
3322 GRefPtr<GTask> task = adoptGRef(g_task_new(webView, cancellable, callback, userData));
3323 getPage(webView).runJavaScriptInMainFrame(String::fromUTF8(script), true, [task = WTFMove(task)](API::SerializedScriptValue* serializedScriptValue, bool, const ExceptionDetails& exceptionDetails, WebKit::CallbackBase::Error) {
3324 webkitWebViewRunJavaScriptCallback(serializedScriptValue, exceptionDetails, task.get());
3329 * webkit_web_view_run_javascript_finish:
3330 * @web_view: a #WebKitWebView
3331 * @result: a #GAsyncResult
3332 * @error: return location for error or %NULL to ignore