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