Source/WebCore/ChangeLog

 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
320 Rename a couple of DOMWindowProperty virtual functions

Source/WebKit/ChangeLog

 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
3119 Safari crashes when attempting to share a YouTube video while in full-screen

Source/WebCore/Modules/mediastream/MediaDevicesRequest.cpp

@@void MediaDevicesRequest::contextDestroyed()
8181
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
9692 int cameraCount = 0;

@@void MediaDevicesRequest::filterDeviceList(Vector<Ref<MediaDeviceInfo>>& devices
10399
104100 return false;
105101 });
106 
107 #endif
108102}
109103
110104void MediaDevicesRequest::start()

Source/WebKit/Shared/WebsiteData/WebsiteDataType.h

@@enum class WebsiteDataType {
4949 ServiceWorkerRegistrations = 1 << 14,
5050#endif
5151 DOMCache = 1 << 15,
 52 DeviceIdHashSalt = 1 << 16,
5253};
5354
5455};

Source/WebKit/Sources.txt

@@UIProcess/FrameLoadState.cpp
228228UIProcess/GeolocationPermissionRequestManagerProxy.cpp
229229UIProcess/GeolocationPermissionRequestProxy.cpp
230230UIProcess/PageLoadState.cpp
 231UIProcess/DeviceIdHashSaltStorage.cpp
231232UIProcess/ProcessAssertion.cpp
232233UIProcess/ProcessThrottler.cpp
233234UIProcess/RemoteWebInspectorProxy.cpp

Source/WebKit/SourcesGTK.txt

@@UIProcess/API/glib/WebKitContextMenuClient.cpp @no-unify
133133UIProcess/API/glib/WebKitCookieManager.cpp @no-unify
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
138139UIProcess/API/glib/WebKitEditorState.cpp @no-unify

Source/WebKit/SourcesWPE.txt

