Title: [272485] trunk
Revision
272485
Author
[email protected]
Date
2021-02-08 03:34:54 -0800 (Mon, 08 Feb 2021)

Log Message

[GLib] Permission request API for MediaKeySystem access support
https://bugs.webkit.org/show_bug.cgi?id=221199

Reviewed by Carlos Garcia Campos.

Source/WebKit:

Expose a new Permission Request object to the public WPE and GTK APIs, allowing the
application to defer the decision of using a given EME MediaKeySystem to the user's
approval.

Covered by new API test.

* PlatformGTK.cmake:
* PlatformWPE.cmake:
* SourcesGTK.txt:
* SourcesWPE.txt:
* UIProcess/API/glib/WebKitMediaKeySystemPermissionRequest.cpp: Added.
(webkitMediaKeySystemPermissionRequestAllow):
(webkitMediaKeySystemPermissionRequestDeny):
(webkit_permission_request_interface_init):
(webkitMediaKeySystemPermissionRequestDispose):
(webkit_media_key_system_permission_request_class_init):
(webkitMediaKeySystemPermissionRequestCreate):
(webkit_media_key_system_permission_get_name):
* UIProcess/API/glib/WebKitMediaKeySystemPermissionRequestPrivate.h: Added.
* UIProcess/API/glib/WebKitUIClient.cpp:
* UIProcess/API/gtk/WebKitAutocleanups.h:
* UIProcess/API/gtk/WebKitMediaKeySystemPermissionRequest.h: Added.
* UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
* UIProcess/API/gtk/docs/webkit2gtk-docs.sgml:
* UIProcess/API/gtk/webkit2.h:
* UIProcess/API/wpe/WebKitMediaKeySystemPermissionRequest.h: Added.
* UIProcess/API/wpe/docs/wpe-1.0-sections.txt:
* UIProcess/API/wpe/docs/wpe-docs.sgml:

Tools:

Added basic support for MediaKeySystem permission request to the GTK MiniBrowser, and a GLib
API unit-test as well.

* MiniBrowser/gtk/BrowserTab.c:
(permissionRequestDialogResponse):
(decidePermissionRequest):
(browser_tab_class_init):
* TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp:
(testWebViewMediaKeySystemPermissionRequests):
(beforeAll):
* TestWebKitAPI/glib/WebKitGLib/WebViewTest.cpp:
(WebViewTest::initializeWebView):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (272484 => 272485)


--- trunk/Source/WebKit/ChangeLog	2021-02-08 09:47:26 UTC (rev 272484)
+++ trunk/Source/WebKit/ChangeLog	2021-02-08 11:34:54 UTC (rev 272485)
@@ -1,5 +1,41 @@
 2021-02-08  Philippe Normand  <[email protected]>
 
+        [GLib] Permission request API for MediaKeySystem access support
+        https://bugs.webkit.org/show_bug.cgi?id=221199
+
+        Reviewed by Carlos Garcia Campos.
+
+        Expose a new Permission Request object to the public WPE and GTK APIs, allowing the
+        application to defer the decision of using a given EME MediaKeySystem to the user's
+        approval.
+
+        Covered by new API test.
+
+        * PlatformGTK.cmake:
+        * PlatformWPE.cmake:
+        * SourcesGTK.txt:
+        * SourcesWPE.txt:
+        * UIProcess/API/glib/WebKitMediaKeySystemPermissionRequest.cpp: Added.
+        (webkitMediaKeySystemPermissionRequestAllow):
+        (webkitMediaKeySystemPermissionRequestDeny):
+        (webkit_permission_request_interface_init):
+        (webkitMediaKeySystemPermissionRequestDispose):
+        (webkit_media_key_system_permission_request_class_init):
+        (webkitMediaKeySystemPermissionRequestCreate):
+        (webkit_media_key_system_permission_get_name):
+        * UIProcess/API/glib/WebKitMediaKeySystemPermissionRequestPrivate.h: Added.
+        * UIProcess/API/glib/WebKitUIClient.cpp:
+        * UIProcess/API/gtk/WebKitAutocleanups.h:
+        * UIProcess/API/gtk/WebKitMediaKeySystemPermissionRequest.h: Added.
+        * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt:
+        * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml:
+        * UIProcess/API/gtk/webkit2.h:
+        * UIProcess/API/wpe/WebKitMediaKeySystemPermissionRequest.h: Added.
+        * UIProcess/API/wpe/docs/wpe-1.0-sections.txt:
+        * UIProcess/API/wpe/docs/wpe-docs.sgml:
+
+2021-02-08  Philippe Normand  <[email protected]>
+
         Unreviewed, unified build fix after r272480
 
         * WebProcess/Speech/SpeechRecognitionRealtimeMediaSourceManager.cpp: Logging.h is needed for

