@@ -189,6 +189,7 @@ enum {
189189 PROP_ENABLE_WEBRTC,
190190 PROP_DISABLE_WEB_SECURITY,
191191 PROP_WEBRTC_UDP_PORTS_RANGE,
192+ PROP_ALLOW_SCRIPTS_TO_CLOSE_WINDOWS,
192193 N_PROPERTIES,
193194};
194195
@@ -419,6 +420,9 @@ ALLOW_DEPRECATED_DECLARATIONS_BEGIN
419420 case PROP_WEBRTC_UDP_PORTS_RANGE:
420421 webkit_settings_set_webrtc_udp_ports_range (settings, g_value_get_string (value));
421422 break ;
423+ case PROP_ALLOW_SCRIPTS_TO_CLOSE_WINDOWS:
424+ webkit_settings_set_allow_scripts_to_close_windows (settings, g_value_get_boolean (value));
425+ break ;
422426 default :
423427 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propId, paramSpec);
424428 break ;
@@ -633,6 +637,9 @@ ALLOW_DEPRECATED_DECLARATIONS_BEGIN
633637 case PROP_WEBRTC_UDP_PORTS_RANGE:
634638 g_value_set_string (value, webkit_settings_get_webrtc_udp_ports_range (settings));
635639 break ;
640+ case PROP_ALLOW_SCRIPTS_TO_CLOSE_WINDOWS:
641+ g_value_set_boolean (value, webkit_settings_get_allow_scripts_to_close_windows (settings));
642+ break ;
636643 default :
637644 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propId, paramSpec);
638645 break ;
@@ -1715,6 +1722,19 @@ static void webkit_settings_class_init(WebKitSettingsClass* klass)
17151722 nullptr , // A null string forces the default value.
17161723 readWriteConstructParamFlags);
17171724
1725+ /* *
1726+ * WebKitSettings:allow-scripts-to-close-windows:
1727+ *
1728+ * Allow scripts to close windows they didn't open.
1729+ *
1730+ */
1731+ sObjProperties [PROP_ALLOW_SCRIPTS_TO_CLOSE_WINDOWS] = g_param_spec_boolean (
1732+ " allow-scripts-to-close-windows" ,
1733+ _ (" Allow scripts to close windows" ),
1734+ _ (" Whether scripts can close windows they didn't open." ),
1735+ FALSE ,
1736+ readWriteConstructParamFlags);
1737+
17181738 g_object_class_install_properties (gObjectClass , N_PROPERTIES, sObjProperties .data ());
17191739}
17201740
@@ -4438,3 +4458,39 @@ webkit_settings_set_webrtc_udp_ports_range(WebKitSettings* settings, const gchar
44384458 UNUSED_PARAM (udpPortsRange);
44394459#endif
44404460}
4461+
4462+ /* *
4463+ * webkit_settings_get_allow_scripts_to_close_windows:
4464+ * @settings: a #WebKitSettings
4465+ *
4466+ * Get the #WebKitSettings:allow-scripts-to-close-windows property.
4467+ *
4468+ * Returns: %TRUE If script can close windows not opened by them or %FALSE otherwise.
4469+ */
4470+ gboolean webkit_settings_get_allow_scripts_to_close_windows (WebKitSettings *settings)
4471+ {
4472+ g_return_val_if_fail (WEBKIT_IS_SETTINGS (settings), FALSE );
4473+
4474+ return settings->priv ->preferences ->allowScriptsToCloseWindows ();
4475+ }
4476+
4477+ /* *
4478+ * webkit_settings_set_allow_scripts_to_close_windows
4479+ * @settings: a #WebKitSettings
4480+ * @allowed: Value to be set
4481+ *
4482+ * Set the #WebKitSettings:allow-scripts-to-close-windows property.
4483+ */
4484+ WEBKIT_API void
4485+ webkit_settings_set_allow_scripts_to_close_windows (WebKitSettings *settings, gboolean allowed)
4486+ {
4487+ g_return_if_fail (WEBKIT_IS_SETTINGS (settings));
4488+
4489+ WebKitSettingsPrivate* priv = settings->priv ;
4490+ bool currentValue = priv->preferences ->allowScriptsToCloseWindows ();
4491+ if (currentValue == allowed)
4492+ return ;
4493+
4494+ priv->preferences ->setAllowScriptsToCloseWindows (allowed);
4495+ g_object_notify (G_OBJECT (settings), " allow-scripts-to-close-windows" );
4496+ }
0 commit comments