@@UIProcess/API/glib/WebKitContextMenuClient.cpp @no-unify
120120UIProcess/API/glib/WebKitCookieManager.cpp @no-unify
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
125126UIProcess/API/glib/WebKitEditorState.cpp @no-unify

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

 1/*
 2 * Copyright (C) 2018 Igalia S.L
 3 *
 4 * This library is free software; you can redistribute it and/or
 5 * modify it under the terms of the GNU Lesser General Public
 6 * License as published by the Free Software Foundation; either
 7 * version 2 of the License, or (at your option) any later version.
 8 *
 9 * This library is distributed in the hope that it will be useful,
 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12 * Lesser General Public License for more details.
 13 *
 14 * You should have received a copy of the GNU Lesser General Public
 15 * License along with this library; if not, write to the Free Software
 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 17 */
 18
 19#include "config.h"
 20#include "WebKitDeviceInfoPermissionRequest.h"
 21
 22#include "DeviceIdHashSaltStorage.h"
 23#include "UserMediaPermissionCheckProxy.h"
 24#include "WebKitDeviceInfoPermissionRequestPrivate.h"
 25#include "WebKitPermissionRequest.h"
 26#include "WebsiteDataStore.h"
 27#include <glib/gi18n-lib.h>
 28#include <wtf/glib/WTFGType.h>
 29
 30using namespace WebKit;
 31
 32/**
 33 * SECTION: WebKitDeviceInfoPermissionRequest
 34 * @Short_description: A permission request for accessing user's audio/video devices.
 35 * @Title: WebKitDeviceInfoPermissionRequest
 36 * @See_also: #WebKitPermissionRequest, #WebKitWebView
 37 *
 38 * WebKitUserMediaPermissionRequest represents a request for
 39 * permission to whether WebKit should be allowed to access the user's
 40 * devices information when requested through the enumeraceDevices API.
 41 *
 42 * When a WebKitDeviceInfoPermissionRequest is not handled by the user,
 43 * it is denied by default.
 44 *
 45 * Since: 2.22
 46 */
 47
 48static void webkit_permission_request_interface_init(WebKitPermissionRequestIface*);
 49
 50struct _WebKitDeviceInfoPermissionRequestPrivate {
 51 RefPtr<UserMediaPermissionCheckProxy> request;
 52 RefPtr<DeviceIdHashSaltStorage> deviceIdHashSaltStorage;
 53 bool madeDecision;
 54};
 55
 56WEBKIT_DEFINE_TYPE_WITH_CODE(
 57 WebKitDeviceInfoPermissionRequest, webkit_device_info_permission_request, G_TYPE_OBJECT,
 58 G_IMPLEMENT_INTERFACE(WEBKIT_TYPE_PERMISSION_REQUEST, webkit_permission_request_interface_init))
 59
 60static void webkitDeviceInfoPermissionRequestAllow(WebKitPermissionRequest* request)
 61{
 62 ASSERT(WEBKIT_IS_DEVICE_INFO_PERMISSION_REQUEST(request));
 63
 64 auto& priv = WEBKIT_DEVICE_INFO_PERMISSION_REQUEST(request)->priv;
 65
 66 if (!priv->deviceIdHashSaltStorage) {
 67 priv->request->setUserMediaAccessInfo(String(), false);
 68 return;
 69 }
 70
 71 // Only one decision at a time.
 72 if (priv->madeDecision)
 73 return;
 74
 75 priv->madeDecision = true;
 76 auto salt = priv->deviceIdHashSaltStorage->deviceIdHashSaltForOrigin(priv->request->topLevelDocumentSecurityOrigin());
 77 priv->request->setUserMediaAccessInfo(WTFMove(salt), true);
 78}
 79
 80static void webkitDeviceInfoPermissionRequestDeny(WebKitPermissionRequest* request)
 81{
 82 ASSERT(WEBKIT_IS_DEVICE_INFO_PERMISSION_REQUEST(request));
 83
 84 auto& priv = WEBKIT_DEVICE_INFO_PERMISSION_REQUEST(request)->priv;
 85
 86 if (!priv->deviceIdHashSaltStorage) {
 87 priv->request->setUserMediaAccessInfo(String(), false);
 88 return;
 89 }
 90
 91 // Only one decision at a time.
 92 if (priv->madeDecision)
 93 return;
 94
 95 priv->madeDecision = true;
 96 auto salt = priv->deviceIdHashSaltStorage->regenerateDeviceIdHashSaltForOrigin(*priv->request);
 97 priv->request->setUserMediaAccessInfo(WTFMove(salt), false);
 98}
 99
 100static void webkit_permission_request_interface_init(WebKitPermissionRequestIface* iface)
 101{
 102 iface->allow = webkitDeviceInfoPermissionRequestAllow;
 103 iface->deny = webkitDeviceInfoPermissionRequestDeny;
 104}
 105
 106static void webkitDeviceInfoPermissionRequestDispose(GObject* object)
 107{
 108 // Default behaviour when no decision has been made is denying the request.
 109 webkitDeviceInfoPermissionRequestDeny(WEBKIT_PERMISSION_REQUEST(object));
 110 G_OBJECT_CLASS(webkit_device_info_permission_request_parent_class)->dispose(object);
 111}
 112
 113static void webkit_device_info_permission_request_class_init(WebKitDeviceInfoPermissionRequestClass* klass)
 114{
 115 GObjectClass* objectClass = G_OBJECT_CLASS(klass);
 116 objectClass->dispose = webkitDeviceInfoPermissionRequestDispose;
 117}
 118
 119WebKitDeviceInfoPermissionRequest* webkitDeviceInfoPermissionRequestCreate(UserMediaPermissionCheckProxy& request, DeviceIdHashSaltStorage* deviceIdHashSaltStorage)
 120{
 121 auto* deviceInfoPermissionRequest = WEBKIT_DEVICE_INFO_PERMISSION_REQUEST(g_object_new(WEBKIT_TYPE_DEVICE_INFO_PERMISSION_REQUEST, nullptr));
 122
 123 deviceInfoPermissionRequest->priv->request = &request;
 124 deviceInfoPermissionRequest->priv->deviceIdHashSaltStorage = deviceIdHashSaltStorage;
 125 return deviceInfoPermissionRequest;
 126}

