[GTK][WPE] Add enable-media websetting
authorphiln@webkit.org <philn@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Apr 2019 14:41:17 +0000 (14:41 +0000)
committerphiln@webkit.org <philn@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 15 Apr 2019 14:41:17 +0000 (14:41 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196863

Reviewed by Michael Catanzaro.

Source/WebKit:

It can be useful for headless browsers, for instance. The setting is enabled by default.

* Shared/WebPreferences.yaml:
* UIProcess/API/glib/WebKitSettings.cpp:
(webKitSettingsSetProperty):
(webKitSettingsGetProperty):
(webkit_settings_class_init):
(webkit_settings_get_enable_media):
(webkit_settings_set_enable_media):
* UIProcess/API/gtk/WebKitSettings.h:
* UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
* UIProcess/API/wpe/WebKitSettings.h:
* UIProcess/API/wpe/docs/wpe-1.0-sections.txt:

Tools:

* TestWebKitAPI/Tests/WebKitGLib/TestWebKitSettings.cpp:
(testWebKitSettings): Add test for the enable-media web-setting.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@244260 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/Shared/WebPreferences.yaml
Source/WebKit/UIProcess/API/glib/WebKitSettings.cpp
Source/WebKit/UIProcess/API/gtk/WebKitSettings.h
Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt
Source/WebKit/UIProcess/API/wpe/WebKitSettings.h
Source/WebKit/UIProcess/API/wpe/docs/wpe-1.0-sections.txt
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebKitSettings.cpp

index eee0ec6..63f9638 100644 (file)
@@ -1,3 +1,24 @@
+2019-04-15  Philippe Normand  <pnormand@igalia.com>
+
+        [GTK][WPE] Add enable-media websetting
+        https://bugs.webkit.org/show_bug.cgi?id=196863
+
+        Reviewed by Michael Catanzaro.
+
+        It can be useful for headless browsers, for instance. The setting is enabled by default.
+
+        * Shared/WebPreferences.yaml:
+        * UIProcess/API/glib/WebKitSettings.cpp:
+        (webKitSettingsSetProperty):
+        (webKitSettingsGetProperty):
+        (webkit_settings_class_init):
+        (webkit_settings_get_enable_media):
+        (webkit_settings_set_enable_media):
+        * UIProcess/API/gtk/WebKitSettings.h:
+        * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
+        * UIProcess/API/wpe/WebKitSettings.h:
+        * UIProcess/API/wpe/docs/wpe-1.0-sections.txt:
+
 2019-04-14  Rob Buis  <rbuis@igalia.com>
 
         Link prefetch not useful for top-level navigation
index f3fe546..e7a279e 100644 (file)
@@ -524,6 +524,12 @@ MediaStreamEnabled:
   webcoreBinding: RuntimeEnabledFeatures
   condition: ENABLE(MEDIA_STREAM)
 
+MediaEnabled:
+  type: bool
+  defaultValue: true
+  webcoreName: mediaEnabled
+  condition: ENABLE(VIDEO)
+
 ScreenCaptureEnabled:
   type: bool
   defaultValue: true
index 03654dd..023b14c 100644 (file)
@@ -167,6 +167,7 @@ enum {
     PROP_ENABLE_BACK_FORWARD_NAVIGATION_GESTURES,
 #endif
     PROP_ENABLE_JAVASCRIPT_MARKUP,
+    PROP_ENABLE_MEDIA,
 };
 
 static void webKitSettingsDispose(GObject* object)
@@ -393,6 +394,9 @@ static void webKitSettingsSetProperty(GObject* object, guint propId, const GValu
     case PROP_ENABLE_JAVASCRIPT_MARKUP:
         webkit_settings_set_enable_javascript_markup(settings, g_value_get_boolean(value));
         break;
+    case PROP_ENABLE_MEDIA:
+        webkit_settings_set_enable_media(settings, g_value_get_boolean(value));
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
         break;
@@ -578,6 +582,9 @@ static void webKitSettingsGetProperty(GObject* object, guint propId, GValue* val
     case PROP_ENABLE_JAVASCRIPT_MARKUP:
         g_value_set_boolean(value, webkit_settings_get_enable_javascript_markup(settings));
         break;
+    case PROP_ENABLE_MEDIA:
+        g_value_set_boolean(value, webkit_settings_get_enable_media(settings));
+        break;
     default:
         G_OBJECT_WARN_INVALID_PROPERTY_ID(object, propId, paramSpec);
         break;
@@ -1493,6 +1500,24 @@ static void webkit_settings_class_init(WebKitSettingsClass* klass)
             _("Enable JavaScript in document markup."),
             TRUE,
             readWriteConstructParamFlags));
+
+    /**
+     * WebKitSettings:enable-media:
+     *
+     * Enable or disable support for media playback on pages. This setting is enabled by
+     * default. Disabling it means <audio>, <track> and <video> elements will have
+     * playback support disabled.
+     *
+     * Since: 2.26
+     */
+    g_object_class_install_property(gObjectClass,
+        PROP_ENABLE_MEDIA,
+        g_param_spec_boolean("enable-media",
+            _("Enable media"),
+            _("Whether media content should be handled"),
+            TRUE,
+            readWriteConstructParamFlags));
+
 }
 
 WebPreferences* webkitSettingsGetPreferences(WebKitSettings* settings)