Modified: trunk/Source/WebKit/PlatformGTK.cmake (272484 => 272485)


--- trunk/Source/WebKit/PlatformGTK.cmake	2021-02-08 09:47:26 UTC (rev 272484)
+++ trunk/Source/WebKit/PlatformGTK.cmake	2021-02-08 11:34:54 UTC (rev 272485)
@@ -119,6 +119,7 @@
     ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitHitTestResult.h
     ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitInstallMissingMediaPluginsPermissionRequest.h
     ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitJavascriptResult.h
+    ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitMediaKeySystemPermissionRequest.h
     ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitMimeInfo.h
     ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitNavigationAction.h
     ${WEBKIT_DIR}/UIProcess/API/gtk/WebKitNavigationPolicyDecision.h

Modified: trunk/Source/WebKit/PlatformWPE.cmake (272484 => 272485)


--- trunk/Source/WebKit/PlatformWPE.cmake	2021-02-08 09:47:26 UTC (rev 272484)
+++ trunk/Source/WebKit/PlatformWPE.cmake	2021-02-08 11:34:54 UTC (rev 272485)
@@ -132,6 +132,7 @@
     ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitInputMethodContext.h
     ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitInstallMissingMediaPluginsPermissionRequest.h
     ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitJavascriptResult.h
+    ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitMediaKeySystemPermissionRequest.h
     ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitMimeInfo.h
     ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitNavigationAction.h
     ${WEBKIT_DIR}/UIProcess/API/wpe/WebKitNavigationPolicyDecision.h

Modified: trunk/Source/WebKit/SourcesGTK.txt (272484 => 272485)


--- trunk/Source/WebKit/SourcesGTK.txt	2021-02-08 09:47:26 UTC (rev 272484)
+++ trunk/Source/WebKit/SourcesGTK.txt	2021-02-08 11:34:54 UTC (rev 272485)
@@ -146,6 +146,7 @@
 UIProcess/API/glib/WebKitInputMethodContext.cpp @no-unify
 UIProcess/API/glib/WebKitInstallMissingMediaPluginsPermissionRequest.cpp @no-unify
 UIProcess/API/glib/WebKitJavascriptResult.cpp @no-unify
+UIProcess/API/glib/WebKitMediaKeySystemPermissionRequest.cpp @no-unify
 UIProcess/API/glib/WebKitMimeInfo.cpp @no-unify
 UIProcess/API/glib/WebKitNavigationAction.cpp @no-unify
 UIProcess/API/glib/WebKitNavigationClient.cpp @no-unify

Modified: trunk/Source/WebKit/SourcesWPE.txt (272484 => 272485)


--- trunk/Source/WebKit/SourcesWPE.txt	2021-02-08 09:47:26 UTC (rev 272484)
+++ trunk/Source/WebKit/SourcesWPE.txt	2021-02-08 11:34:54 UTC (rev 272485)
@@ -137,6 +137,7 @@
 UIProcess/API/glib/WebKitInputMethodContext.cpp @no-unify
 UIProcess/API/glib/WebKitInstallMissingMediaPluginsPermissionRequest.cpp @no-unify
 UIProcess/API/glib/WebKitJavascriptResult.cpp @no-unify
+UIProcess/API/glib/WebKitMediaKeySystemPermissionRequest.cpp @no-unify
 UIProcess/API/glib/WebKitMimeInfo.cpp @no-unify
 UIProcess/API/glib/WebKitNavigationAction.cpp @no-unify
 UIProcess/API/glib/WebKitNavigationClient.cpp @no-unify

Added: trunk/Source/WebKit/UIProcess/API/glib/WebKitMediaKeySystemPermissionRequest.cpp (0 => 272485)