Source/WebKit/UIProcess/API/glib/WebKitDeviceInfoPermissionRequestPrivate.h

 1/*
 2 * Copyright (C) 2018 Igalia S.L
 3 *
 4 * This library is free software; you can redistribute it and/or
 5 * modify it under the terms of the GNU Lesser General Public
 6 * License as published by the Free Software Foundation; either
 7 * version 2 of the License, or (at your option) any later version.
 8 *
 9 * This library is distributed in the hope that it will be useful,
 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12 * Lesser General Public License for more details.
 13 *
 14 * You should have received a copy of the GNU Lesser General Public
 15 * License along with this library; if not, write to the Free Software
 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 17 */
 18
 19#pragma once
 20
 21#include "APISecurityOrigin.h"
 22
 23typedef struct _WebKitDeviceInfoPermissionRequest WebKitDeviceInfoPermissionRequest;
 24
 25namespace WebKit {
 26class DeviceIdHashSaltStorage;
 27};
 28
 29WebKitDeviceInfoPermissionRequest* webkitDeviceInfoPermissionRequestCreate(WebKit::UserMediaPermissionCheckProxy&, WebKit::DeviceIdHashSaltStorage*);

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

2222
2323#include "APIUIClient.h"
2424#include "DrawingAreaProxy.h"
 25#include "WebKitDeviceInfoPermissionRequestPrivate.h"
2526#include "WebKitFileChooserRequestPrivate.h"
2627#include "WebKitGeolocationPermissionRequestPrivate.h"
2728#include "WebKitNavigationActionPrivate.h"

3233#include "WebKitWindowPropertiesPrivate.h"
3334#include "WebPageProxy.h"
3435#include "WebProcessProxy.h"
 36#include "WebsiteDataStore.h"
3537#include <wtf/glib/GRefPtr.h>
3638
3739#if PLATFORM(GTK)

@@private:
189191 return true;
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 {
194203 GRefPtr<WebKitNotificationPermissionRequest> notificationPermissionRequest = adoptGRef(webkitNotificationPermissionRequestCreate(NotificationPermissionRequest::create(WTFMove(completionHandler)).ptr()));

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

@@static bool recordContainsSupportedDataTypes(const WebsiteDataRecord& record)
7676#if ENABLE(NETSCAPE_PLUGIN_API)
7777 WebsiteDataType::PlugInData,
7878#endif
79  WebsiteDataType::Cookies
 79 WebsiteDataType::Cookies,
 80 WebsiteDataType::DeviceIdHashSalt
8081 });
8182}
8283

@@static WebKitWebsiteDataTypes toWebKitWebsiteDataTypes(OptionSet<WebsiteDataType
103104#endif
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}
108111

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

@@static OptionSet<WebsiteDataType> toWebsiteDataTypes(WebKitWebsiteDataTypes type
649649#endif
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}
654656

