Enable getUserMedia in mini browser
authoryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Sep 2018 16:08:49 +0000 (16:08 +0000)
committeryouenn@apple.com <youenn@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 27 Sep 2018 16:08:49 +0000 (16:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=190012

Reviewed by Eric Carlson.

Enable MediaDevices and mock capture devices.
Grant mock devices access to any getUserMedia call.
Covered by manual testing.

* MiniBrowser/mac/AppDelegate.m:
(defaultConfiguration):
* MiniBrowser/mac/WK2BrowserWindowController.m:
(-[WK2BrowserWindowController _webView:requestUserMediaAuthorizationForDevices:url:mainFrameURL:decisionHandler:]):
(-[WK2BrowserWindowController _webView:checkUserMediaPermissionForURL:mainFrameURL:frameIdentifier:decisionHandler:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236548 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/MiniBrowser/mac/AppDelegate.m
Tools/MiniBrowser/mac/WK2BrowserWindowController.m

index f385b05..8af4624 100644 (file)
@@ -1,3 +1,20 @@
+2018-09-27  Youenn Fablet  <youenn@apple.com>
+
+        Enable getUserMedia in mini browser
+        https://bugs.webkit.org/show_bug.cgi?id=190012
+
+        Reviewed by Eric Carlson.
+
+        Enable MediaDevices and mock capture devices.
+        Grant mock devices access to any getUserMedia call.
+        Covered by manual testing.
+
+        * MiniBrowser/mac/AppDelegate.m:
+        (defaultConfiguration):
+        * MiniBrowser/mac/WK2BrowserWindowController.m:
+        (-[WK2BrowserWindowController _webView:requestUserMediaAuthorizationForDevices:url:mainFrameURL:decisionHandler:]):
+        (-[WK2BrowserWindowController _webView:checkUserMediaPermissionForURL:mainFrameURL:frameIdentifier:decisionHandler:]):
+
 2018-09-27  Antoine Quint  <graouts@apple.com>
 
         [Web Animations] Turn Web Animations with CSS integration on
index bb8f528..99a500d 100644 (file)
@@ -94,6 +94,8 @@ static WKWebViewConfiguration *defaultConfiguration()
         configuration = [[WKWebViewConfiguration alloc] init];
         configuration.preferences._fullScreenEnabled = YES;
         configuration.preferences._developerExtrasEnabled = YES;
+        configuration.preferences._mediaDevicesEnabled = YES;
+        configuration.preferences._mockCaptureDevicesEnabled = YES;
 
         _WKProcessPoolConfiguration *processConfiguration = [[[_WKProcessPoolConfiguration alloc] init] autorelease];
         processConfiguration.diskCacheSpeculativeValidationEnabled = ![SettingsController shared].networkCacheSpeculativeRevalidationDisabled;
index 8ce8589..03efb4e 100644 (file)
@@ -795,6 +795,16 @@ static NSSet *dataTypes()
 {
 }
 
+- (void)_webView:(WKWebView *)webView requestUserMediaAuthorizationForDevices:(_WKCaptureDevices)devices url:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL decisionHandler:(void (^)(BOOL authorized))decisionHandler
+{
+    decisionHandler(true);
+}
+
+- (void)_webView:(WKWebView *)webView checkUserMediaPermissionForURL:(NSURL *)url mainFrameURL:(NSURL *)mainFrameURL frameIdentifier:(NSUInteger)frameIdentifier decisionHandler:(void (^)(NSString *salt, BOOL authorized))decisionHandler
+{
+    decisionHandler(@"", false);
+}
+
 @end
 
 #endif // WK_API_ENABLED