--- trunk/Source/WebKit/UIProcess/API/glib/WebKitMediaKeySystemPermissionRequest.cpp	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitMediaKeySystemPermissionRequest.cpp	2021-02-08 11:34:54 UTC (rev 272485)
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2021 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "WebKitMediaKeySystemPermissionRequest.h"
+
+#include "MediaKeySystemPermissionRequest.h"
+#include "WebKitMediaKeySystemPermissionRequestPrivate.h"
+#include "WebKitPermissionRequest.h"
+#include <wtf/glib/WTFGType.h>
+
+using namespace WebKit;
+
+/**
+ * SECTION: WebKitMediaKeySystemPermissionRequest
+ * @Short_description: A permission request for using an EME Content Decryption Module
+ * @Title: WebKitMediaKeySystemPermissionRequest
+ * @See_also: #WebKitPermissionRequest, #WebKitWebView
+ *
+ * WebKitMediaKeySystemPermissionRequest represents a request for permission to decide whether
+ * WebKit should use the given CDM to access protected media when requested through the
+ * MediaKeySystem API.
+ *
+ * When a WebKitMediaKeySystemPermissionRequest is not handled by the user,
+ * it is denied by default.
+ *
+ * When handling this permission request the application may perform additional installation of the
+ * requested CDM, unless it is already present on the host system.
+ */
+
+static void webkit_permission_request_interface_init(WebKitPermissionRequestIface*);
+
+struct _WebKitMediaKeySystemPermissionRequestPrivate {
+    RefPtr<MediaKeySystemPermissionRequest> request;
+    bool madeDecision;
+    CString keySystem;
+};
+
+WEBKIT_DEFINE_TYPE_WITH_CODE(
+    WebKitMediaKeySystemPermissionRequest, webkit_media_key_system_permission_request, G_TYPE_OBJECT,
+    G_IMPLEMENT_INTERFACE(WEBKIT_TYPE_PERMISSION_REQUEST, webkit_permission_request_interface_init))
+
+static void webkitMediaKeySystemPermissionRequestAllow(WebKitPermissionRequest* request)
+{
+    ASSERT(WEBKIT_IS_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST(request));
+
+    WebKitMediaKeySystemPermissionRequestPrivate* priv = WEBKIT_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST(request)->priv;
+
+    // Only one decision at a time.
+    if (priv->madeDecision)
+        return;
+
+    priv->request->complete(true);
+    priv->madeDecision = true;
+}
+
+static void webkitMediaKeySystemPermissionRequestDeny(WebKitPermissionRequest* request)
+{
+    ASSERT(WEBKIT_IS_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST(request));
+
+    WebKitMediaKeySystemPermissionRequestPrivate* priv = WEBKIT_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST(request)->priv;
+
+    // Only one decision at a time.
+    if (priv->madeDecision)
+        return;
+
+    priv->request->complete(false);
+    priv->madeDecision = true;
+}
+
+static void webkit_permission_request_interface_init(WebKitPermissionRequestIface* iface)
+{
+    iface->allow = webkitMediaKeySystemPermissionRequestAllow;
+    iface->deny = webkitMediaKeySystemPermissionRequestDeny;
+}
+
+static void webkitMediaKeySystemPermissionRequestDispose(GObject* object)
+{
+    // Default behaviour when no decision has been made is denying the request.
+    webkitMediaKeySystemPermissionRequestDeny(WEBKIT_PERMISSION_REQUEST(object));
+    G_OBJECT_CLASS(webkit_media_key_system_permission_request_parent_class)->dispose(object);
+}
+
+static void webkit_media_key_system_permission_request_class_init(WebKitMediaKeySystemPermissionRequestClass* klass)
+{
+    GObjectClass* objectClass = G_OBJECT_CLASS(klass);
+    objectClass->dispose = webkitMediaKeySystemPermissionRequestDispose;
+}
+
+WebKitMediaKeySystemPermissionRequest* webkitMediaKeySystemPermissionRequestCreate(Ref<MediaKeySystemPermissionRequest>&& request)
+{
+    WebKitMediaKeySystemPermissionRequest* permissionRequest = WEBKIT_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST(g_object_new(WEBKIT_TYPE_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST, NULL));
+    permissionRequest->priv->request = WTFMove(request);
+    return permissionRequest;
+}
+
+/**
+ * webkit_media_key_system_permission_get_name:
+ * @request: a #WebKitMediaKeySystemPermissionRequest
+ *
+ * Get the key system for which access permission is being requested.
+ *
+ * Returns: the key system name for @request
+ *
+ * Since: 2.32
+ */
+const gchar*
+webkit_media_key_system_permission_get_name(WebKitMediaKeySystemPermissionRequest* request)
+{
+    auto* priv = request->priv;
+    if (priv->keySystem.isNull())
+        priv->keySystem = priv->request->keySystem().utf8().data();
+    return priv->keySystem.data();
+}