@@void webkit_website_data_manager_remove(WebKitWebsiteDataManager* manager, WebKi
732734 for (GList* item = websiteData; item; item = g_list_next(item)) {
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 }
738745

Source/WebKit/UIProcess/API/gtk/WebKitDeviceInfoPermissionRequest.h

 1/*
 2 * Copyright (C) 2018 Igalia S.L
 3 *
 4 * This library is free software; you can redistribute it and/or
 5 * modify it under the terms of the GNU Lesser General Public
 6 * License as published by the Free Software Foundation; either
 7 * version 2 of the License, or (at your option) any later version.
 8 *
 9 * This library is distributed in the hope that it will be useful,
 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12 * Lesser General Public License for more details.
 13 *
 14 * You should have received a copy of the GNU Lesser General Public
 15 * License along with this library; if not, write to the Free Software
 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 17 */
 18
 19#if !defined(__WEBKIT2_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
 20#error "Only <webkit2/webkit2.h> can be included directly."
 21#endif
 22
 23#ifndef WebKitDeviceInfoPermissionRequest_h
 24#define WebKitDeviceInfoPermissionRequest_h
 25
 26#include <glib-object.h>
 27#include <webkit2/WebKitDefines.h>
 28
 29G_BEGIN_DECLS
 30
 31#define WEBKIT_TYPE_DEVICE_INFO_PERMISSION_REQUEST (webkit_device_info_permission_request_get_type())
 32#define WEBKIT_DEVICE_INFO_PERMISSION_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_DEVICE_INFO_PERMISSION_REQUEST, WebKitDeviceInfoPermissionRequest))
 33#define WEBKIT_DEVICE_INFO_PERMISSION_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_DEVICE_INFO_PERMISSION_REQUEST, WebKitDeviceInfoPermissionRequestClass))
 34#define WEBKIT_IS_DEVICE_INFO_PERMISSION_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_DEVICE_INFO_PERMISSION_REQUEST))
 35#define WEBKIT_IS_DEVICE_INFO_PERMISSION_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_DEVICE_INFO_PERMISSION_REQUEST))
 36#define WEBKIT_DEVICE_INFO_PERMISSION_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_DEVICE_INFO_PERMISSION_REQUEST, WebKitDeviceInfoPermissionRequestClass))
 37
 38typedef struct _WebKitDeviceInfoPermissionRequest WebKitDeviceInfoPermissionRequest;
 39typedef struct _WebKitDeviceInfoPermissionRequestClass WebKitDeviceInfoPermissionRequestClass;
 40typedef struct _WebKitDeviceInfoPermissionRequestPrivate WebKitDeviceInfoPermissionRequestPrivate;
 41
 42struct _WebKitDeviceInfoPermissionRequest {
 43 GObject parent;
 44
 45 /*< private >*/
 46 WebKitDeviceInfoPermissionRequestPrivate *priv;
 47};
 48
 49struct _WebKitDeviceInfoPermissionRequestClass {
 50 GObjectClass parent_class;
 51
 52 void (*_webkit_reserved0) (void);
 53 void (*_webkit_reserved1) (void);
 54 void (*_webkit_reserved2) (void);
 55 void (*_webkit_reserved3) (void);
 56};
 57
 58WEBKIT_API GType
 59webkit_device_info_permission_request_get_type (void);
 60
 61G_END_DECLS
 62
 63#endif

Source/WebKit/UIProcess/API/gtk/WebKitWebsiteData.h

@@typedef struct _WebKitWebsiteData WebKitWebsiteData;
4444 * @WEBKIT_WEBSITE_DATA_INDEXEDDB_DATABASES: IndexedDB databases.
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 *
4950 * Enum values with flags representing types of Website data.

@@typedef enum {
6061 WEBKIT_WEBSITE_DATA_INDEXEDDB_DATABASES = 1 << 6,
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
6668WEBKIT_API GType

Source/WebKit/UIProcess/API/wpe/WebKitDeviceInfoPermissionRequest.h

 1/*
 2 * Copyright (C) 2018 Igalia S.L
 3 *
 4 * This library is free software; you can redistribute it and/or
 5 * modify it under the terms of the GNU Lesser General Public
 6 * License as published by the Free Software Foundation; either
 7 * version 2 of the License, or (at your option) any later version.
 8 *
 9 * This library is distributed in the hope that it will be useful,
 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12 * Lesser General Public License for more details.
 13 *
 14 * You should have received a copy of the GNU Lesser General Public
 15 * License along with this library; if not, write to the Free Software
 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 17 */
 18
 19#if !defined(__WEBKIT_H_INSIDE__) && !defined(WEBKIT2_COMPILATION)
 20#error "Only <wpe/webkit.h> can be included directly."
 21#endif
 22
 23#ifndef WebKitDeviceInfoPermissionRequest_h
 24#define WebKitDeviceInfoPermissionRequest_h
 25
 26#include <glib-object.h>
 27#include <wpe/WebKitDefines.h>
 28
 29G_BEGIN_DECLS
 30
 31#define WEBKIT_TYPE_DEVICE_INFO_PERMISSION_REQUEST (webkit_device_info_permission_request_get_type())
 32#define WEBKIT_DEVICE_INFO_PERMISSION_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), WEBKIT_TYPE_DEVICE_INFO_PERMISSION_REQUEST, WebKitDeviceInfoPermissionRequest))
 33#define WEBKIT_DEVICE_INFO_PERMISSION_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), WEBKIT_TYPE_DEVICE_INFO_PERMISSION_REQUEST, WebKitDeviceInfoPermissionRequestClass))
 34#define WEBKIT_IS_DEVICE_INFO_PERMISSION_REQUEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), WEBKIT_TYPE_DEVICE_INFO_PERMISSION_REQUEST))
 35#define WEBKIT_IS_DEVICE_INFO_PERMISSION_REQUEST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), WEBKIT_TYPE_DEVICE_INFO_PERMISSION_REQUEST))
 36#define WEBKIT_DEVICE_INFO_PERMISSION_REQUEST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), WEBKIT_TYPE_DEVICE_INFO_PERMISSION_REQUEST, WebKitDeviceInfoPermissionRequestClass))
 37
 38typedef struct _WebKitDeviceInfoPermissionRequest WebKitDeviceInfoPermissionRequest;
 39typedef struct _WebKitDeviceInfoPermissionRequestClass WebKitDeviceInfoPermissionRequestClass;
 40typedef struct _WebKitDeviceInfoPermissionRequestPrivate WebKitDeviceInfoPermissionRequestPrivate;
 41
 42struct _WebKitDeviceInfoPermissionRequest {
 43 GObject parent;
 44
 45 /*< private >*/
 46 WebKitDeviceInfoPermissionRequestPrivate *priv;
 47};
 48
 49struct _WebKitDeviceInfoPermissionRequestClass {
 50 GObjectClass parent_class;
 51
 52 void (*_webkit_reserved0) (void);
 53 void (*_webkit_reserved1) (void);
 54 void (*_webkit_reserved2) (void);
 55 void (*_webkit_reserved3) (void);
 56};
 57
 58WEBKIT_API GType
 59webkit_device_info_permission_request_get_type (void);
 60
 61G_END_DECLS
 62
 63#endif

Source/WebKit/UIProcess/API/wpe/WebKitWebsiteData.h

@@typedef struct _WebKitWebsiteData WebKitWebsiteData;
4444 * @WEBKIT_WEBSITE_DATA_INDEXEDDB_DATABASES: IndexedDB databases.
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 *
4950 * Enum values with flags representing types of Website data.

@@typedef enum {
6061 WEBKIT_WEBSITE_DATA_INDEXEDDB_DATABASES = 1 << 6,
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
6668WEBKIT_API GType

Source/WebKit/UIProcess/DeviceIdHashSaltStorage.cpp

 1/*
 2 * Copyright (C) 2018 Igalia S.L. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "DeviceIdHashSaltStorage.h"
 28
 29#include <WebCore/FileSystem.h>
 30#include <wtf/CryptographicallyRandomNumber.h>
 31#include <wtf/HexNumber.h>
 32#include <wtf/RunLoop.h>
 33#include <wtf/text/StringBuilder.h>
 34#include <wtf/text/StringHash.h>
 35
 36// FIXME: Implement persistency.
 37
 38namespace WebKit {
 39using namespace WebCore;
 40
 41static const int hashSaltSize = 48;
 42static const int randomDataSize = hashSaltSize / 16;
 43
 44Ref<DeviceIdHashSaltStorage> DeviceIdHashSaltStorage::create()
 45{
 46 return adoptRef(*new DeviceIdHashSaltStorage());
 47}
 48
 49const String& DeviceIdHashSaltStorage::regenerateDeviceIdHashSaltForOrigin(UserMediaPermissionCheckProxy& request)
 50{
 51 auto& documentOrigin = request.topLevelDocumentSecurityOrigin();
 52
 53 auto documentOriginData = documentOrigin.data();
 54 m_deviceIdHashSaltForOrigins.removeIf([&documentOriginData](auto& keyAndValue) {
 55 return keyAndValue.value->documentOrigin == documentOriginData;
 56 });
 57
 58 return deviceIdHashSaltForOrigin(documentOrigin);
 59}
 60
 61const String& DeviceIdHashSaltStorage::deviceIdHashSaltForOrigin(SecurityOrigin& documentOrigin)
 62{
 63 auto& deviceIdHashSalt = m_deviceIdHashSaltForOrigins.ensure(documentOrigin.toRawString(), [&documentOrigin] () {
 64 uint64_t randomData[randomDataSize];
 65 cryptographicallyRandomValues(reinterpret_cast<unsigned char*>(randomData), sizeof(randomData));
 66
 67 StringBuilder builder;
 68 builder.reserveCapacity(hashSaltSize);
 69 for (int i = 0; i < randomDataSize; i++)
 70 appendUnsigned64AsHex(randomData[0], builder);
 71
 72 String deviceIdHashSalt = builder.toString();
 73
 74 return std::make_unique<HashSaltForOrigin>(documentOrigin.data().isolatedCopy(), WTFMove(deviceIdHashSalt));
 75 }).iterator->value;
 76
 77 deviceIdHashSalt->lastTimeUsed = WallTime::now();
 78
 79 return deviceIdHashSalt->deviceIdHashSalt;
 80}
 81
 82void DeviceIdHashSaltStorage::getDeviceIdHashSaltOrigins(CompletionHandler<void(HashSet<SecurityOriginData>&&)>&& completionHandler)
 83{
 84 HashSet<SecurityOriginData> origins;
 85
 86 for (auto& hashSaltForOrigin : m_deviceIdHashSaltForOrigins)
 87 origins.add(hashSaltForOrigin.value->documentOrigin);
 88
 89 RunLoop::main().dispatch([origins = WTFMove(origins), completionHandler = WTFMove(completionHandler)]() mutable {
 90 completionHandler(WTFMove(origins));
 91 });
 92}
 93
 94void DeviceIdHashSaltStorage::deleteDeviceIdHashSaltForOrigins(const Vector<SecurityOriginData>& origins, CompletionHandler<void()>&& completionHandler)
 95{
 96 m_deviceIdHashSaltForOrigins.removeIf([&origins](auto& keyAndValue) {
 97 return origins.contains(keyAndValue.value->documentOrigin);
 98 });
 99
 100 RunLoop::main().dispatch(WTFMove(completionHandler));
 101}
 102
 103void DeviceIdHashSaltStorage::deleteDeviceIdHashSaltOriginsModifiedSince(WallTime time, CompletionHandler<void()>&& completionHandler)
 104{
 105 m_deviceIdHashSaltForOrigins.removeIf([time](auto& keyAndValue) {
 106 return keyAndValue.value->lastTimeUsed > time;
 107 });
 108
 109 RunLoop::main().dispatch(WTFMove(completionHandler));
 110}
 111
 112} // namespace WebKit

Source/WebKit/UIProcess/DeviceIdHashSaltStorage.h

 1/*
 2 * Copyright (C) 2018 Igalia S.L. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#include "UserMediaPermissionCheckProxy.h"
 29#include <WebCore/SecurityOrigin.h>
 30#include <wtf/HashMap.h>
 31#include <wtf/HashSet.h>
 32#include <wtf/Ref.h>
 33
 34namespace WebKit {
 35
 36class DeviceIdHashSaltStorage : public RefCounted<DeviceIdHashSaltStorage> {
 37public:
 38 static Ref<DeviceIdHashSaltStorage> create();
 39 ~DeviceIdHashSaltStorage() = default;
 40
 41 const String& deviceIdHashSaltForOrigin(WebCore::SecurityOrigin&);
 42 const String& regenerateDeviceIdHashSaltForOrigin(UserMediaPermissionCheckProxy&);
 43
 44 void getDeviceIdHashSaltOrigins(CompletionHandler<void(HashSet<WebCore::SecurityOriginData>&&)>&&);
 45 void deleteDeviceIdHashSaltForOrigins(const Vector<WebCore::SecurityOriginData>&, CompletionHandler<void()>&&);
 46 void deleteDeviceIdHashSaltOriginsModifiedSince(WallTime, CompletionHandler<void()>&&);
 47
 48private:
 49 struct HashSaltForOrigin {
 50 HashSaltForOrigin(WebCore::SecurityOriginData&& securityOrigin, String&& deviceIdHashSalt)
 51 : documentOrigin(securityOrigin)
 52 , deviceIdHashSalt(WTFMove(deviceIdHashSalt))
 53 , lastTimeUsed(WallTime::now())
 54 { };
 55
 56 WebCore::SecurityOriginData documentOrigin;
 57 String deviceIdHashSalt;
 58 WallTime lastTimeUsed;
 59 };
 60
 61 DeviceIdHashSaltStorage() = default;
 62
 63 HashMap<String, std::unique_ptr<HashSaltForOrigin>> m_deviceIdHashSaltForOrigins;
 64};
 65
 66} // namespace WebKit

Source/WebKit/UIProcess/UserMediaPermissionCheckProxy.h

@@class SecurityOrigin;
3636
3737namespace WebKit {
3838
39 class UserMediaPermissionRequestManagerProxy;
40 
4139class UserMediaPermissionCheckProxy : public API::ObjectImpl<API::Object::Type::UserMediaPermissionCheck> {
4240public:
4341

Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp

3030#include "APIWebsiteDataRecord.h"
3131#include "APIWebsiteDataStore.h"
3232#include "AuthenticatorManager.h"
 33#include "DeviceIdHashSaltStorage.h"
3334#include "MockAuthenticatorManager.h"
3435#include "NetworkProcessMessages.h"
3536#include "StorageManager.h"

@@WebsiteDataStore::WebsiteDataStore(Configuration configuration, PAL::SessionID s
9596 : m_sessionID(sessionID)
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)
100102 , m_authenticatorManager(makeUniqueRef<AuthenticatorManager>())

@@void WebsiteDataStore::fetchDataAndApply(OptionSet<WebsiteDataType> dataTypes, O
485487 });
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();
490505

@@void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, WallTime
800815 });
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();
805828

@@void WebsiteDataStore::removeData(OptionSet<WebsiteDataType> dataTypes, const Ve
10741097 });
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;
10791110 for (const auto& dataRecord : dataRecords) {

Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h

@@namespace WebKit {
5555class AuthenticatorManager;
5656class SecKeyProxyStore;
5757class StorageManager;
 58class DeviceIdHashSaltStorage;
5859class WebPageProxy;
5960class WebProcessPool;
6061class WebResourceLoadStatisticsStore;

@@public:
9293 String webSQLDatabaseDirectory;
9394 String localStorageDirectory;
9495 String mediaKeysStorageDirectory;
 96 String deviceIdHashSaltsStorageDirectory;
9597 String resourceLoadStatisticsDirectory;
9698 String javaScriptConfigurationDirectory;
9799 String cookieStorageFile;

@@public:
161163
162164 StorageManager* storageManager() { return m_storageManager.get(); }
163165
 166 DeviceIdHashSaltStorage* deviceIdHashSaltStorage() { return m_deviceIdHashSaltStorage.get(); }
 167
164168 WebProcessPool* processPoolForCookieStorageOperations();
165169 bool isAssociatedProcessPool(WebProcessPool&) const;
166170

@@private:
235239 bool m_hasResolvedDirectories { false };
236240
237241 const RefPtr<StorageManager> m_storageManager;
 242 const RefPtr<DeviceIdHashSaltStorage> m_deviceIdHashSaltStorage;
238243 RefPtr<WebResourceLoadStatisticsStore> m_resourceLoadStatistics;
239244 bool m_resourceLoadStatisticsDebugMode { false };
240245

Source/WebKit/WebKit.xcodeproj/project.pbxproj

7676 00B9661618E24CBA00CE1F88 /* APIFindClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 00B9661518E24CBA00CE1F88 /* APIFindClient.h */; };
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 */; };
8182 076E884E1A13CADF005E90FC /* APIContextMenuClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 076E884D1A13CADF005E90FC /* APIContextMenuClient.h */; };

