Skip to content

Commit 7a2e741

Browse files
Add provision to allow insecure content
1 parent fb00101 commit 7a2e741

2 files changed

Lines changed: 122 additions & 0 deletions

File tree

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

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ enum {
174174
PROP_MEDIA_CONTENT_TYPES_REQUIRING_HARDWARE_SUPPORT,
175175
PROP_ENABLE_WEBRTC,
176176
PROP_DISABLE_WEB_SECURITY,
177+
PROP_ALLOW_RUNNING_OF_INSECURE_CONTENT,
178+
PROP_ALLOW_DISPLAY_OF_INSECURE_CONTENT,
177179
PROP_ALLOW_SCRIPTS_TO_CLOSE_WINDOWS,
178180
PROP_ENABLE_DIRECTORY_UPLOAD,
179181
N_PROPERTIES,
@@ -411,6 +413,12 @@ ALLOW_DEPRECATED_DECLARATIONS_BEGIN
411413
case PROP_DISABLE_WEB_SECURITY:
412414
webkit_settings_set_disable_web_security(settings, g_value_get_boolean(value));
413415
break;
416+
case PROP_ALLOW_RUNNING_OF_INSECURE_CONTENT:
417+
webkit_settings_set_allow_running_of_insecure_content(settings, g_value_get_boolean(value));
418+
break;
419+
case PROP_ALLOW_DISPLAY_OF_INSECURE_CONTENT:
420+
webkit_settings_set_allow_display_of_insecure_content(settings, g_value_get_boolean(value));
421+
break;
414422
case PROP_ALLOW_SCRIPTS_TO_CLOSE_WINDOWS:
415423
webkit_settings_set_allow_scripts_to_close_windows(settings, g_value_get_boolean(value));
416424
break;
@@ -625,6 +633,12 @@ ALLOW_DEPRECATED_DECLARATIONS_BEGIN
625633
case PROP_DISABLE_WEB_SECURITY:
626634
g_value_set_boolean(value, webkit_settings_get_disable_web_security(settings));
627635
break;
636+
case PROP_ALLOW_RUNNING_OF_INSECURE_CONTENT:
637+
g_value_set_boolean(value, webkit_settings_get_allow_running_of_insecure_content(settings));
638+
break;
639+
case PROP_ALLOW_DISPLAY_OF_INSECURE_CONTENT:
640+
g_value_set_boolean(value, webkit_settings_get_allow_display_of_insecure_content(settings));
641+
break;
628642
case PROP_ALLOW_SCRIPTS_TO_CLOSE_WINDOWS:
629643
g_value_set_boolean(value, webkit_settings_get_allow_scripts_to_close_windows(settings));
630644
break;
@@ -1632,6 +1646,30 @@ static void webkit_settings_class_init(WebKitSettingsClass* klass)
16321646
FALSE,
16331647
readWriteConstructParamFlags);
16341648

