Changeset 237031 in webkit


Ignore:
Timestamp:
Oct 11, 2018 3:26:52 AM (6 years ago)
Author:
commit-queue@webkit.org
Message:

[GTK][WPE] Add mediaDevices.enumerateDevices support
https://bugs.webkit.org/show_bug.cgi?id=185761

Patch by Alejandro G. Castro <alex@igalia.com> on 2018-10-11
Reviewed by Youenn Fablet.

Source/WebCore:

We are adopting the same policy COCOA is using when returning the
list of media devices if the user does not have persistent
access. Namely, we just return the first media device for audio
and video capture.

  • Modules/mediastream/MediaDevicesRequest.cpp:

(WebCore::MediaDevicesRequest::filterDeviceList): Add support for
other platforms when filtering devices if there is no persistent
access to the origin.

Source/WebKit:

Implemented the enumerateDevices API using a new WebKit class
(DeviceIdHashSaltStorage) that generates and stores the device ids
hash salts per origin, used to avoid fingerprinting in the
webpages.

The patch also adds a new type of data for the WebsiteDataStore.
That way the users can call the WebsiteDataStore to show what
origins have hash salt generated and remove them at some point.

For the moment just GTK+ and WPE ports are using this class to
generate the hash salts. The patch adds code to the
checkUserMediaPermissionForOrigin API implementation, it was empty
until now for these ports. In this function we create an instance
of a new class WebKitDeviceInfoPermissionRequest that implements
the WebKitPermissionRequestIface interface, that allows the ports
to use the current permission managers implemented in the
embedders to handle this new kind of request the way they like
it. The default implementation is deny.

The class WebKitDeviceInfoPermissionRequest takes care of
contacting the DeviceIdHashSaltStorage and request/regenerate the
hash salts accordingly.

Persistency is still not implemented, we will add it in a
future patch.

  • Shared/WebsiteData/WebsiteDataType.h: Added the new type of

webside data: DeviceIdHashSalt.

  • Sources.txt: Added new files to compilation.
  • SourcesGTK.txt: Ditto.
  • SourcesWPE.txt: Ditto.
  • UIProcess/API/glib/WebKitDeviceInfoPermissionRequest.cpp: Added

this class to represent a request of permission to access the
devices information. This is specific for glib ports and implements
the policies regarding the hash salts when the embedder allows or
denies the access using the DeviceIdHashSaltStorage class.
(webkitDeviceInfoPermissionRequestAllow): Get the device hash salt
when the origin is allowed and set it in the original request.
(webkitDeviceInfoPermissionRequestDeny): Regenerate the device id
hash salt when the user does not allow to access the device information.
(webkit_permission_request_interface_init):
(webkitDeviceInfoPermissionRequestDispose):
(webkit_device_info_permission_request_class_init):
(webkitDeviceInfoPermissionRequestCreate): Create the class using
the proxy request from the webprocess and a reference to the
DeviceIdHashSaltStorage.

  • UIProcess/API/glib/WebKitDeviceInfoPermissionRequestPrivate.h:

Ditto.

  • UIProcess/API/glib/WebKitUIClient.cpp: Added the implementation

for the checkUserMediaPermissionForOrigin API for the glib ports,
it creates the device info request and calls the permission
request API.

  • UIProcess/API/glib/WebKitWebsiteData.cpp:

(recordContainsSupportedDataTypes): Added the DeviceIdHashSalt
type.
(toWebKitWebsiteDataTypes): Added the conversion from the WebKit
types to the glib types for the WebsiteDataType::DeviceIdHashSalt.

  • UIProcess/API/glib/WebKitWebsiteDataManager.cpp:

(toWebsiteDataTypes): Added the conversion from the glib type
WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT to the WebKit type.
(webkit_website_data_manager_remove): Make sure we remote the
DeviceIdHashSalt if the Cookies are selected.

  • UIProcess/API/gtk/WebKitDeviceInfoPermissionRequest.h: Added

this new class that represents a permission request for the device
information in the GTK+ port.

  • UIProcess/API/gtk/WebKitWebsiteData.h: Added the new type of

website that in the GTK+ port:
WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT.

  • UIProcess/API/wpe/WebKitDeviceInfoPermissionRequest.h: Added

this new class that represents a permission request for the device
information in the WPE port.

  • UIProcess/API/wpe/WebKitWebsiteData.h: Added the new type of

website that in the WPE port:
WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT.

  • UIProcess/DeviceIdHashSaltStorage.cpp: Added this new class that

handles how to generate and store the hash salts inside
WebKit. Persistency is still not implemented, we will add it in a
future patch.
(WebKit::DeviceIdHashSaltStorage::create):
(WebKit::DeviceIdHashSaltStorage::deviceIdentifierHashSaltForOrigin):
Check the map to get the hash salt for an origin, if there is none
create a new random one.
(WebKit::DeviceIdHashSaltStorage::regenerateDeviceIdentifierHashSaltForOrigin):
Delete the hash salt of an origin if it already exists and create a new one.
(WebKit::DeviceIdHashSaltStorage::getDeviceIdHashSaltOrigins):
Returns the list of origins that have a hash salt generated for
them. It is used in the WebsiteDataStore.
(WebKit::DeviceIdHashSaltStorage::deleteDeviceIdHashSaltForOrigins):
Deletes the hash salts in the map for an origin.
(WebKit::DeviceIdHashSaltStorage::deleteDeviceIdHashSaltOriginsModifiedSince):
Delete the origins that have not been modified since a time.

  • UIProcess/DeviceIdHashSaltStorage.h: Ditto.
  • UIProcess/UserMediaPermissionCheckProxy.h: Remove uneeded class

