Skip to content

Commit c7fd248

Browse files
pgorszkowski-igaliaspenap
authored andcommitted
Add settings to allow running and displaying insecure content
Don't upgrade mixed content when insecure content is allowed
1 parent a0688f5 commit c7fd248

2 files changed

Lines changed: 132 additions & 0 deletions

File tree

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

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ enum {
191191
PROP_WEBRTC_UDP_PORTS_RANGE,
192192
PROP_ALLOW_SCRIPTS_TO_CLOSE_WINDOWS,
193193
PROP_ENABLE_DIRECTORY_UPLOAD,
194+
PROP_ALLOW_RUNNING_OF_INSECURE_CONTENT,
195+
PROP_ALLOW_DISPLAY_OF_INSECURE_CONTENT,
194196
N_PROPERTIES,
195197
};
196198

@@ -427,6 +429,12 @@ ALLOW_DEPRECATED_DECLARATIONS_BEGIN
427429
case PROP_ENABLE_DIRECTORY_UPLOAD:
428430
webkit_settings_set_enable_directory_upload(settings, g_value_get_boolean(value));
429431
break;
432+
case PROP_ALLOW_RUNNING_OF_INSECURE_CONTENT:
433+
webkit_settings_set_allow_running_of_insecure_content(settings, g_value_get_boolean(value));
434+
break;
435+
case PROP_ALLOW_DISPLAY_OF_INSECURE_CONTENT:
436+
webkit_settings_set_allow_display_of_insecure_content(settings, g_value_get_boolean(value));
437+
break;
430438
default:
431439
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
432440
break;
@@ -647,6 +655,12 @@ ALLOW_DEPRECATED_DECLARATIONS_BEGIN
647655
case PROP_ENABLE_DIRECTORY_UPLOAD:
648656
g_value_set_boolean(value, webkit_settings_get_enable_directory_upload(settings));
649657
break;
658+
case PROP_ALLOW_RUNNING_OF_INSECURE_CONTENT:
659+
g_value_set_boolean(value, webkit_settings_get_allow_running_of_insecure_content(settings));
660+
break;
661+
case PROP_ALLOW_DISPLAY_OF_INSECURE_CONTENT:
662+
g_value_set_boolean(value, webkit_settings_get_allow_display_of_insecure_content(settings));
663+
break;
650664
default:
651665
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
652666
break;
@@ -1755,6 +1769,30 @@ static void webkit_settings_class_init(WebKitSettingsClass* klass)
17551769
TRUE,
17561770
readWriteConstructParamFlags);
17571771

1772+
/**
1773+
* WebKitSettings:allow-running-of-insecure-content:
1774+
*
1775+
* Allow running of insecure content on pages
1776+
*/
1777+
sObjProperties[PROP_ALLOW_RUNNING_OF_INSECURE_CONTENT] = g_param_spec_boolean(
1778+
"allow-running-of-insecure-content",
1779+
_("Allow running insecure content"),
1780+
_("Whether running insecure content should be allowed."),
1781+
FALSE,
1782+
readWriteConstructParamFlags);
1783+
1784+
/**
1785+
* WebKitSettings:allow-display-of-insecure-content:
1786+
*
1787+
* Allow display of insecure content on pages
1788+
*/
1789+
sObjProperties[PROP_ALLOW_DISPLAY_OF_INSECURE_CONTENT] = g_param_spec_boolean(
1790+
"allow-display-of-insecure-content",
1791+
_("Allow display insecure content"),
1792+
_("Whether display insecure content should be allowed."),
1793+
FALSE,
1794+
readWriteConstructParamFlags);
1795+
17581796
g_object_class_install_properties(gObjectClass, N_PROPERTIES, sObjProperties.data());
17591797
}
17601798

