RESOLVED FIXED 152087
[MediaStream] Expose media capture devices persistent permissions to WebCore
https://bugs.webkit.org/show_bug.cgi?id=152087
Summary [MediaStream] Expose media capture devices persistent permissions to WebCore
Eric Carlson
Reported 2015-12-09 11:41:02 PST
Make it possible for WebCore to check to see if persistent permission to access media capture devices has been granted to the page's origin.
Attachments
Preliminary patch for the bots. (97.31 KB, patch)
2015-12-09 15:30 PST, Eric Carlson
no flags
Patch. (98.21 KB, patch)
2015-12-09 17:04 PST, Eric Carlson
no flags
Updated patch. (99.40 KB, patch)
2015-12-10 06:37 PST, Eric Carlson
cdumez: review+
cdumez: commit-queue-
Patch for landing. (112.65 KB, patch)
2015-12-10 11:51 PST, Eric Carlson
no flags
Another updated patch for landing. (112.64 KB, patch)
2015-12-10 13:02 PST, Eric Carlson
no flags
Eric Carlson
Comment 1 2015-12-09 15:30:56 PST
Created attachment 267052 [details] Preliminary patch for the bots. Patch without useful ChangeLog entries for the bots to mull over.
WebKit Commit Bot
Comment 2 2015-12-09 15:32:08 PST
Attachment 267052 [details] did not pass style-queue: ERROR: Source/WebCore/ChangeLog:8: You should remove the 'No new tests' and either add and list tests, or explain why no new tests were possible. [changelog/nonewtests] [5] Total errors found: 1 in 44 files If any of these errors are false positives, please file a bug against check-webkit-style.
Eric Carlson
Comment 3 2015-12-09 17:04:16 PST
Simon Fraser (smfr)
Comment 4 2015-12-09 17:12:49 PST
Comment on attachment 267056 [details] Patch. View in context: https://bugs.webkit.org/attachment.cgi?id=267056&action=review > Source/WebCore/Modules/mediastream/MediaDevicesRequest.cpp:86 > + m_hasUserMediaPermission = access; Is storing in m_hasUserMediaPermission thread-safe given the callOnMainThread() below? > Source/WebCore/Modules/mediastream/UserMediaController.h:67 > +inline void UserMediaController::checkUserMediaPermission(Ref<UserMediaPermissionCheck>&& request) I don't really like this model of a "check" function taking ownership of the UserMediaPermissionCheck passed in. > Source/WebCore/Modules/mediastream/UserMediaPermissionCheck.cpp:43 > +RefPtr<UserMediaPermissionCheck> UserMediaPermissionCheck::create(Document& document, UserMediaPermissionCheckClient& client) This should return a Ref<> > Source/WebCore/Modules/mediastream/UserMediaPermissionCheck.cpp:81 > + m_protector = this; Weird. Why doesn't someone own this explicitly? > Source/WebCore/Modules/mediastream/UserMediaPermissionCheck.h:69 > + RefPtr<UserMediaPermissionCheck> m_protector; Odd to have this here.
Eric Carlson
Comment 5 2015-12-09 17:30:17 PST
Comment on attachment 267056 [details] Patch. View in context: https://bugs.webkit.org/attachment.cgi?id=267056&action=review >> Source/WebCore/Modules/mediastream/MediaDevicesRequest.cpp:86 >> + m_hasUserMediaPermission = access; > > Is storing in m_hasUserMediaPermission thread-safe given the callOnMainThread() below? Yes, this is the callback from the permission checker so it is called exactly once. >> Source/WebCore/Modules/mediastream/UserMediaController.h:67 >> +inline void UserMediaController::checkUserMediaPermission(Ref<UserMediaPermissionCheck>&& request) > > I don't really like this model of a "check" function taking ownership of the UserMediaPermissionCheck passed in. The check function doesn't take ownership, it passes it along to the client (the WK1 or WK2 WebUserMediaClient ) which stores it in a map and calls the UI delegate (WK1) or page proxy (WK2). >> Source/WebCore/Modules/mediastream/UserMediaPermissionCheck.cpp:43 >> +RefPtr<UserMediaPermissionCheck> UserMediaPermissionCheck::create(Document& document, UserMediaPermissionCheckClient& client) > > This should return a Ref<> Oops, will fix. >> Source/WebCore/Modules/mediastream/UserMediaPermissionCheck.cpp:81 >> + m_protector = this; > > Weird. Why doesn't someone own this explicitly? Actually, the checker is owned by a MediaDevicesRequest so this isn't necessary. Will remove.
Darin Adler
Comment 6 2015-12-09 19:26:52 PST
Comment on attachment 267056 [details] Patch. View in context: https://bugs.webkit.org/attachment.cgi?id=267056&action=review >>> Source/WebCore/Modules/mediastream/UserMediaController.h:67 >>> +inline void UserMediaController::checkUserMediaPermission(Ref<UserMediaPermissionCheck>&& request) >> >> I don't really like this model of a "check" function taking ownership of the UserMediaPermissionCheck passed in. > > The check function doesn't take ownership, it passes it along to the client (the WK1 or WK2 WebUserMediaClient ) which stores it in a map and calls the UI delegate (WK1) or page proxy (WK2). So the argument type should just be UserMediaPermissionCheck& instead of Ref&&. Same for requestUserMediaAccess.
Eric Carlson
Comment 7 2015-12-10 06:36:54 PST
(In reply to comment #6) > Comment on attachment 267056 [details] > Patch. > > View in context: > https://bugs.webkit.org/attachment.cgi?id=267056&action=review > > >>> Source/WebCore/Modules/mediastream/UserMediaController.h:67 > >>> +inline void UserMediaController::checkUserMediaPermission(Ref<UserMediaPermissionCheck>&& request) > >> > >> I don't really like this model of a "check" function taking ownership of the UserMediaPermissionCheck passed in. > > > > The check function doesn't take ownership, it passes it along to the client (the WK1 or WK2 WebUserMediaClient ) which stores it in a map and calls the UI delegate (WK1) or page proxy (WK2). > > So the argument type should just be UserMediaPermissionCheck& instead of > Ref&&. Same for requestUserMediaAccess. OK, fixed.
Eric Carlson
Comment 8 2015-12-10 06:37:24 PST
Created attachment 267102 [details] Updated patch.
Chris Dumez
Comment 9 2015-12-10 10:19:59 PST
Comment on attachment 267102 [details] Updated patch. View in context: https://bugs.webkit.org/attachment.cgi?id=267102&action=review r=me with comments. > Source/WebCore/Modules/mediastream/MediaDevicesRequest.cpp:84 > +void MediaDevicesRequest::didCompleteCheck(bool access) nit: I think we usually name booleans so that they start with something like is/can/should for clarity. > Source/WebCore/Modules/mediastream/MediaDevicesRequest.cpp:91 > + RefPtr<MediaDevicesRequest> protectedThis(this); Hmm, this looks unsafe. MediaDevicesRequest is not ThreadSafeRefCounted. > Source/WebCore/Modules/mediastream/UserMediaPermissionCheck.cpp:75 > + Document* document = downcast<Document>(scriptExecutionContext()); nit: I would prefer: auto& document = downcast<Document>(*scriptExecutionContext()); > Source/WebCore/Modules/mediastream/UserMediaPermissionCheck.h:50 > +class UserMediaPermissionCheck : public ContextDestructionObserver, public RefCounted<UserMediaPermissionCheck> { Could be final ? > Source/WebKit2/UIProcess/UserMediaPermissionCheckProxy.h:41 > + static PassRefPtr<UserMediaPermissionCheckProxy> create(UserMediaPermissionRequestManagerProxy& manager, uint64_t userMediaID) We don't use PassRefPtr anymore. This should return a Ref<> > Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp:63 > +PassRefPtr<UserMediaPermissionCheckProxy> UserMediaPermissionRequestManagerProxy::createUserMediaPermissionCheck(uint64_t userMediaID) Should return a Ref<>. > Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp:65 > + RefPtr<UserMediaPermissionCheckProxy> request = UserMediaPermissionCheckProxy::create(*this, userMediaID); Ref<> > Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp:66 > + m_pendingDeviceRequests.add(userMediaID, request.get()); request.ptr() > Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.h:40 > + PassRefPtr<UserMediaPermissionCheckProxy> createUserMediaPermissionCheck(uint64_t userMediaID); Ref<> > Source/WebKit2/WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp:90 > +void UserMediaPermissionRequestManager::startUserMediaPermissionCheck(WebCore::UserMediaPermissionCheck& request) You don't need the WebCore:: > Source/WebKit2/WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp:92 > + Document* document = downcast<Document>(request.scriptExecutionContext()); auto* > Source/WebKit/mac/WebCoreSupport/WebUserMediaClient.mm:84 > + DEPRECATED_DEFINE_STATIC_LOCAL(UserMediaCheckMap, requests, ()); static NeverDestroyed<> ? > Source/WebKit/mac/WebCoreSupport/WebUserMediaClient.mm:119 > +void WebUserMediaClient::requestUserMediaAccess(UserMediaRequest& prpRequest) We should get rid of the prp prefix > Source/WebKit/mac/WebCoreSupport/WebUserMediaClient.mm:123 > + UserMediaRequest* request = &prpRequest; We don't really need this local variable anymore I believe. > Source/WebKit/mac/WebCoreSupport/WebUserMediaClient.mm:153 > +void WebUserMediaClient::checkUserMediaPermission(UserMediaPermissionCheck& prpRequest) We should drop the prp prefix > Source/WebKit/mac/WebCoreSupport/WebUserMediaClient.mm:157 > + UserMediaPermissionCheck* request = &prpRequest; Not needed? > Tools/WebKitTestRunner/TestController.h:289 > + typedef Vector<std::pair<WKRetainPtr<WKSecurityOriginRef>, WKRetainPtr<WKUserMediaPermissionRequestRef>>> PermissionRequestMap; Calling this "Map" is a tad confusing. Maybe List or Vector?
Chris Dumez
Comment 10 2015-12-10 10:22:12 PST
Comment on attachment 267102 [details] Updated patch. View in context: https://bugs.webkit.org/attachment.cgi?id=267102&action=review > Source/WebCore/Modules/mediastream/UserMediaPermissionCheck.h:34 > +#include <wtf/PassRefPtr.h> Useless include. > Source/WebKit2/UIProcess/UserMediaPermissionCheckProxy.h:31 > +#include <wtf/PassRefPtr.h> Useless include.
Eric Carlson
Comment 11 2015-12-10 11:51:01 PST
Created attachment 267116 [details] Patch for landing.
WebKit Commit Bot
Comment 12 2015-12-10 11:52:08 PST
Attachment 267116 [details] did not pass style-queue: ERROR: Source/WebCore/ChangeLog:25: Need whitespace between colon and description [changelog/filechangedescriptionwhitespace] [5] Total errors found: 1 in 45 files If any of these errors are false positives, please file a bug against check-webkit-style.
Eric Carlson
Comment 13 2015-12-10 13:02:08 PST
Created attachment 267121 [details] Another updated patch for landing.
Eric Carlson
Comment 14 2015-12-10 20:08:04 PST
Note You need to log in before you can comment on or make changes to this bug.