Added: trunk/Source/WebKit/UIProcess/API/glib/WebKitMediaKeySystemPermissionRequestPrivate.h (0 => 272485)


--- trunk/Source/WebKit/UIProcess/API/glib/WebKitMediaKeySystemPermissionRequestPrivate.h	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitMediaKeySystemPermissionRequestPrivate.h	2021-02-08 11:34:54 UTC (rev 272485)
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2021 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#pragma once
+
+#include "MediaKeySystemPermissionRequest.h"
+#include "WebKitMediaKeySystemPermissionRequest.h"
+
+WebKitMediaKeySystemPermissionRequest* webkitMediaKeySystemPermissionRequestCreate(WTF::Ref<WebKit::MediaKeySystemPermissionRequest>&&);

Modified: trunk/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp (272484 => 272485)


--- trunk/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp	2021-02-08 09:47:26 UTC (rev 272484)
+++ trunk/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp	2021-02-08 11:34:54 UTC (rev 272485)
@@ -25,6 +25,7 @@
 #include "WebKitDeviceInfoPermissionRequestPrivate.h"
 #include "WebKitFileChooserRequestPrivate.h"
 #include "WebKitGeolocationPermissionRequestPrivate.h"
+#include "WebKitMediaKeySystemPermissionRequestPrivate.h"
 #include "WebKitNavigationActionPrivate.h"
 #include "WebKitNotificationPermissionRequestPrivate.h"
 #include "WebKitPointerLockPermissionRequestPrivate.h"
@@ -283,6 +284,12 @@
         webkitWebViewMakePermissionRequest(m_webView, WEBKIT_PERMISSION_REQUEST(geolocationPermissionRequest.get()));
     }
 
+    void decidePolicyForMediaKeySystemPermissionRequest(WebPageProxy&, API::SecurityOrigin&, const WTF::String& keySystem, CompletionHandler<void(bool)>&& completionHandler) final
+    {
+        auto permissionRequest = adoptGRef(webkitMediaKeySystemPermissionRequestCreate(MediaKeySystemPermissionRequest::create(keySystem, WTFMove(completionHandler))));
+        webkitWebViewMakePermissionRequest(m_webView, WEBKIT_PERMISSION_REQUEST(permissionRequest.get()));
+    }
+
     void decidePolicyForUserMediaPermissionRequest(WebPageProxy&, WebFrameProxy&, API::SecurityOrigin& userMediaDocumentOrigin, API::SecurityOrigin& topLevelDocumentOrigin, UserMediaPermissionRequestProxy& permissionRequest) final
     {
         GRefPtr<WebKitUserMediaPermissionRequest> userMediaPermissionRequest = adoptGRef(webkitUserMediaPermissionRequestCreate(permissionRequest, userMediaDocumentOrigin, topLevelDocumentOrigin));

Modified: trunk/Source/WebKit/UIProcess/API/gtk/WebKitAutocleanups.h (272484 => 272485)


--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitAutocleanups.h	2021-02-08 09:47:26 UTC (rev 272484)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitAutocleanups.h	2021-02-08 11:34:54 UTC (rev 272485)
@@ -45,6 +45,7 @@
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitHitTestResult, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitInputMethodContext, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitInstallMissingMediaPluginsPermissionRequest, g_object_unref)
+G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitMediaKeySystemPermissionRequest, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitNavigationPolicyDecision, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitNotification, g_object_unref)
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (WebKitNotificationPermissionRequest, g_object_unref)

Added: trunk/Source/WebKit/UIProcess/API/gtk/WebKitMediaKeySystemPermissionRequest.h (0 => 272485)


