@@ -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,8 @@ 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));
422425 default :
423426 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propId, paramSpec);
424427 break ;
@@ -633,6 +636,8 @@ ALLOW_DEPRECATED_DECLARATIONS_BEGIN
633636 case PROP_WEBRTC_UDP_PORTS_RANGE:
634637 g_value_set_string (value, webkit_settings_get_webrtc_udp_ports_range (settings));
635638 break ;
639+ case PROP_ALLOW_SCRIPTS_TO_CLOSE_WINDOWS:
640+ g_value_set_boolean (value, webkit_settings_get_allow_scripts_to_close_windows (settings));
636641 default :
637642 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, propId, paramSpec);
638643 break ;
@@ -1715,6 +1720,19 @@ static void webkit_settings_class_init(WebKitSettingsClass* klass)
17151720 nullptr , // A null string forces the default value.
17161721 readWriteConstructParamFlags);
17171722
1723+ /* *
1724+ * WebKitSettings:allow-scripts-to-close-windows:
1725+ *
1726+ * Allow scripts to close windows they didn't open.
1727+ *
1728+ */
1729+ sObjProperties [PROP_ALLOW_SCRIPTS_TO_CLOSE_WINDOWS] = g_param_spec_boolean (
1730+ " allow-scripts-to-close-windows" ,
1731+ _ (" Allow scripts to close windows" ),
1732+ _ (" Whether scripts can close windows they didn't open." ),
1733+ FALSE ,
1734+ readWriteConstructParamFlags);
1735+
17181736 g_object_class_install_properties (gObjectClass , N_PROPERTIES, sObjProperties .data ());
17191737}
17201738
@@ -4438,3 +4456,39 @@ webkit_settings_set_webrtc_udp_ports_range(WebKitSettings* settings, const gchar
44384456 UNUSED_PARAM (udpPortsRange);
44394457#endif
44404458}
4459+
4460+ /* *
4461+ * webkit_settings_get_allow_scripts_to_close_windows:
4462+ * @settings: a #WebKitSettings
4463+ *
4464+ * Get the #WebKitSettings:allow-scripts-to-close-windows property.
4465+ *
4466+ * Returns: %TRUE If script can close windows not opened by them or %FALSE otherwise.
4467+ */
4468+ gboolean webkit_settings_get_allow_scripts_to_close_windows (WebKitSettings *settings)
4469+ {
4470+ g_return_val_if_fail (WEBKIT_IS_SETTINGS (settings), FALSE );
4471+
4472+ return settings->priv ->preferences ->allowScriptsToCloseWindows ();
4473+ }
4474+
4475+ /* *
4476+ * webkit_settings_set_allow_scripts_to_close_windows
4477+ * @settings: a #WebKitSettings
4478+ * @allowed: Value to be set
4479+ *
4480+ * Set the #WebKitSettings:allow-scripts-to-close-windows property.
4481+ */
4482+ WEBKIT_API void
4483+ webkit_settings_set_allow_scripts_to_close_windows (WebKitSettings *settings, gboolean allowed)
4484+ {
4485+ g_return_if_fail (WEBKIT_IS_SETTINGS (settings));
4486+
4487+ WebKitSettingsPrivate* priv = settings->priv ;
4488+ bool currentValue = priv->preferences ->allowScriptsToCloseWindows ();
4489+ if (currentValue == allowed)
4490+ return ;
4491+
4492+ priv->preferences ->setAllowScriptsToCloseWindows (allowed);
4493+ g_object_notify (G_OBJECT (settings), " allow-scripts-to-close-windows" );
4494+ }
0 commit comments