definition.

  • UIProcess/WebsiteData/WebsiteDataStore.cpp: Added support to

return and remove the origins with a generate hash salt used to
generate the device ids.
(WebKit::WebsiteDataStore::WebsiteDataStore): Added the new
reference to the DeviceIdHashSaltStorage class, used to handle the
hash salts.
(WebKit::WebsiteDataStore::fetchDataAndApply): Get the list of
origins with a hash salts in the DeviceIdHashSaltStorage.
(WebKit::WebsiteDataStore::removeData): Remove the hash salts in
DeviceIdHashSaltStorage for an origin.

  • UIProcess/WebsiteData/WebsiteDataStore.h: Ditto.

(WebKit::WebsiteDataStore::deviceIdHashSaltStorage):

  • WebKit.xcodeproj/project.pbxproj: Added the

DeviceIdHashSaltStorage to the compilation.

Tools:

Added new API test for the mediaDevices.enumerateDevices:
usermedia-enumeratedevices-permission-check. And a new API test
for the WebsiteDataStore: testWebsiteDataDeviceIdHashSalt.

  • MiniBrowser/gtk/main.c:

(gotWebsiteDataCallback): Added a new section to the about:data
webpage to include the information about the hash salt.

  • TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp:

(testWebViewUserMediaEnumerateDevicesPermissionCheck): Added the
new test checking the enumerateDevices API when permission is
denied and when permission is allowed for the origin.
(beforeAll): Defined the new test.

  • TestWebKitAPI/Tests/WebKitGLib/TestWebsiteData.cpp:

(serverCallback): Register a new URI for the enumerateDevices.
(testWebsiteDataConfiguration): Remove the hash salts from the
directories.
(testWebsiteDataDeviceIdHashSalt): New test cheking the
enumerateDevices API.
(beforeAll): Added the new test testWebsiteDataDeviceIdHashSalt to
the init structure.

  • TestWebKitAPI/glib/WebKitGLib/WebViewTest.cpp:

(WebViewTest::initializeWebView): Make sure the media-stream is
activated in the webView.

LayoutTests:

Remove the failure expectation for the test
media-devices-enumerate-devices.html. Just for the record we have
also checked the following tests.

fast/mediastream/media-devices-enumerate-devices.html
fast/mediastream/resources/enumerate-devices-frame.html
http/tests/media/media-stream/enumerate-devices-source-id.html
http/tests/media/media-stream/enumerate-devices-source-id-persistent.html
http/tests/media/media-stream/resources/enumerate-devices-source-id-frame.html

  • platform/gtk/TestExpectations:
Location:
trunk
Files:
6 added
23 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r237028 r237031  
     12018-10-11  Alejandro G. Castro  <alex@igalia.com>
     2
     3        [GTK][WPE] Add mediaDevices.enumerateDevices support
     4        https://bugs.webkit.org/show_bug.cgi?id=185761
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Remove the failure expectation for the test
     9        media-devices-enumerate-devices.html. Just for the record we have
     10        also checked the following tests.
     11
     12        fast/mediastream/media-devices-enumerate-devices.html
     13        fast/mediastream/resources/enumerate-devices-frame.html
     14        http/tests/media/media-stream/enumerate-devices-source-id.html
     15        http/tests/media/media-stream/enumerate-devices-source-id-persistent.html
     16        http/tests/media/media-stream/resources/enumerate-devices-source-id-frame.html
     17
     18        * platform/gtk/TestExpectations:
     19
    1202018-10-10  Devin Rousso  <drousso@apple.com>
    221
  • trunk/LayoutTests/platform/gtk/TestExpectations

    r236961 r237031  
    641641# Crash is bug #176801
    642642webkit.org/b/160996 fast/mediastream/MediaStream-video-element-video-tracks-disabled.html [ ImageOnlyFailure Crash ]
    643 webkit.org/b/172269 fast/mediastream/media-devices-enumerate-devices.html [ Failure ]
    644643webkit.org/b/173257 fast/mediastream/getUserMedia-grant-persistency3.html [ Pass Failure ]
    645644
  • trunk/Source/WebCore/ChangeLog

    r237029 r237031  
     12018-10-11  Alejandro G. Castro  <alex@igalia.com>
     2
     3        [GTK][WPE] Add mediaDevices.enumerateDevices support
     4        https://bugs.webkit.org/show_bug.cgi?id=185761
     5
     6        Reviewed by Youenn Fablet.
     7
     8        We are adopting the same policy COCOA is using when returning the
     9        list of media devices if the user does not have persistent
     10        access. Namely, we just return the first media device for audio
     11        and video capture.
     12
     13        * Modules/mediastream/MediaDevicesRequest.cpp:
     14        (WebCore::MediaDevicesRequest::filterDeviceList): Add support for
     15        other platforms when filtering devices if there is no persistent
     16        access to the origin.
     17
    1182018-10-10  Chris Dumez  <cdumez@apple.com>
    219
  • trunk/Source/WebCore/Modules/mediastream/MediaDevicesRequest.cpp

    r236877 r237031  
    8282void MediaDevicesRequest::filterDeviceList(Vector<Ref<MediaDeviceInfo>>& devices)
    8383{
    84 #if !PLATFORM(COCOA)
    85     UNUSED_PARAM(devices);
    86 #else
    87 
    8884#if PLATFORM(IOS)
    8985    static const int defaultCameraCount = 2;
    90 #endif
    91 #if PLATFORM(MAC)
     86#else
    9287    static const int defaultCameraCount = 1;
    9388#endif
     89
    9490    static const int defaultMicrophoneCount = 1;
    9591
     
    104100        return false;
    105101    });
    106 
    107 #endif
    108102}
    109103
  • trunk/Source/WebKit/ChangeLog

    r237026 r237031  
     12018-10-11  Alejandro G. Castro  <alex@igalia.com>
     2
     3        [GTK][WPE] Add mediaDevices.enumerateDevices support
     4        https://bugs.webkit.org/show_bug.cgi?id=185761
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Implemented the enumerateDevices API using a new WebKit class
     9        (DeviceIdHashSaltStorage) that generates and stores the device ids
     10        hash salts per origin, used to avoid fingerprinting in the
     11        webpages.
     12
     13        The patch also adds a new type of data for the WebsiteDataStore.
     14        That way the users can call the WebsiteDataStore to show what
     15        origins have hash salt generated and remove them at some point.
     16
     17        For the moment just GTK+ and WPE ports are using this class to
     18        generate the hash salts. The patch adds code to the
     19        checkUserMediaPermissionForOrigin API implementation, it was empty
     20        until now for these ports. In this function we create an instance
     21        of a new class WebKitDeviceInfoPermissionRequest that implements
     22        the WebKitPermissionRequestIface interface, that allows the ports
     23        to use the current permission managers implemented in the
     24        embedders to handle this new kind of request the way they like
     25        it. The default implementation is deny.
     26
     27        The class WebKitDeviceInfoPermissionRequest takes care of
     28        contacting the DeviceIdHashSaltStorage and request/regenerate the
     29        hash salts accordingly.
     30
     31        Persistency is still not implemented, we will add it in a
     32        future patch.
     33
     34        * Shared/WebsiteData/WebsiteDataType.h: Added the new type of
     35        webside data: DeviceIdHashSalt.
     36        * Sources.txt: Added new files to compilation.
     37        * SourcesGTK.txt: Ditto.
     38        * SourcesWPE.txt: Ditto.
     39        * UIProcess/API/glib/WebKitDeviceInfoPermissionRequest.cpp: Added
     40        this class to represent a request of permission to access the
     41        devices information. This is specific for glib ports and implements
     42        the policies regarding the hash salts when the embedder allows or
     43        denies the access using the DeviceIdHashSaltStorage class.
     44        (webkitDeviceInfoPermissionRequestAllow): Get the device hash salt
     45        when the origin is allowed and set it in the original request.
     46        (webkitDeviceInfoPermissionRequestDeny): Regenerate the device id
     47        hash salt when the user does not allow to access the device information.
     48        (webkit_permission_request_interface_init):
     49        (webkitDeviceInfoPermissionRequestDispose):
     50        (webkit_device_info_permission_request_class_init):
     51        (webkitDeviceInfoPermissionRequestCreate): Create the class using
     52        the proxy request from the webprocess and a reference to the
     53        DeviceIdHashSaltStorage.
     54        * UIProcess/API/glib/WebKitDeviceInfoPermissionRequestPrivate.h:
     55        Ditto.
     56        * UIProcess/API/glib/WebKitUIClient.cpp: Added the implementation
     57        for the checkUserMediaPermissionForOrigin API for the glib ports,
     58        it creates the device info request and calls the permission
     59        request API.
     60        * UIProcess/API/glib/WebKitWebsiteData.cpp:
     61        (recordContainsSupportedDataTypes): Added the DeviceIdHashSalt
     62        type.
     63        (toWebKitWebsiteDataTypes): Added the conversion from the WebKit
     64        types to the glib types for the WebsiteDataType::DeviceIdHashSalt.
     65        * UIProcess/API/glib/WebKitWebsiteDataManager.cpp:
     66        (toWebsiteDataTypes): Added the conversion from the glib type
     67        WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT to the WebKit type.
     68        (webkit_website_data_manager_remove): Make sure we remote the
     69        DeviceIdHashSalt if the Cookies are selected.
     70        * UIProcess/API/gtk/WebKitDeviceInfoPermissionRequest.h: Added
     71        this new class that represents a permission request for the device
     72        information in the GTK+ port.
     73        * UIProcess/API/gtk/WebKitWebsiteData.h: Added the new type of
     74        website that in the GTK+ port:
     75        WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT.
     76        * UIProcess/API/wpe/WebKitDeviceInfoPermissionRequest.h: Added
     77        this new class that represents a permission request for the device
     78        information in the WPE port.
     79        * UIProcess/API/wpe/WebKitWebsiteData.h: Added the new type of
     80        website that in the WPE port:
     81        WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT.
     82        * UIProcess/DeviceIdHashSaltStorage.cpp: Added this new class that
     83        handles how to generate and store the hash salts inside
     84        WebKit. Persistency is still not implemented, we will add it in a
     85        future patch.
     86        (WebKit::DeviceIdHashSaltStorage::create):
     87        (WebKit::DeviceIdHashSaltStorage::deviceIdentifierHashSaltForOrigin):
     88        Check the map to get the hash salt for an origin, if there is none
     89        create a new random one.
     90        (WebKit::DeviceIdHashSaltStorage::regenerateDeviceIdentifierHashSaltForOrigin):
     91        Delete the hash salt of an origin if it already exists and create a new one.
     92        (WebKit::DeviceIdHashSaltStorage::getDeviceIdHashSaltOrigins):
     93        Returns the list of origins that have a hash salt generated for
     94        them. It is used in the WebsiteDataStore.
     95        (WebKit::DeviceIdHashSaltStorage::deleteDeviceIdHashSaltForOrigins):
     96        Deletes the hash salts in the map for an origin.
     97        (WebKit::DeviceIdHashSaltStorage::deleteDeviceIdHashSaltOriginsModifiedSince):
     98        Delete the origins that have not been modified since a time.
     99        * UIProcess/DeviceIdHashSaltStorage.h: Ditto.
     100        * UIProcess/UserMediaPermissionCheckProxy.h: Remove uneeded class
     101        definition.
     102        * UIProcess/WebsiteData/WebsiteDataStore.cpp: Added support to
     103        return and remove the origins with a generate hash salt used to
     104        generate the device ids.
     105        (WebKit::WebsiteDataStore::WebsiteDataStore): Added the new
     106        reference to the DeviceIdHashSaltStorage class, used to handle the
     107        hash salts.
     108        (WebKit::WebsiteDataStore::fetchDataAndApply): Get the list of
     109        origins with a hash salts in the DeviceIdHashSaltStorage.
     110        (WebKit::WebsiteDataStore::removeData): Remove the hash salts in
     111        DeviceIdHashSaltStorage for an origin.
     112        * UIProcess/WebsiteData/WebsiteDataStore.h: Ditto.
     113        (WebKit::WebsiteDataStore::deviceIdHashSaltStorage):
     114        * WebKit.xcodeproj/project.pbxproj: Added the
     115        DeviceIdHashSaltStorage to the compilation.
     116
    11172018-10-10  Tim Horton  <timothy_horton@apple.com>
    2118
  • trunk/Source/WebKit/Shared/WebsiteData/WebsiteDataType.h

    r223263 r237031  
    5050#endif
    5151    DOMCache = 1 << 15,
     52    DeviceIdHashSalt = 1 << 16,
    5253};
    5354
  • trunk/Source/WebKit/Sources.txt

    r236930 r237031  
    229229UIProcess/GeolocationPermissionRequestProxy.cpp
    230230UIProcess/PageLoadState.cpp
     231UIProcess/DeviceIdHashSaltStorage.cpp
    231232UIProcess/ProcessAssertion.cpp
    232233UIProcess/ProcessThrottler.cpp
  • trunk/Source/WebKit/SourcesGTK.txt

    r236690 r237031  
    134134UIProcess/API/glib/WebKitCredential.cpp @no-unify
    135135UIProcess/API/glib/WebKitCustomProtocolManagerClient.cpp @no-unify
     136UIProcess/API/glib/WebKitDeviceInfoPermissionRequest.cpp @no-unify
    136137UIProcess/API/glib/WebKitDownload.cpp @no-unify
    137138UIProcess/API/glib/WebKitDownloadClient.cpp @no-unify
  • trunk/Source/WebKit/SourcesWPE.txt

    r236690 r237031  
    121121UIProcess/API/glib/WebKitCredential.cpp @no-unify
    122122UIProcess/API/glib/WebKitCustomProtocolManagerClient.cpp @no-unify
     123UIProcess/API/glib/WebKitDeviceInfoPermissionRequest.cpp @no-unify
    123124UIProcess/API/glib/WebKitDownload.cpp @no-unify
    124125UIProcess/API/glib/WebKitDownloadClient.cpp @no-unify
  • trunk/Source/WebKit/UIProcess/API/glib/WebKitUIClient.cpp

    r235969 r237031  
    2323#include "APIUIClient.h"
    2424#include "DrawingAreaProxy.h"
     25#include "WebKitDeviceInfoPermissionRequestPrivate.h"
    2526#include "WebKitFileChooserRequestPrivate.h"
    2627#include "WebKitGeolocationPermissionRequestPrivate.h"
     
    3334#include "WebPageProxy.h"
    3435#include "WebProcessProxy.h"
     36#include "WebsiteDataStore.h"
    3537#include <wtf/glib/GRefPtr.h>
    3638
     
    190192    }
    191193
     194    bool checkUserMediaPermissionForOrigin(WebPageProxy& page, WebFrameProxy&, API::SecurityOrigin& userMediaDocumentOrigin, API::SecurityOrigin& topLevelDocumentOrigin, UserMediaPermissionCheckProxy& permissionRequest) override
     195    {
     196        auto deviceInfoPermissionRequest = adoptGRef(webkitDeviceInfoPermissionRequestCreate(permissionRequest, page.websiteDataStore().deviceIdHashSaltStorage()));
     197        webkitWebViewMakePermissionRequest(m_webView, WEBKIT_PERMISSION_REQUEST(deviceInfoPermissionRequest.get()));
     198        return true;
     199    }
     200
    192201    void decidePolicyForNotificationPermissionRequest(WebPageProxy&, API::SecurityOrigin&, Function<void(bool)>&& completionHandler) final
    193202    {
  • trunk/Source/WebKit/UIProcess/API/glib/WebKitWebsiteData.cpp

    r234813 r237031  
    7777        WebsiteDataType::PlugInData,
    7878#endif
    79         WebsiteDataType::Cookies
     79        WebsiteDataType::Cookies,
     80        WebsiteDataType::DeviceIdHashSalt
    8081    });
    8182}
     
    104105    if (types.contains(WebsiteDataType::Cookies))
    105106        returnValue |= WEBKIT_WEBSITE_DATA_COOKIES;
     107    if (types.contains(WebsiteDataType::DeviceIdHashSalt))
     108        returnValue |= WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT;
    106109    return static_cast<WebKitWebsiteDataTypes>(returnValue);
    107110}
  • trunk/Source/WebKit/UIProcess/API/glib/WebKitWebsiteDataManager.cpp

    r235560 r237031  
    650650    if (types & WEBKIT_WEBSITE_DATA_COOKIES)
    651651        returnValue.add(WebsiteDataType::Cookies);
     652    if (types & WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT)
     653        returnValue.add(WebsiteDataType::DeviceIdHashSalt);
    652654    return returnValue;
    653655}
     
    733735        WebKitWebsiteData* data = static_cast<WebKitWebsiteData*>(item->data);
    734736
    735         if (webkit_website_data_get_types(data) & types)
     737        // We have to remove the hash salts when cookies are removed.
     738        auto dataTypes = webkit_website_data_get_types(data);
     739        if (dataTypes & WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT)
     740            dataTypes = static_cast<WebKitWebsiteDataTypes>(dataTypes | WEBKIT_WEBSITE_DATA_COOKIES);
     741
     742        if (dataTypes & types)
    736743            records.append(webkitWebsiteDataGetRecord(data));
    737744    }
  • trunk/Source/WebKit/UIProcess/API/gtk/WebKitWebsiteData.h

    r232010 r237031  
    4545 * @WEBKIT_WEBSITE_DATA_PLUGIN_DATA: Plugins data.
    4646 * @WEBKIT_WEBSITE_DATA_COOKIES: Cookies.
     47 * @WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT: Hash salt used to generate the device ids used by webpages.
    4748 * @WEBKIT_WEBSITE_DATA_ALL: All types.
    4849 *
     
    6162    WEBKIT_WEBSITE_DATA_PLUGIN_DATA               = 1 << 7,
    6263    WEBKIT_WEBSITE_DATA_COOKIES                   = 1 << 8,
    63     WEBKIT_WEBSITE_DATA_ALL                       = (1 << 9) - 1
     64    WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT       = 1 << 9,
     65    WEBKIT_WEBSITE_DATA_ALL                       = (1 << 10) - 1
    6466} WebKitWebsiteDataTypes;
    6567
  • trunk/Source/WebKit/UIProcess/API/wpe/WebKitWebsiteData.h

    r232010 r237031  
    4545 * @WEBKIT_WEBSITE_DATA_PLUGIN_DATA: Plugins data.
    4646 * @WEBKIT_WEBSITE_DATA_COOKIES: Cookies.
     47 * @WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT: Hash salt used to generate the device ids used by webpages.
    4748 * @WEBKIT_WEBSITE_DATA_ALL: All types.
    4849 *
     
    6162    WEBKIT_WEBSITE_DATA_PLUGIN_DATA               = 1 << 7,
    6263    WEBKIT_WEBSITE_DATA_COOKIES                   = 1 << 8,
    63     WEBKIT_WEBSITE_DATA_ALL                       = (1 << 9) - 1
     64    WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT       = 1 << 9,
     65    WEBKIT_WEBSITE_DATA_ALL                       = (1 << 10) - 1
    6466} WebKitWebsiteDataTypes;
    6567
  • trunk/Source/WebKit/UIProcess/UserMediaPermissionCheckProxy.h

    r216952 r237031  
    3737namespace WebKit {
    3838
    39 class UserMediaPermissionRequestManagerProxy;
    40 
    4139class UserMediaPermissionCheckProxy : public API::ObjectImpl<API::Object::Type::UserMediaPermissionCheck> {
    4240public:
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp

    r236690 r237031  
    3131#include "APIWebsiteDataStore.h"
    3232#include "AuthenticatorManager.h"
     33#include "DeviceIdHashSaltStorage.h"
    3334#include "MockAuthenticatorManager.h"
    3435#include "NetworkProcessMessages.h"
     
    9697    , m_configuration(WTFMove(configuration))
    9798    , m_storageManager(StorageManager::create(m_configuration.localStorageDirectory))
     99    , m_deviceIdHashSaltStorage(DeviceIdHashSaltStorage::create())
    98100    , m_queue(WorkQueue::create("com.apple.WebKit.WebsiteDataStore"))
    99101#if ENABLE(WEB_AUTHN)
     
    486488    }
    487489
     490    if (m_deviceIdHashSaltStorage && dataTypes.contains(WebsiteDataType::DeviceIdHashSalt)) {
     491        callbackAggregator->addPendingCallback();
     492
     493        m_deviceIdHashSaltStorage->getDeviceIdHashSaltOrigins([callbackAggregator](auto&& origins) {
     494            WebsiteData websiteData;
     495
     496            while (!origins.isEmpty())
     497                websiteData.entries.append(WebsiteData::Entry { origins.takeAny(), WebsiteDataType::DeviceIdHashSalt, 0 });
     498
     499            callbackAggregator->removePendingCallback(WTFMove(websiteData));
     500        });
     501    }
     502
    488503    if (dataTypes.contains(WebsiteDataType::OfflineWebApplicationCache) && isPersistent()) {
    489504        callbackAggregator->addPendingCallback();
     
    801816    }
    802817
     818    if (m_deviceIdHashSaltStorage && (dataTypes.contains(WebsiteDataType::DeviceIdHashSalt) || (dataTypes.contains(WebsiteDataType::Cookies)))) {
     819        callbackAggregator->addPendingCallback();
     820
     821        m_deviceIdHashSaltStorage->deleteDeviceIdHashSaltOriginsModifiedSince(modifiedSince, [callbackAggregator] {
     822            callbackAggregator->removePendingCallback();
     823        });
     824    }
     825
    803826    if (dataTypes.contains(WebsiteDataType::OfflineWebApplicationCache) && isPersistent()) {
    804827        callbackAggregator->addPendingCallback();
     
    10751098    }
    10761099
     1100    if (m_deviceIdHashSaltStorage && (dataTypes.contains(WebsiteDataType::DeviceIdHashSalt) || (dataTypes.contains(WebsiteDataType::Cookies)))) {
     1101        callbackAggregator->addPendingCallback();
     1102
     1103        m_deviceIdHashSaltStorage->deleteDeviceIdHashSaltForOrigins(origins, [callbackAggregator] {
     1104            callbackAggregator->removePendingCallback();
     1105        });
     1106    }
     1107
    10771108    if (dataTypes.contains(WebsiteDataType::OfflineWebApplicationCache) && isPersistent()) {
    10781109        HashSet<WebCore::SecurityOriginData> origins;
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h

    r236690 r237031  
    5656class SecKeyProxyStore;
    5757class StorageManager;
     58class DeviceIdHashSaltStorage;
    5859class WebPageProxy;
    5960class WebProcessPool;
     
    9394        String localStorageDirectory;
    9495        String mediaKeysStorageDirectory;
     96        String deviceIdHashSaltsStorageDirectory;
    9597        String resourceLoadStatisticsDirectory;
    9698        String javaScriptConfigurationDirectory;
     
    162164    StorageManager* storageManager() { return m_storageManager.get(); }
    163165
     166    DeviceIdHashSaltStorage* deviceIdHashSaltStorage() { return m_deviceIdHashSaltStorage.get(); }
     167
    164168    WebProcessPool* processPoolForCookieStorageOperations();
    165169    bool isAssociatedProcessPool(WebProcessPool&) const;
     
    236240
    237241    const RefPtr<StorageManager> m_storageManager;
     242    const RefPtr<DeviceIdHashSaltStorage> m_deviceIdHashSaltStorage;
    238243    RefPtr<WebResourceLoadStatisticsStore> m_resourceLoadStatistics;
    239244    bool m_resourceLoadStatisticsDebugMode { false };
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r236930 r237031  
    7777                00B9661A18E25AE100CE1F88 /* FindClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 00B9661818E25AE100CE1F88 /* FindClient.h */; };
    7878                07297F9F1C17BBEA003F0735 /* UserMediaPermissionCheckProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 07297F9D1C17BBEA003F0735 /* UserMediaPermissionCheckProxy.h */; };
     79                07297F9F1C17BBEA015F0735 /* DeviceIdHashSaltStorage.h in Headers */ = {isa = PBXBuildFile; fileRef = 07297F9D1C17BBEA223F0735 /* DeviceIdHashSaltStorage.h */; };
    7980                07297FA31C186ADB003F0735 /* WKUserMediaPermissionCheck.h in Headers */ = {isa = PBXBuildFile; fileRef = 07297FA11C186ADB003F0735 /* WKUserMediaPermissionCheck.h */; settings = {ATTRIBUTES = (Private, ); }; };
    8081                074E75FE1DF2211900D318EC /* UserMediaProcessManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 074E75FB1DF1FD1300D318EC /* UserMediaProcessManager.h */; };
     
    18351836                07297F9C1C17BBEA003F0735 /* UserMediaPermissionCheckProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMediaPermissionCheckProxy.cpp; sourceTree = "<group>"; };
    18361837                07297F9D1C17BBEA003F0735 /* UserMediaPermissionCheckProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserMediaPermissionCheckProxy.h; sourceTree = "<group>"; };
     1838                07297F9C1C1711EA003F0735 /* DeviceIdHashSaltStorage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DeviceIdHashSaltStorage.cpp; sourceTree = "<group>"; };
     1839                07297F9D1C17BBEA223F0735 /* DeviceIdHashSaltStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DeviceIdHashSaltStorage.h; sourceTree = "<group>"; };
    18371840                07297FA01C186ADB003F0735 /* WKUserMediaPermissionCheck.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKUserMediaPermissionCheck.cpp; sourceTree = "<group>"; };
    18381841                07297FA11C186ADB003F0735 /* WKUserMediaPermissionCheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKUserMediaPermissionCheck.h; sourceTree = "<group>"; };
     
    71867189                                E1513C64166EABB200149FCB /* ChildProcessProxy.cpp */,
    71877190                                E1513C65166EABB200149FCB /* ChildProcessProxy.h */,
     7191                                07297F9C1C1711EA003F0735 /* DeviceIdHashSaltStorage.cpp */,
     7192                                07297F9D1C17BBEA223F0735 /* DeviceIdHashSaltStorage.h */,
    71887193                                BC2652121182608100243E12 /* DrawingAreaProxy.cpp */,
    71897194                                BC2652131182608100243E12 /* DrawingAreaProxy.h */,
     
    88588863                                BC032DA610F437D10058C15A /* Decoder.h in Headers */,
    88598864                                57DCEDAB214C60090016B847 /* DeviceIdentitySPI.h in Headers */,
     8865                                07297F9F1C17BBEA015F0735 /* DeviceIdHashSaltStorage.h in Headers */,
    88608866                                83891B6C1A68C30B0030F386 /* DiagnosticLoggingClient.h in Headers */,
    88618867                                C18173612058424700DFDA65 /* DisplayLink.h in Headers */,
     
    1059510601                                2D92A77E212B6A7100F493FD /* DataReference.cpp in Sources */,
    1059610602                                2D92A77F212B6A7100F493FD /* Decoder.cpp in Sources */,
     10603                                07297F9E1C17BBEA014F0735 /* DeviceIdHashSaltStorage.cpp in Sources */,
    1059710604                                1AB7D6191288B9D900CFD08C /* DownloadProxyMessageReceiver.cpp in Sources */,
    1059810605                                1A64229912DD029200CAAE2C /* DrawingAreaMessageReceiver.cpp in Sources */,
  • trunk/Tools/ChangeLog

    r237023 r237031  
     12018-10-11  Alejandro G. Castro  <alex@igalia.com>
     2
     3        [GTK][WPE] Add mediaDevices.enumerateDevices support
     4        https://bugs.webkit.org/show_bug.cgi?id=185761
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Added new API test for the mediaDevices.enumerateDevices:
     9        usermedia-enumeratedevices-permission-check. And a new API test
     10        for the WebsiteDataStore: testWebsiteDataDeviceIdHashSalt.
     11
     12        * MiniBrowser/gtk/main.c:
     13        (gotWebsiteDataCallback): Added a new section to the about:data
     14        webpage to include the information about the hash salt.
     15        * TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp:
     16        (testWebViewUserMediaEnumerateDevicesPermissionCheck): Added the
     17        new test checking the enumerateDevices API when permission is
     18        denied and when permission is allowed for the origin.
     19        (beforeAll): Defined the new test.
     20        * TestWebKitAPI/Tests/WebKitGLib/TestWebsiteData.cpp:
     21        (serverCallback): Register a new URI for the enumerateDevices.
     22        (testWebsiteDataConfiguration): Remove the hash salts from the
     23        directories.
     24        (testWebsiteDataDeviceIdHashSalt): New test cheking the
     25        enumerateDevices API.
     26        (beforeAll): Added the new test testWebsiteDataDeviceIdHashSalt to
     27        the init structure.
     28        * TestWebKitAPI/glib/WebKitGLib/WebViewTest.cpp:
     29        (WebViewTest::initializeWebView): Make sure the media-stream is
     30        activated in the webView.
     31
    1322018-10-10  Fujii Hironori  <Hironori.Fujii@sony.com>
    233
  • trunk/Tools/MiniBrowser/gtk/main.c

    r232834 r237031  
    403403    guint64 pageID = webkit_web_view_get_page_id(webkit_uri_scheme_request_get_web_view(dataRequest->request));
    404404    aboutDataFillTable(result, dataRequest, dataList, "Cookies", WEBKIT_WEBSITE_DATA_COOKIES, NULL, pageID);
     405    aboutDataFillTable(result, dataRequest, dataList, "Device Id Hash Salt", WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT, NULL, pageID);
    405406    aboutDataFillTable(result, dataRequest, dataList, "Memory Cache", WEBKIT_WEBSITE_DATA_MEMORY_CACHE, NULL, pageID);
    406407    aboutDataFillTable(result, dataRequest, dataList, "Disk Cache", WEBKIT_WEBSITE_DATA_DISK_CACHE, webkit_website_data_manager_get_disk_cache_directory(manager), pageID);
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp

    r235969 r237031  
    835835
    836836#if ENABLE(MEDIA_STREAM)
     837static void testWebViewUserMediaEnumerateDevicesPermissionCheck(UIClientTest* test, gconstpointer)
     838{
     839    WebKitSettings* settings = webkit_web_view_get_settings(test->m_webView);
     840    gboolean enabled = webkit_settings_get_enable_media_stream(settings);
     841    webkit_settings_set_enable_media_stream(settings, TRUE);
     842
     843#if PLATFORM(GTK)
     844    test->showInWindowAndWaitUntilMapped();
     845#endif
     846    static const char* userMediaRequestHTML =
     847        "<html>"
     848        "  <script>"
     849        "  function runTest()"
     850        "  {"
     851        "    navigator.mediaDevices.enumerateDevices().then("
     852        "        function(devices) { "
     853        "            devices.forEach(function(device) {"
     854        "                                if (device.label) document.title = \"OK\";"
     855        "                                             else document.title = \"Permission denied\";"
     856        "            })"
     857        "    })"
     858        "  }"
     859        "  </script>"
     860        "  <body onload='runTest();'></body>"
     861        "</html>";
     862
     863    test->m_verifyMediaTypes = TRUE;
     864
     865    // Test denying a permission request.
     866    test->m_allowPermissionRequests = false;
     867    test->loadHtml(userMediaRequestHTML, nullptr);
     868    test->waitUntilTitleChangedTo("Permission denied");
     869
     870    // Test allowing a permission request.
     871    test->m_allowPermissionRequests = true;
     872    test->loadHtml(userMediaRequestHTML, nullptr);
     873    test->waitUntilTitleChangedTo("OK");
     874
     875    webkit_settings_set_enable_media_stream(settings, enabled);
     876}
     877
    837878static void testWebViewUserMediaPermissionRequests(UIClientTest* test, gconstpointer)
    838879{
     
    11571198#endif
    11581199#if ENABLE(MEDIA_STREAM)
     1200    UIClientTest::add("WebKitWebView", "usermedia-enumeratedevices-permission-check", testWebViewUserMediaEnumerateDevicesPermissionCheck);
    11591201    UIClientTest::add("WebKitWebView", "usermedia-permission-requests", testWebViewUserMediaPermissionRequests);
    11601202    UIClientTest::add("WebKitWebView", "audio-usermedia-permission-request", testWebViewAudioOnlyUserMediaPermissionRequests);
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebsiteData.cpp

    r232010 r237031  
    2222#include "WebKitTestServer.h"
    2323#include "WebViewTest.h"
     24#include <glib/gstdio.h>
    2425
    2526static WebKitTestServer* kServer;
     
    6061        const char* localStorageHTML = "<html><body onload=\"localStorage.foo = 'bar';\"></body></html>";
    6162        soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, localStorageHTML, strlen(localStorageHTML));
     63        soup_message_body_complete(message->response_body);
     64        soup_message_set_status(message, SOUP_STATUS_OK);
     65    } else if (g_str_equal(path, "/enumeratedevices")) {
     66        const char* enumerateDevicesHTML = "<html><body onload=\"navigator.mediaDevices.enumerateDevices().then(function(devices) { document.title = 'Finished'; })\"></body></html>";
     67        soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, enumerateDevicesHTML, strlen(enumerateDevicesHTML));
    6268        soup_message_body_complete(message->response_body);
    6369        soup_message_set_status(message, SOUP_STATUS_OK);
     
    164170    // Clear all persistent caches, since the data dir is common to all test cases.
    165171    static const WebKitWebsiteDataTypes persistentCaches = static_cast<WebKitWebsiteDataTypes>(WEBKIT_WEBSITE_DATA_DISK_CACHE | WEBKIT_WEBSITE_DATA_LOCAL_STORAGE
    166         | WEBKIT_WEBSITE_DATA_WEBSQL_DATABASES | WEBKIT_WEBSITE_DATA_INDEXEDDB_DATABASES | WEBKIT_WEBSITE_DATA_OFFLINE_APPLICATION_CACHE);
     172        | WEBKIT_WEBSITE_DATA_WEBSQL_DATABASES | WEBKIT_WEBSITE_DATA_INDEXEDDB_DATABASES | WEBKIT_WEBSITE_DATA_OFFLINE_APPLICATION_CACHE | WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT);
    167173    test->clear(persistentCaches, 0);
    168174    g_assert(!test->fetch(persistentCaches));
     
    518524}
    519525
     526static void testWebsiteDataDeviceIdHashSalt(WebsiteDataTest* test, gconstpointer)
     527{
     528    test->clear(WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT, 0);
     529
     530    GList* dataList = test->fetch(WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT);
     531    g_assert(!dataList);
     532
     533    test->loadURI(kServer->getURIForPath("/enumeratedevices").data());
     534    test->waitUntilTitleChangedTo("Finished");
     535
     536    dataList = test->fetch(WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT);
     537    g_assert(dataList);
     538
     539    g_assert_cmpuint(g_list_length(dataList), ==, 1);
     540    WebKitWebsiteData* data = static_cast<WebKitWebsiteData*>(dataList->data);
     541    g_assert(data);
     542    WebKitSecurityOrigin* origin = webkit_security_origin_new_for_uri(kServer->getURIForPath("/").data());
     543    g_assert_cmpstr(webkit_website_data_get_name(data), ==, webkit_security_origin_get_host(origin));
     544    webkit_security_origin_unref(origin);
     545    g_assert_cmpuint(webkit_website_data_get_types(data), ==, WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT);
     546
     547    GList removeList = { data, nullptr, nullptr };
     548    test->remove(WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT, &removeList);
     549    dataList = test->fetch(WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT);
     550    g_assert(!dataList);
     551
     552    // Test removing the cookies.
     553    test->loadURI(kServer->getURIForPath("/enumeratedevices").data());
     554    test->waitUntilTitleChangedTo("Finished");
     555
     556    dataList = test->fetch(WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT);
     557    g_assert(dataList);
     558    data = static_cast<WebKitWebsiteData*>(dataList->data);
     559    g_assert(data);
     560
     561    GList removeCookieList = { data, nullptr, nullptr };
     562    test->remove(WEBKIT_WEBSITE_DATA_COOKIES, &removeCookieList);
     563    dataList = test->fetch(WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT);
     564    g_assert(!dataList);
     565
     566    // Clear all.
     567    static const WebKitWebsiteDataTypes cacheAndAppcacheTypes = static_cast<WebKitWebsiteDataTypes>(WEBKIT_WEBSITE_DATA_DEVICE_ID_HASH_SALT);
     568    test->clear(cacheAndAppcacheTypes, 0);
     569    dataList = test->fetch(cacheAndAppcacheTypes);
     570    g_assert(!dataList);
     571}
     572
    520573void beforeAll()
    521574{
     
    530583    WebsiteDataTest::add("WebKitWebsiteData", "appcache", testWebsiteDataAppcache);
    531584    WebsiteDataTest::add("WebKitWebsiteData", "cookies", testWebsiteDataCookies);
     585    WebsiteDataTest::add("WebKitWebsiteData", "deviceidhashsalt", testWebsiteDataDeviceIdHashSalt);
    532586}
    533587
  • trunk/Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.cpp

    r232671 r237031  
    4949{
    5050    g_assert(!m_webView);
     51
     52    WebKitSettings* webkitSettings = webkit_settings_new();
     53    webkit_settings_set_enable_media_stream(webkitSettings, TRUE);
     54
    5155    m_webView = WEBKIT_WEB_VIEW(g_object_new(WEBKIT_TYPE_WEB_VIEW,
    5256#if PLATFORM(WPE)
    5357        "backend", Test::createWebViewBackend(),
    5458#endif
     59        "settings", webkitSettings,
    5560        "web-context", m_webContext.get(),
    5661        "user-content-manager", m_userContentManager.get(),
Note: See TracChangeset for help on using the changeset viewer.