--- trunk/Source/WebKit/UIProcess/API/gtk/WebKitMediaKeySystemPermissionRequest.h	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/gtk/WebKitMediaKeySystemPermissionRequest.h	2021-02-08 11:34:54 UTC (rev 272485)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2021 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitMediaKeySystemPermissionRequest_h
+#define WebKitMediaKeySystemPermissionRequest_h
+
+#include <glib-object.h>
+#include <webkit2/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST            (webkit_media_key_system_permission_request_get_type())
+#define WEBKIT_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST, WebKitMediaKeySystemPermissionRequest))
+#define WEBKIT_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  WEBKIT_TYPE_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST, WebKitMediaKeySystemPermissionRequestClass))
+#define WEBKIT_IS_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST))
+#define WEBKIT_IS_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_TYPE_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST))
+#define WEBKIT_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_TYPE_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST, WebKitMediaKeySystemPermissionRequestClass))
+
+typedef struct _WebKitMediaKeySystemPermissionRequest        WebKitMediaKeySystemPermissionRequest;
+typedef struct _WebKitMediaKeySystemPermissionRequestClass   WebKitMediaKeySystemPermissionRequestClass;
+typedef struct _WebKitMediaKeySystemPermissionRequestPrivate WebKitMediaKeySystemPermissionRequestPrivate;
+
+struct _WebKitMediaKeySystemPermissionRequest {
+    GObject parent;
+
+    /*< private >*/
+    WebKitMediaKeySystemPermissionRequestPrivate *priv;
+};
+
+struct _WebKitMediaKeySystemPermissionRequestClass {
+    GObjectClass parent_class;
+
+    void (*_webkit_reserved0) (void);
+    void (*_webkit_reserved1) (void);
+    void (*_webkit_reserved2) (void);
+    void (*_webkit_reserved3) (void);
+};
+
+WEBKIT_API GType
+webkit_media_key_system_permission_request_get_type (void);
+
+WEBKIT_API const gchar *
+webkit_media_key_system_permission_get_name (WebKitMediaKeySystemPermissionRequest *request);
+
+G_END_DECLS
+
+#endif

Modified: trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt (272484 => 272485)


--- trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt	2021-02-08 09:47:26 UTC (rev 272484)
+++ trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt	2021-02-08 11:34:54 UTC (rev 272485)
@@ -805,6 +805,25 @@
 </SECTION>
 
 <SECTION>
+<FILE>WebKitMediaKeySystemPermissionRequest</FILE>
+WebKitMediaKeySystemPermissionRequest
+webkit_media_key_system_permission_get_name
+
+<SUBSECTION Standard>
+WebKitMediaKeySystemPermissionRequestClass
+WEBKIT_TYPE_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST
+WEBKIT_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST
+WEBKIT_IS_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST
+WEBKIT_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST_CLASS
+WEBKIT_IS_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST_CLASS
+WEBKIT_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST_GET_CLASS
+
+<SUBSECTION Private>
+WebKitMediaKeySystemPermissionRequestPrivate
+webkit_media_key_system_permission_request_get_type
+</SECTION>
+
+<SECTION>
 <FILE>WebKitNotification</FILE>
 WebKitNotification
 webkit_notification_get_id

Modified: trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml (272484 => 272485)


--- trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml	2021-02-08 09:47:26 UTC (rev 272484)
+++ trunk/Source/WebKit/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml	2021-02-08 11:34:54 UTC (rev 272485)
@@ -24,6 +24,7 @@
     <xi:include href=""
     <xi:include href=""
     <xi:include href=""
+    <xi:include href=""
     <xi:include href=""
     <xi:include href=""
     <xi:include href=""

Modified: trunk/Source/WebKit/UIProcess/API/gtk/webkit2.h (272484 => 272485)


--- trunk/Source/WebKit/UIProcess/API/gtk/webkit2.h	2021-02-08 09:47:26 UTC (rev 272484)
+++ trunk/Source/WebKit/UIProcess/API/gtk/webkit2.h	2021-02-08 11:34:54 UTC (rev 272485)
@@ -32,6 +32,7 @@
 #include <webkit2/WebKitAutomationSession.h>
 #include <webkit2/WebKitBackForwardList.h>
 #include <webkit2/WebKitBackForwardListItem.h>
+#include <webkit2/WebKitColorChooserRequest.h>
 #include <webkit2/WebKitContextMenu.h>
 #include <webkit2/WebKitContextMenuActions.h>
 #include <webkit2/WebKitContextMenuItem.h>
@@ -45,7 +46,6 @@
 #include <webkit2/WebKitEnumTypes.h>
 #include <webkit2/WebKitError.h>
 #include <webkit2/WebKitFaviconDatabase.h>
-#include <webkit2/WebKitColorChooserRequest.h>
 #include <webkit2/WebKitFileChooserRequest.h>
 #include <webkit2/WebKitFindController.h>
 #include <webkit2/WebKitFormSubmissionRequest.h>