18341835 00B9661818E25AE100CE1F88 /* FindClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FindClient.h; sourceTree = "<group>"; };
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>"; };
18391842 074E75FB1DF1FD1300D318EC /* UserMediaProcessManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserMediaProcessManager.h; sourceTree = "<group>"; };

71857188 46A2B6071E5675A200C3DEDA /* BackgroundProcessResponsivenessTimer.h */,
71867189 E1513C64166EABB200149FCB /* ChildProcessProxy.cpp */,
71877190 E1513C65166EABB200149FCB /* ChildProcessProxy.h */,
 7191 07297F9C1C1711EA003F0735 /* DeviceIdHashSaltStorage.cpp */,
 7192 07297F9D1C17BBEA223F0735 /* DeviceIdHashSaltStorage.h */,
71887193 BC2652121182608100243E12 /* DrawingAreaProxy.cpp */,
71897194 BC2652131182608100243E12 /* DrawingAreaProxy.h */,
71907195 1A6422FC12DD08FE00CAAE2C /* DrawingAreaProxy.messages.in */,

88578862 1AC75380183BE50F0072CB15 /* DataReference.h in Headers */,
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 */,
88628868 5C1427021C23F84C00D41183 /* Download.h in Headers */,

1059410600 2D92A77D212B6A7100F493FD /* Connection.cpp in Sources */,
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 */,
1059910606 1A64230812DD09EB00CAAE2C /* DrawingAreaProxyMessageReceiver.cpp in Sources */,

