Skip to content

Commit fb00101

Browse files
magomezpgorszkowski-igalia
authored andcommitted
Add setting to enable/disable directory upload
1 parent 7508775 commit fb00101

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

Source/WebKit/UIProcess/API/glib/WebKitSettings.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ enum {
175175
PROP_ENABLE_WEBRTC,
176176
PROP_DISABLE_WEB_SECURITY,
177177
PROP_ALLOW_SCRIPTS_TO_CLOSE_WINDOWS,
178+
PROP_ENABLE_DIRECTORY_UPLOAD,
178179
N_PROPERTIES,
179180
};
180181

@@ -413,6 +414,9 @@ ALLOW_DEPRECATED_DECLARATIONS_BEGIN
413414
case PROP_ALLOW_SCRIPTS_TO_CLOSE_WINDOWS:
414415
webkit_settings_set_allow_scripts_to_close_windows(settings, g_value_get_boolean(value));
415416
break;
417+
case PROP_ENABLE_DIRECTORY_UPLOAD:
418+
webkit_settings_set_enable_directory_upload(settings, g_value_get_boolean(value));
419+
break;
416420
default:
417421
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
418422
break;
@@ -624,6 +628,9 @@ ALLOW_DEPRECATED_DECLARATIONS_BEGIN
624628
case PROP_ALLOW_SCRIPTS_TO_CLOSE_WINDOWS:
625629
g_value_set_boolean(value, webkit_settings_get_allow_scripts_to_close_windows(settings));
626630
break;
631+
case PROP_ENABLE_DIRECTORY_UPLOAD:
632+
g_value_set_boolean(value, webkit_settings_get_enable_directory_upload(settings));
633+
break;
627634
default:
628635
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
629636
break;
@@ -1638,6 +1645,19 @@ static void webkit_settings_class_init(WebKitSettingsClass* klass)
16381645
FALSE,
16391646
readWriteConstructParamFlags);
16401647

1648+
/**
1649+
* WebKitSettings:enable-directory-upload:
1650+
*
1651+
* Enable or disable directory upload.
1652+
*
1653+
*/
1654+
sObjProperties[PROP_ENABLE_DIRECTORY_UPLOAD] = g_param_spec_boolean(
1655+
"enable-directory-upload",
1656+
_("Enable directory upload"),
1657+
_("Whether directory upload should be enabled."),
1658+
TRUE,
1659+
readWriteConstructParamFlags);
1660+
16411661
g_object_class_install_properties(gObjectClass, N_PROPERTIES, sObjProperties);
16421662
}
16431663

@@ -4187,3 +4207,38 @@ webkit_settings_set_allow_scripts_to_close_windows(WebKitSettings *settings, gbo
41874207
priv->preferences->setAllowScriptsToCloseWindows(allowed);
41884208
g_object_notify(G_OBJECT(settings), "allow-scripts-to-close-windows");
41894209
}
4210+
4211+
/**
4212+
* webkit_settings_get_enable_directory_upload:
4213+
* @settings: a #WebKitSettings
4214+
*
4215+
* Get the #WebKitSettings:enable-directory-upload property.
4216+
*
4217+
* Returns: %TRUE If Directory Upload is enabled or %FALSE otherwise.
4218+
*/
4219+
gboolean webkit_settings_get_enable_directory_upload(WebKitSettings* settings)
4220+
{
4221+
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
4222+
4223+
return settings->priv->preferences->directoryUploadEnabled();
4224+
}
4225+
4226+
/**
4227+
* webkit_settings_set_enable_directory_upload:
4228+
* @settings: a #WebKitSettings
4229+
* @enabled: Value to be set
4230+
*
4231+
* Set the #WebKitSettings:enable-directory-upload property.
4232+
*/
4233+
void webkit_settings_set_enable_directory_upload(WebKitSettings* settings, gboolean enabled)
4234+
{
4235+
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
4236+
4237+
WebKitSettingsPrivate* priv = settings->priv;
4238+
bool currentValue = priv->preferences->directoryUploadEnabled();
4239+
if (currentValue == enabled)
4240+
return;
4241+
4242+
priv->preferences->setDirectoryUploadEnabled(enabled);
4243+
g_object_notify(G_OBJECT(settings), "enable-directory-upload");
4244+
}

Source/WebKit/UIProcess/API/glib/WebKitSettings.h.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,13 @@ WEBKIT_API void
569569
webkit_settings_set_allow_scripts_to_close_windows (WebKitSettings *settings,
570570
gboolean allowed);
571571

572+
WEBKIT_API gboolean
573+
webkit_settings_get_enable_directory_upload (WebKitSettings *settings);
574+
575+
WEBKIT_API void
576+
webkit_settings_set_enable_directory_upload (WebKitSettings *settings,
577+
gboolean enabled);
578+
572579
G_END_DECLS
573580

574581
#endif /* WebKitSettings_h */

0 commit comments

Comments
 (0)