@@ -55,6 +55,7 @@
 #include <webkit2/WebKitInputMethodContext.h>
 #include <webkit2/WebKitInstallMissingMediaPluginsPermissionRequest.h>
 #include <webkit2/WebKitJavascriptResult.h>
+#include <webkit2/WebKitMediaKeySystemPermissionRequest.h>
 #include <webkit2/WebKitMimeInfo.h>
 #include <webkit2/WebKitNavigationAction.h>
 #include <webkit2/WebKitNavigationPolicyDecision.h>

Added: trunk/Source/WebKit/UIProcess/API/wpe/WebKitMediaKeySystemPermissionRequest.h (0 => 272485)


--- trunk/Source/WebKit/UIProcess/API/wpe/WebKitMediaKeySystemPermissionRequest.h	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/API/wpe/WebKitMediaKeySystemPermissionRequest.h	2021-02-08 11:34:54 UTC (rev 272485)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2021 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
+#error "Only <webkit2/webkit2.h> can be included directly."
+#endif
+
+#ifndef WebKitMediaKeySystemPermissionRequest_h
+#define WebKitMediaKeySystemPermissionRequest_h
+
+#include <glib-object.h>
+#include <wpe/WebKitDefines.h>
+
+G_BEGIN_DECLS
+
+#define WEBKIT_TYPE_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST            (webkit_media_key_system_permission_request_get_type())
+#define WEBKIT_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST, WebKitMediaKeySystemPermissionRequest))
+#define WEBKIT_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),  WEBKIT_TYPE_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST, WebKitMediaKeySystemPermissionRequestClass))
+#define WEBKIT_IS_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST))
+#define WEBKIT_IS_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),  WEBKIT_TYPE_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST))
+#define WEBKIT_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj),  WEBKIT_TYPE_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST, WebKitMediaKeySystemPermissionRequestClass))
+
+typedef struct _WebKitMediaKeySystemPermissionRequest        WebKitMediaKeySystemPermissionRequest;
+typedef struct _WebKitMediaKeySystemPermissionRequestClass   WebKitMediaKeySystemPermissionRequestClass;
+typedef struct _WebKitMediaKeySystemPermissionRequestPrivate WebKitMediaKeySystemPermissionRequestPrivate;
+
+struct _WebKitMediaKeySystemPermissionRequest {
+    GObject parent;
+
+    /*< private >*/
+    WebKitMediaKeySystemPermissionRequestPrivate *priv;
+};
+
+struct _WebKitMediaKeySystemPermissionRequestClass {
+    GObjectClass parent_class;
+
+    void (*_webkit_reserved0) (void);
+    void (*_webkit_reserved1) (void);
+    void (*_webkit_reserved2) (void);
+    void (*_webkit_reserved3) (void);
+};
+
+WEBKIT_API GType
+webkit_media_key_system_permission_request_get_type (void);
+
+WEBKIT_API const gchar *
+webkit_media_key_system_permission_get_name (WebKitMediaKeySystemPermissionRequest *request);
+
+G_END_DECLS
+
+#endif

Modified: trunk/Source/WebKit/UIProcess/API/wpe/docs/wpe-1.0-sections.txt (272484 => 272485)


--- trunk/Source/WebKit/UIProcess/API/wpe/docs/wpe-1.0-sections.txt	2021-02-08 09:47:26 UTC (rev 272484)
+++ trunk/Source/WebKit/UIProcess/API/wpe/docs/wpe-1.0-sections.txt	2021-02-08 11:34:54 UTC (rev 272485)
@@ -809,6 +809,25 @@
 </SECTION>
 
 <SECTION>
+<FILE>WebKitMediaKeySystemPermissionRequest</FILE>
+WebKitMediaKeySystemPermissionRequest
+webkit_media_key_system_permission_get_name
+
+<SUBSECTION Standard>
+WebKitMediaKeySystemPermissionRequestClass
+WEBKIT_TYPE_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST
+WEBKIT_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST
+WEBKIT_IS_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST
+WEBKIT_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST_CLASS
+WEBKIT_IS_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST_CLASS
+WEBKIT_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST_GET_CLASS
+
+<SUBSECTION Private>
+WebKitMediaKeySystemPermissionRequestPrivate
+webkit_media_key_system_permission_request_get_type
+</SECTION>
+
+<SECTION>
 <FILE>WebKitNotification</FILE>
 WebKitNotification
 webkit_notification_get_id