Tools/ChangeLog

 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
334 Add WinCairo to the flakiness dashboard

Tools/MiniBrowser/gtk/main.c

@@static void gotWebsiteDataCallback(WebKitWebsiteDataManager *manager, GAsyncResu
402402
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);
407408 aboutDataFillTable(result, dataRequest, dataList, "Session Storage", WEBKIT_WEBSITE_DATA_SESSION_STORAGE, NULL, pageID);

Tools/TestWebKitAPI/Tests/WebKitGLib/TestUIClient.cpp

@@static void testWebViewGeolocationPermissionRequests(UIClientTest* test, gconstp
834834#endif // ENABLE(GEOLOCATION)
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{
839880 WebKitSettings* settings = webkit_web_view_get_settings(test->m_webView);

@@void beforeAll()
11561197 UIClientTest::add("WebKitWebView", "geolocation-permission-requests", testWebViewGeolocationPermissionRequests);
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);
11611203#endif

Tools/TestWebKitAPI/Tests/WebKitGLib/TestWebsiteData.cpp

2121
2222#include "WebKitTestServer.h"
2323#include "WebViewTest.h"
 24#include <glib/gstdio.h>
2425
2526static WebKitTestServer* kServer;
2627

@@static void serverCallback(SoupServer* server, SoupMessage* message, const char*
6162 soup_message_body_append(message->response_body, SOUP_MEMORY_STATIC, localStorageHTML, strlen(localStorageHTML));
6263 soup_message_body_complete(message->response_body);
6364 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));
 68 soup_message_body_complete(message->response_body);
 69 soup_message_set_status(message, SOUP_STATUS_OK);