@@ -3674,3 +3699,42 @@ void webkit_settings_set_enable_javascript_markup(WebKitSettings* settings, gboo
     priv->preferences->setJavaScriptMarkupEnabled(enabled);
     g_object_notify(G_OBJECT(settings), "enable-javascript-markup");
 }
+
+/**
+ * webkit_settings_get_enable_media:
+ * @settings: a #WebKitSettings
+ *
+ * Get the #WebKitSettings:enable-media property.
+ *
+ * Returns: %TRUE if media support is enabled or %FALSE otherwise.
+ *
+ * Since: 2.26
+ */
+gboolean webkit_settings_get_enable_media(WebKitSettings* settings)
+{
+    g_return_val_if_fail(WEBKIT_IS_SETTINGS(settings), FALSE);
+
+    return settings->priv->preferences->mediaEnabled();
+}
+
+/**
+ * webkit_settings_set_enable_media:
+ * @settings: a #WebKitSettings
+ * @enabled: Value to be set
+ *
+ * Set the #WebKitSettings:enable-media property.
+ *
+ * Since: 2.26
+ */
+void webkit_settings_set_enable_media(WebKitSettings* settings, gboolean enabled)
+{
+    g_return_if_fail(WEBKIT_IS_SETTINGS(settings));
+
+    WebKitSettingsPrivate* priv = settings->priv;
+    bool currentValue = priv->preferences->mediaEnabled();
+    if (currentValue == enabled)
+        return;
+
+    priv->preferences->setMediaEnabled(enabled);
+    g_object_notify(G_OBJECT(settings), "enable-media");
+}
index 00a8ebb..224c270 100644 (file)
@@ -492,6 +492,13 @@ WEBKIT_API void
 webkit_settings_set_enable_javascript_markup                   (WebKitSettings *settings,
                                                                 gboolean        enabled);
 
+WEBKIT_API gboolean
+webkit_settings_get_enable_media                               (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_enable_media                               (WebKitSettings *settings,
+                                                                gboolean        enabled);
+
 G_END_DECLS
 
 #endif /* WebKitSettings_h */
index 6bcd7c3..23eeaa6 100644 (file)
@@ -535,6 +535,8 @@ webkit_settings_get_enable_back_forward_navigation_gestures
 webkit_settings_set_enable_back_forward_navigation_gestures
 webkit_settings_font_size_to_points
 webkit_settings_font_size_to_pixels
+webkit_settings_get_enable_media
+webkit_settings_set_enable_media
 
 <SUBSECTION Standard>
 WebKitSettingsClass
index a7921ab..52404d7 100644 (file)
@@ -449,6 +449,13 @@ WEBKIT_API void
 webkit_settings_set_enable_javascript_markup                   (WebKitSettings *settings,
                                                                 gboolean        enabled);
 
+WEBKIT_API gboolean
+webkit_settings_get_enable_media                               (WebKitSettings *settings);
+
+WEBKIT_API void
+webkit_settings_set_enable_media                               (WebKitSettings *settings,
+                                                                gboolean        enabled);
+
 G_END_DECLS
 
 #endif /* WebKitSettings_h */
index ad4d60c..64ea30e 100644 (file)
@@ -522,6 +522,8 @@ webkit_settings_get_allow_file_access_from_file_urls
 webkit_settings_set_allow_file_access_from_file_urls
 webkit_settings_get_allow_universal_access_from_file_urls
 webkit_settings_set_allow_universal_access_from_file_urls
+webkit_settings_get_enable_media
+webkit_settings_set_enable_media
 
 <SUBSECTION Standard>
 WebKitSettingsClass
index c9c72bb..b475fea 100644 (file)
@@ -1,3 +1,13 @@
+2019-04-15  Philippe Normand  <pnormand@igalia.com>
+
+        [GTK][WPE] Add enable-media websetting
+        https://bugs.webkit.org/show_bug.cgi?id=196863
+
+        Reviewed by Michael Catanzaro.
+
+        * TestWebKitAPI/Tests/WebKitGLib/TestWebKitSettings.cpp:
+        (testWebKitSettings): Add test for the enable-media web-setting.
+
 2019-04-14  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         API test WKAttachmentTests.AddAttachmentToConnectedImageElement is a flaky failure on Mac Release builds
index 50ef3d1..d1156f3 100644 (file)
@@ -339,6 +339,11 @@ static void testWebKitSettings(Test*, gconstpointer)
     webkit_settings_set_allow_universal_access_from_file_urls(settings, TRUE);
     g_assert_true(webkit_settings_get_allow_universal_access_from_file_urls(settings));
 
+    // Media is enabled by default.
+    g_assert_true(webkit_settings_get_enable_media(settings));
+    webkit_settings_set_enable_media(settings, FALSE);
+    g_assert_false(webkit_settings_get_enable_media(settings));
+
 #if PLATFORM(GTK)
     // Ondemand is the default hardware acceleration policy.
     g_assert_cmpuint(webkit_settings_get_hardware_acceleration_policy(settings), ==, WEBKIT_HARDWARE_ACCELERATION_POLICY_ON_DEMAND);