Modified: trunk/Source/WebKit/UIProcess/API/wpe/docs/wpe-docs.sgml (272484 => 272485)


--- trunk/Source/WebKit/UIProcess/API/wpe/docs/wpe-docs.sgml	2021-02-08 09:47:26 UTC (rev 272484)
+++ trunk/Source/WebKit/UIProcess/API/wpe/docs/wpe-docs.sgml	2021-02-08 11:34:54 UTC (rev 272485)
@@ -25,6 +25,7 @@
     <xi:include href=""
     <xi:include href=""
     <xi:include href=""
+    <xi:include href=""
     <xi:include href=""
     <xi:include href=""
     <xi:include href=""

Modified: trunk/Tools/ChangeLog (272484 => 272485)


--- trunk/Tools/ChangeLog	2021-02-08 09:47:26 UTC (rev 272484)
+++ trunk/Tools/ChangeLog	2021-02-08 11:34:54 UTC (rev 272485)
@@ -1,3 +1,23 @@
+2021-02-08  Philippe Normand  <[email protected]>
+
+        [GLib] Permission request API for MediaKeySystem access support
+        https://bugs.webkit.org/show_bug.cgi?id=221199
+
+        Reviewed by Carlos Garcia Campos.
+
+        Added basic support for MediaKeySystem permission request to the GTK MiniBrowser, and a GLib
+        API unit-test as well.
+
+        * MiniBrowser/gtk/BrowserTab.c:
+        (permissionRequestDialogResponse):
+        (decidePermissionRequest):
+        (browser_tab_class_init):
+        * TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp:
+        (testWebViewMediaKeySystemPermissionRequests):
+        (beforeAll):
+        * TestWebKitAPI/glib/WebKitGLib/WebViewTest.cpp:
+        (WebViewTest::initializeWebView):
+
 2021-02-08  Alicia Boya GarcĂ­a  <[email protected]>
 
         ConsoleMessage: Don't encode string JSONLogValue's as JSON

Modified: trunk/Tools/MiniBrowser/gtk/BrowserTab.c (272484 => 272485)


--- trunk/Tools/MiniBrowser/gtk/BrowserTab.c	2021-02-08 09:47:26 UTC (rev 272484)
+++ trunk/Tools/MiniBrowser/gtk/BrowserTab.c	2021-02-08 11:34:54 UTC (rev 272485)
@@ -60,6 +60,7 @@
 };
 
 static GHashTable *userMediaPermissionGrantedOrigins;
+static GHashTable *mediaKeySystemPermissionGrantedOrigins;
 struct _BrowserTabClass {
     GtkBoxClass parent;
 };
@@ -264,6 +265,8 @@
     case GTK_RESPONSE_YES:
         if (WEBKIT_IS_USER_MEDIA_PERMISSION_REQUEST(requestData->request))
             g_hash_table_add(userMediaPermissionGrantedOrigins, g_strdup(requestData->origin));
+        if (WEBKIT_IS_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST(requestData->request))
+            g_hash_table_add(mediaKeySystemPermissionGrantedOrigins, g_strdup(requestData->origin));
 
         webkit_permission_request_allow(requestData->request);
         break;
@@ -270,6 +273,8 @@
     default:
         if (WEBKIT_IS_USER_MEDIA_PERMISSION_REQUEST(requestData->request))
             g_hash_table_remove(userMediaPermissionGrantedOrigins, requestData->origin);
+        if (WEBKIT_IS_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST(requestData->request))
+            g_hash_table_remove(mediaKeySystemPermissionGrantedOrigins, requestData->origin);
 
         webkit_permission_request_deny(requestData->request);
         break;
@@ -340,6 +345,16 @@
         const gchar *currentDomain = webkit_website_data_access_permission_request_get_current_domain(websiteDataAccessRequest);
         text = g_strdup_printf("Do you want to allow \"%s\" to use cookies while browsing \"%s\"? This will allow \"%s\" to track your activity",
             requestingDomain, currentDomain, requestingDomain);