1649+
/**
1650+
* WebKitSettings:allow-running-of-insecure-content:
1651+
*
1652+
* Allow running of insecure content on pages
1653+
*/
1654+
sObjProperties[PROP_ALLOW_RUNNING_OF_INSECURE_CONTENT] = g_param_spec_boolean(
1655+
"allow-running-of-insecure-content",
1656+
_("Allow running insecure content"),
1657+
_("Whether running insecure content should be allowed."),
1658+
FALSE,
1659+
readWriteConstructParamFlags);
1660+
1661+
/**
1662+
* WebKitSettings:allow-display-of-insecure-content:
1663+
*
1664+
* Allow display of insecure content on pages
1665+
*/
1666+
sObjProperties[PROP_ALLOW_DISPLAY_OF_INSECURE_CONTENT] = g_param_spec_boolean(
1667+
"allow-display-of-insecure-content",
1668+
_("Allow display insecure content"),
1669+
_("Whether display insecure content should be allowed."),
1670+
FALSE,
1671+
readWriteConstructParamFlags);
1672+
16351673
/**
16361674
* WebKitSettings:allow-scripts-to-close-windows:
16371675
*
@@ -4172,6 +4210,76 @@ WebKitFeatureList* webkit_settings_get_development_features(void)
41724210
return webkitFeatureListCreate(WebPreferences::internalDebugFeatures());
41734211
}
41744212

4213+
/**
4214+
* webkit_settings_get_allow_running_of_insecure_content:
4215+
* @settings: a #WebKitSettings
4216+
*
4217+
* Get the #WebKitSettings:allow-running-of-insecure-content property.
4218+
*
4219+
* Returns: %TRUE If running of insecure content is allowed or %FALSE otherwise.
4220+
*/
4221+
gboolean webkit_settings_get_allow_running_of_insecure_content(WebKitSettings* settings)
4222+
{
4223+
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
4224+
4225+
return settings->priv->preferences->allowRunningOfInsecureContent();
4226+
}
4227+
4228+
/**
4229+
* webkit_settings_set_allow_running_of_insecure_content:
4230+
* @settings: a #WebKitSettings
4231+
* @allowed: Value to be set
4232+
*
4233+
* Set the #WebKitSettings:allow-running-of-insecure-content property.
4234+
*/
4235+
void webkit_settings_set_allow_running_of_insecure_content(WebKitSettings* settings, gboolean allowed)
4236+
{
4237+
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
4238+
4239+
WebKitSettingsPrivate* priv = settings->priv;
4240+
bool currentValue = priv->preferences->allowRunningOfInsecureContent();
4241+
if (currentValue == allowed)
4242+
return;
4243+
4244+
priv->preferences->setAllowRunningOfInsecureContent(allowed);
4245+
g_object_notify_by_pspec(G_OBJECT(settings), sObjProperties[PROP_ALLOW_RUNNING_OF_INSECURE_CONTENT]);
4246+
}
4247+
4248+
/**
4249+
* webkit_settings_get_allow_display_of_insecure_content:
4250+
* @settings: a #WebKitSettings
4251+
*
4252+
* Get the #WebKitSettings:allow-display-of-insecure-content property.
4253+
*
4254+
* Returns: %TRUE If display of insecure content is allowed or %FALSE otherwise.
4255+
*/
4256+
gboolean webkit_settings_get_allow_display_of_insecure_content(WebKitSettings* settings)
4257+
{
4258+
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
4259+
4260+
return settings->priv->preferences->allowDisplayOfInsecureContent();
4261+
}
4262+
4263+
/**
4264+
* webkit_settings_set_allow_display_of_insecure_content:
4265+
* @settings: a #WebKitSettings
4266+
* @allowed: Value to be set
4267+
*
4268+
* Set the #WebKitSettings:allow-display-of-insecure-content property.
4269+
*/
4270+
void webkit_settings_set_allow_display_of_insecure_content(WebKitSettings* settings, gboolean allowed)
4271+
{
4272+
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
4273+
4274+
WebKitSettingsPrivate* priv = settings->priv;
4275+
bool currentValue = priv->preferences->allowDisplayOfInsecureContent();
4276+
if (currentValue == allowed)
4277+
return;
4278+
4279+
priv->preferences->setAllowDisplayOfInsecureContent(allowed);
4280+
g_object_notify_by_pspec(G_OBJECT(settings), sObjProperties[PROP_ALLOW_DISPLAY_OF_INSECURE_CONTENT]);
4281+
}
4282+
41754283
/**
41764284
* webkit_settings_get_allow_scripts_to_close_windows:
41774285
* @settings: a #WebKitSettings

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,20 @@ webkit_settings_get_experimental_features (void);
562562
WEBKIT_API WebKitFeatureList *
563563
webkit_settings_get_development_features (void);
564564

565+
WEBKIT_API gboolean
566+
webkit_settings_get_allow_running_of_insecure_content (WebKitSettings *settings);
567+
568+
WEBKIT_API void
569+
webkit_settings_set_allow_running_of_insecure_content (WebKitSettings *settings,
570+
gboolean allowed);
571+
572+
WEBKIT_API gboolean
573+
webkit_settings_get_allow_display_of_insecure_content (WebKitSettings *settings);
574+
575+
WEBKIT_API void
576+
webkit_settings_set_allow_display_of_insecure_content (WebKitSettings *settings,
577+
gboolean allowed);
578+
565579
WEBKIT_API gboolean
566580
webkit_settings_get_allow_scripts_to_close_windows (WebKitSettings *settings);
567581

0 commit comments

Comments
 (0)