@@ -4549,3 +4587,83 @@ void webkit_settings_set_enable_directory_upload(WebKitSettings* settings, gbool
45494587
priv->preferences->setDirectoryUploadEnabled(enabled);
45504588
g_object_notify(G_OBJECT(settings), "enable-directory-upload");
45514589
}
4590+
4591+
/**
4592+
* webkit_settings_get_allow_running_of_insecure_content:
4593+
* @settings: a #WebKitSettings
4594+
*
4595+
* Get the #WebKitSettings:allow-running-of-insecure-content property.
4596+
*
4597+
* Returns: %TRUE If running of insecure content is allowed or %FALSE otherwise.
4598+
*/
4599+
gboolean webkit_settings_get_allow_running_of_insecure_content(WebKitSettings* settings)
4600+
{
4601+
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
4602+
4603+
return settings->priv->preferences->allowRunningOfInsecureContent();
4604+
}
4605+
4606+
/**
4607+
* webkit_settings_set_allow_running_of_insecure_content:
4608+
* @settings: a #WebKitSettings
4609+
* @allowed: Value to be set
4610+
*
4611+
* Set the #WebKitSettings:allow-running-of-insecure-content property.
4612+
*/
4613+
void webkit_settings_set_allow_running_of_insecure_content(WebKitSettings* settings, gboolean allowed)
4614+
{
4615+
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
4616+
4617+
WebKitSettingsPrivate* priv = settings->priv;
4618+
bool currentValue = priv->preferences->allowRunningOfInsecureContent();
4619+
if (currentValue == allowed)
4620+
return;
4621+
4622+
priv->preferences->setAllowRunningOfInsecureContent(allowed);
4623+
4624+
// If we are allowed to run insecure content, then upgrade mixed content should not be performed
4625+
if (allowed)
4626+
priv->preferences->setUpgradeMixedContentEnabled(false);
4627+
4628+
g_object_notify_by_pspec(G_OBJECT(settings), sObjProperties[PROP_ALLOW_RUNNING_OF_INSECURE_CONTENT]);
4629+
}
4630+
4631+
/**
4632+
* webkit_settings_get_allow_display_of_insecure_content:
4633+
* @settings: a #WebKitSettings
4634+
*
4635+
* Get the #WebKitSettings:allow-display-of-insecure-content property.
4636+
*
4637+
* Returns: %TRUE If display of insecure content is allowed or %FALSE otherwise.
4638+
*/
4639+
gboolean webkit_settings_get_allow_display_of_insecure_content(WebKitSettings* settings)
4640+
{
4641+
g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
4642+
4643+
return settings->priv->preferences->allowDisplayOfInsecureContent();
4644+
}
4645+
4646+
/**
4647+
* webkit_settings_set_allow_display_of_insecure_content:
4648+
* @settings: a #WebKitSettings
4649+
* @allowed: Value to be set
4650+
*
4651+
* Set the #WebKitSettings:allow-display-of-insecure-content property.
4652+
*/
4653+
void webkit_settings_set_allow_display_of_insecure_content(WebKitSettings* settings, gboolean allowed)
4654+
{
4655+
g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
4656+
4657+
WebKitSettingsPrivate* priv = settings->priv;
4658+
bool currentValue = priv->preferences->allowDisplayOfInsecureContent();
4659+
if (currentValue == allowed)
4660+
return;
4661+
4662+
priv->preferences->setAllowDisplayOfInsecureContent(allowed);
4663+
4664+
// If we are allowed to display insecure content, then upgrade mixed content should not be performed
4665+
if (allowed)
4666+
priv->preferences->setUpgradeMixedContentEnabled(false);
4667+
4668+
g_object_notify_by_pspec(G_OBJECT(settings), sObjProperties[PROP_ALLOW_DISPLAY_OF_INSECURE_CONTENT]);
4669+
}

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,20 @@ WEBKIT_API void
582582
webkit_settings_set_webrtc_udp_ports_range (WebKitSettings *settings,
583583
const gchar *udp_port_range);
584584

585+
WEBKIT_API gboolean
586+
webkit_settings_get_allow_running_of_insecure_content (WebKitSettings *settings);
587+
588+
WEBKIT_API void
589+
webkit_settings_set_allow_running_of_insecure_content (WebKitSettings *settings,
590+
gboolean allowed);
591+
592+
WEBKIT_API gboolean
593+
webkit_settings_get_allow_display_of_insecure_content (WebKitSettings *settings);
594+
595+
WEBKIT_API void
596+
webkit_settings_set_allow_display_of_insecure_content (WebKitSettings *settings,
597+
gboolean allowed);
598+
585599
WEBKIT_API gboolean
586600
webkit_settings_get_allow_scripts_to_close_windows (WebKitSettings *settings);
587601

0 commit comments

Comments
 (0)