Bug 221199 - [GLib] Permission request API for MediaKeySystem access support
Summary: [GLib] Permission request API for MediaKeySystem access support
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Philippe Normand
URL:
Keywords:
Depends on: 221187 221588
Blocks:
  Show dependency treegraph
 
Reported: 2021-02-01 05:02 PST by Philippe Normand
Modified: 2021-02-09 05:13 PST (History)
15 users (show)

See Also:


Attachments
Patch (33.93 KB, patch)
2021-02-01 05:08 PST, Philippe Normand
no flags Details | Formatted Diff | Diff
Patch (33.93 KB, patch)
2021-02-08 02:19 PST, Philippe Normand
cgarcia: review+
cgarcia: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Philippe Normand 2021-02-01 05:02:51 PST
.
Comment 1 Philippe Normand 2021-02-01 05:08:09 PST
Created attachment 418860 [details]
Patch
Comment 2 EWS Watchlist 2021-02-01 05:08:54 PST
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See https://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Comment 3 Philippe Normand 2021-02-08 02:19:35 PST
Created attachment 419567 [details]
Patch
Comment 4 Carlos Garcia Campos 2021-02-08 02:50:05 PST
Comment on attachment 419567 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=419567&action=review

Please fix my comments before landing.

> Source/WebKit/UIProcess/API/glib/WebKitMediaKeySystemPermissionRequest.cpp:105
> +WebKitMediaKeySystemPermissionRequest* webkitMediaKeySystemPermissionRequestCreate(MediaKeySystemPermissionRequest* request)

This is receiving the newly created request, so it could be Ref<MediaKeySystemPermissionRequest>&& instead of a pointer

> Source/WebKit/UIProcess/API/glib/WebKitMediaKeySystemPermissionRequest.cpp:107
> +    WebKitMediaKeySystemPermissionRequest* permissionRequest = WEBKIT_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST(g_object_new(WEBKIT_TYPE_MEDIA_KEY_SYSTEM_PERMISSION_REQUEST, NULL));

NULL -> nullptr

> Source/WebKit/UIProcess/API/glib/WebKitMediaKeySystemPermissionRequest.cpp:108
> +    permissionRequest->priv->request = request;

And here we would WTFMove(request)

> Source/WebKit/UIProcess/API/glib/WebKitMediaKeySystemPermissionRequest.cpp:116
> + *
> + * Returns: The name of the key system for which access permission is being requested.

Add a body description, the Returns: can be simpler to not duplicate

* Get the key system for which access permission is being requested.
*
* Returns: the key system name for @request

Or something similar.

> Source/WebKit/UIProcess/API/glib/WebKitMediaKeySystemPermissionRequest.cpp:123
> +    return request->priv->request->keySystem().utf8().data();

This is a temporary, we need to cache its value in a CString in the priv struct to be able to return a const char*

> Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp:287
> +    void decidePolicyForMediaKeySystemPermissionRequest(WebPageProxy&, API::SecurityOrigin& topLevelDocumentOrigin, const WTF::String& keySystem, CompletionHandler<void(bool)>&& completionHandler) final

topLevelDocumentOrigin can be omitted as it's unused, no?

> Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp:289
> +        auto permissionRequest = adoptGRef(webkitMediaKeySystemPermissionRequestCreate(MediaKeySystemPermissionRequest::create(keySystem, std::exchange(completionHandler, nullptr)).ptr()));

why exchange and not WTFMove()?

> Source/WebKit/UIProcess/API/gtk/WebKitMediaKeySystemPermissionRequest.h:62
> +WEBKIT_API const gchar*

gchar* -> gchar *

> Source/WebKit/UIProcess/API/wpe/WebKitMediaKeySystemPermissionRequest.h:62
> +WEBKIT_API const gchar*

Ditto.

> Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.cpp:67
> +#if ENABLE(ENCRYPTED_MEDIA)
> +    auto* settings = webkit_web_view_get_settings(m_webView);
> +    webkit_settings_set_enable_encrypted_media(settings, TRUE);
> +#endif

Let's enable this only for the test that needs it. It could just one line.
Comment 5 Philippe Normand 2021-02-08 03:08:41 PST
Comment on attachment 419567 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=419567&action=review

>> Source/WebKit/UIProcess/API/glib/WebKitMediaKeySystemPermissionRequest.cpp:108
>> +    permissionRequest->priv->request = request;
> 
> And here we would WTFMove(request)

error: reference to type 'Ref<WebKitMediaKeySystemPermissionRequest>' (aka 'Ref<_WebKitMediaKeySystemPermissionRequest>') could not bind to an rvalue of type 'typename remove_reference<_WebKitMediaKeySystemPermissionRequest *&>::type' (aka '_WebKitMediaKeySystemPermissionRequest *')
    return WTFMove(permissionRequest);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~
DerivedSources/ForwardingHeaders/wtf/StdLibExtras.h:532:24: note: expanded from macro 'WTFMove'
#define WTFMove(value) std::move<WTF::CheckMoveParameter>(value)
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

>> Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.cpp:67
>> +#endif
> 
> Let's enable this only for the test that needs it. It could just one line.

Then I need to write a WebViewTest sub-class, only to add that one line? Why is it an issue to do this here?
Comment 6 Carlos Garcia Campos 2021-02-08 03:14:10 PST
Comment on attachment 419567 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=419567&action=review

>>> Source/WebKit/UIProcess/API/glib/WebKitMediaKeySystemPermissionRequest.cpp:108
>>> +    permissionRequest->priv->request = request;
>> 
>> And here we would WTFMove(request)
> 
> error: reference to type 'Ref<WebKitMediaKeySystemPermissionRequest>' (aka 'Ref<_WebKitMediaKeySystemPermissionRequest>') could not bind to an rvalue of type 'typename remove_reference<_WebKitMediaKeySystemPermissionRequest *&>::type' (aka '_WebKitMediaKeySystemPermissionRequest *')
>     return WTFMove(permissionRequest);
>            ^~~~~~~~~~~~~~~~~~~~~~~~~~
> DerivedSources/ForwardingHeaders/wtf/StdLibExtras.h:532:24: note: expanded from macro 'WTFMove'
> #define WTFMove(value) std::move<WTF::CheckMoveParameter>(value)
>                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 1 error generated.

WTFMove(request) not WTFMove(permissionRequest) in the return

>>> Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.cpp:67
>>> +#endif
>> 
>> Let's enable this only for the test that needs it. It could just one line.
> 
> Then I need to write a WebViewTest sub-class, only to add that one line? Why is it an issue to do this here?

No, just do 

webkit_settings_set_enable_encrypted_media(webkit_web_view_get_settings(test->m_webView), TRUE);

before test->showInWindow(); in the test
Comment 7 Philippe Normand 2021-02-08 03:35:19 PST
Committed r272485: <https://trac.webkit.org/changeset/272485>
Comment 8 WebKit Commit Bot 2021-02-08 18:14:27 PST
Re-opened since this is blocked by bug 221588
Comment 9 Philippe Normand 2021-02-09 05:13:11 PST
Committed r272574: <https://trac.webkit.org/changeset/272574>