+    } else if (WEBKIT_IS_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST(request)) {
+        char *origin = getWebViewOrigin(webView);
+        if (g_hash_table_contains(mediaKeySystemPermissionGrantedOrigins, origin)) {
+            webkit_permission_request_allow(request);
+            g_free(origin);
+            return TRUE;
+        }
+        g_free(origin);
+        title = "DRM system access request";
+        text = g_strdup_printf("Allow to use a CDM providing access to %s?", webkit_media_key_system_permission_get_name(WEBKIT_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST(request)));
     } else {
         g_print("%s request not handled\n", G_OBJECT_TYPE_NAME(request));
         return FALSE;
@@ -655,6 +670,9 @@
     if (!userMediaPermissionGrantedOrigins)
         userMediaPermissionGrantedOrigins = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
 
+    if (!mediaKeySystemPermissionGrantedOrigins)
+        mediaKeySystemPermissionGrantedOrigins = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
+
     g_object_class_install_property(
         gobjectClass,
         PROP_VIEW,

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp (272484 => 272485)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp	2021-02-08 09:47:26 UTC (rev 272484)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp	2021-02-08 11:34:54 UTC (rev 272485)
@@ -896,6 +896,43 @@
     Test::addLogFatalFlag(G_LOG_LEVEL_WARNING);
 }
 
+#if ENABLE(ENCRYPTED_MEDIA)
+static void testWebViewMediaKeySystemPermissionRequests(UIClientTest* test, gconstpointer)
+{
+    webkit_settings_set_enable_encrypted_media(webkit_web_view_get_settings(test->m_webView), TRUE);
+    test->showInWindow();
+    static const char* mediaKeySystemRequestHTML = "<html>"
+        "  <script>"
+        "  function runTest()"
+        "  {"
+        "    const options = ["
+        "     { initDataTypes: [\"cenc\"],"
+        "       videoCapabilities: [{contentType : 'video/mp4'}] }"
+        "    ];"
+        "    navigator.requestMediaKeySystemAccess('org.w3.clearkey', options).then((access) => {"
+        "      window.webkit.messageHandlers.permission.postMessage('OK');"
+        "    }).catch((e) => {"
+        "      window.webkit.messageHandlers.permission.postMessage(e.name);"
+        "    });"
+        "  }"
+        "  </script>"
+        "  <body _onload_='runTest();'></body>"
+        "</html>";
+
+    // Test denying a permission request.
+    test->m_allowPermissionRequests = false;
+    test->loadHtml(mediaKeySystemRequestHTML, "https://foo.com/bar");
+    const gchar* result = test->waitUntilPermissionResultMessageReceived();
+    g_assert_cmpstr(result, ==, "NotSupportedError");
+
+    // Test allowing a permission request.
+    test->m_allowPermissionRequests = true;
+    test->loadHtml(mediaKeySystemRequestHTML, "https://foo.com/bar");
+    result = test->waitUntilPermissionResultMessageReceived();
+    g_assert_cmpstr(result, ==, "OK");
+}
+#endif
+
 #if ENABLE(MEDIA_STREAM)
 static void testWebViewUserMediaEnumerateDevicesPermissionCheck(UIClientTest* test, gconstpointer)
 {
@@ -1299,6 +1336,9 @@
     UIClientTest::add("WebKitWebView", "mouse-target", testWebViewMouseTarget);
 #endif
     UIClientTest::add("WebKitWebView", "geolocation-permission-requests", testWebViewGeolocationPermissionRequests);
+#if ENABLE(ENCRYPTED_MEDIA)
+    UIClientTest::add("WebKitWebView", "mediaKeySystem-permission-requests", testWebViewMediaKeySystemPermissionRequests);
+#endif
 #if ENABLE(MEDIA_STREAM)
     UIClientTest::add("WebKitWebView", "usermedia-enumeratedevices-permission-check", testWebViewUserMediaEnumerateDevicesPermissionCheck);
     UIClientTest::add("WebKitWebView", "usermedia-permission-requests", testWebViewUserMediaPermissionRequests);

Modified: trunk/Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.cpp (272484 => 272485)


--- trunk/Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.cpp	2021-02-08 09:47:26 UTC (rev 272484)
+++ trunk/Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.cpp	2021-02-08 11:34:54 UTC (rev 272485)
@@ -60,6 +60,7 @@
         "user-content-manager", m_userContentManager.get(),
         "is-ephemeral", shouldCreateEphemeralWebView,
         nullptr));
+
     platformInitializeWebView();
     assertObjectIsDeletedWhenTestFinishes(G_OBJECT(m_webView));
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to