6470 } else
6571 soup_message_set_status(message, SOUP_STATUS_NOT_FOUND);
6672}

@@static void testWebsiteDataConfiguration(WebsiteDataTest* test, gconstpointer)
163169
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));
169175

@@static void testWebsiteDataCookies(WebsiteDataTest* test, gconstpointer)
517523 g_assert(!dataList);
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{
522575 kServer = new WebKitTestServer();

@@void beforeAll()
529582 WebsiteDataTest::add("WebKitWebsiteData", "databases", testWebsiteDataDatabases);
530583 WebsiteDataTest::add("WebKitWebsiteData", "appcache", testWebsiteDataAppcache);
531584 WebsiteDataTest::add("WebKitWebsiteData", "cookies", testWebsiteDataCookies);
 585 WebsiteDataTest::add("WebKitWebsiteData", "deviceidhashsalt", testWebsiteDataDeviceIdHashSalt);
532586}
533587
534588void afterAll()

Tools/TestWebKitAPI/glib/WebKitGLib/WebViewTest.cpp

@@WebViewTest::~WebViewTest()
4848void WebViewTest::initializeWebView()
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(),
5762 nullptr));

LayoutTests/ChangeLog

 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
322 Web Inspector: create special Network waterfall for media events

LayoutTests/platform/gtk/TestExpectations

@@webkit.org/b/79203 imported/w3c/web-platform-tests/mediacapture-streams/MediaStr
640640webkit.org/b/151344 fast/mediastream/MediaStream-add-ended-tracks.html [ Timeout ]
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
646645# Canvas captureStream support is not implemented