Patch
authorphiln@webkit.org <philn@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Nov 2014 08:25:05 +0000 (08:25 +0000)
committerphiln@webkit.org <philn@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Nov 2014 08:25:05 +0000 (08:25 +0000)
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176011 268f45cc-cd09-0410-ab3c-d52691b4dbfc

66 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/mediastream/delayed-permission-allowed-expected.txt [new file with mode: 0644]
LayoutTests/fast/mediastream/delayed-permission-allowed.html [new file with mode: 0644]
LayoutTests/fast/mediastream/delayed-permission-denied-expected.txt [new file with mode: 0644]
LayoutTests/fast/mediastream/delayed-permission-denied.html [new file with mode: 0644]
LayoutTests/fast/mediastream/error-expected.txt [new file with mode: 0644]
LayoutTests/fast/mediastream/error.html [new file with mode: 0644]
LayoutTests/fast/mediastream/success-expected.txt [new file with mode: 0644]
LayoutTests/fast/mediastream/success.html [new file with mode: 0644]
LayoutTests/http/tests/media/media-stream/disconnected-frame-already-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/media/media-stream/disconnected-frame-already.html [new file with mode: 0644]
LayoutTests/http/tests/media/media-stream/disconnected-frame-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/media/media-stream/disconnected-frame-permission-denied-expected.txt [new file with mode: 0644]
LayoutTests/http/tests/media/media-stream/disconnected-frame-permission-denied.html [new file with mode: 0644]
LayoutTests/http/tests/media/media-stream/disconnected-frame.html [new file with mode: 0644]
LayoutTests/http/tests/media/media-stream/resources/disconnected-frame-already-inner1.html [new file with mode: 0644]
LayoutTests/http/tests/media/media-stream/resources/disconnected-frame-already-inner2.html [new file with mode: 0644]
LayoutTests/http/tests/media/media-stream/resources/disconnected-frame-inner.html [new file with mode: 0644]
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/mac/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/Modules/mediastream/UserMediaClient.h
Source/WebCore/Modules/mediastream/UserMediaController.h
Source/WebCore/Modules/mediastream/UserMediaRequest.cpp
Source/WebCore/Modules/mediastream/UserMediaRequest.h
Source/WebCore/platform/mock/UserMediaClientMock.h
Source/WebKit2/CMakeLists.txt
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/API/c/WKBase.h
Source/WebKit2/Shared/APIObject.h
Source/WebKit2/UIProcess/API/APIUIClient.h
Source/WebKit2/UIProcess/API/C/WKAPICast.h
Source/WebKit2/UIProcess/API/C/WKPage.cpp
Source/WebKit2/UIProcess/API/C/WKPageUIClient.h
Source/WebKit2/UIProcess/API/C/WKUserMediaPermissionRequest.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/API/C/WKUserMediaPermissionRequest.h [new file with mode: 0644]
Source/WebKit2/UIProcess/API/C/WebKit2_C.h
Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.h [new file with mode: 0644]
Source/WebKit2/UIProcess/UserMediaPermissionRequestProxy.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/UserMediaPermissionRequestProxy.h [new file with mode: 0644]
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/WebPageProxy.messages.in
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/MediaStream/UserMediaPermissionRequestManager.h [new file with mode: 0644]
Source/WebKit2/WebProcess/WebCoreSupport/WebUserMediaClient.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/WebCoreSupport/WebUserMediaClient.h [new file with mode: 0644]
Source/WebKit2/WebProcess/WebPage/WebPage.cpp
Source/WebKit2/WebProcess/WebPage/WebPage.h
Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
Tools/ChangeLog
Tools/TestWebKitAPI/CMakeLists.txt
Tools/TestWebKitAPI/PlatformGTK.cmake
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2/UserMedia.cpp [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2/getUserMedia.html [new file with mode: 0644]
Tools/WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp
Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.h
Tools/WebKitTestRunner/InjectedBundle/TestRunner.cpp
Tools/WebKitTestRunner/InjectedBundle/TestRunner.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/TestController.h
Tools/WebKitTestRunner/TestInvocation.cpp

index 2ed1cfe..6c2c33f 100644 (file)
@@ -1,3 +1,34 @@
+2014-09-01  Philippe Normand  <pnormand@igalia.com>
+
+        [WK2] UserMediaClient support
+        https://bugs.webkit.org/show_bug.cgi?id=123158
+
+        Reviewed by Benjamin Poulain.
+
+        Simple UserMedia permission request tests inspired from the
+        Geolocation test suite.
+
+        * fast/mediastream/error-expected.txt: Added.
+        * fast/mediastream/error.html: Added.
+        * fast/mediastream/script-tests/error.js: Added.
+        * fast/mediastream/script-tests/success.js: Added.
+        * fast/mediastream/success-expected.txt: Added.
+        * fast/mediastream/success.html: Added.
+        * fast/mediastream/delayed-permission-allowed-expected.txt: Added.
+        * fast/mediastream/delayed-permission-allowed.html: Added.
+        * fast/mediastream/delayed-permission-denied-expected.txt: Added.
+        * fast/mediastream/delayed-permission-denied.html: Added.
+        * http/tests/media/media-stream/disconnected-frame-already-expected.txt: Added.
+        * http/tests/media/media-stream/disconnected-frame-already.html: Added.
+        * http/tests/media/media-stream/disconnected-frame-expected.txt: Added.
+        * http/tests/media/media-stream/disconnected-frame-permission-denied-expected.txt: Added.
+        * http/tests/media/media-stream/disconnected-frame-permission-denied.html: Added.
+        * http/tests/media/media-stream/disconnected-frame.html: Added.
+        * http/tests/media/media-stream/resources/disconnected-frame-already-inner1.html: Added.
+        * http/tests/media/media-stream/resources/disconnected-frame-already-inner2.html: Added.
+        * http/tests/media/media-stream/resources/disconnected-frame-inner.html: Added.
+        * platform/gtk/TestExpectations:
+
 2014-11-11  Jinwoo Song  <jinwoo7.song@samsung.com>
 
         [EFL] Unreviewed EFL gardening. Rebaseline after r174535.
diff --git a/LayoutTests/fast/mediastream/delayed-permission-allowed-expected.txt b/LayoutTests/fast/mediastream/delayed-permission-allowed-expected.txt
new file mode 100644 (file)
index 0000000..f3f825c
--- /dev/null
@@ -0,0 +1,10 @@
+Tests that no callbacks are invoked until permission is allowed.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Success callback invoked
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/mediastream/delayed-permission-allowed.html b/LayoutTests/fast/mediastream/delayed-permission-allowed.html
new file mode 100644 (file)
index 0000000..d547c07
--- /dev/null
@@ -0,0 +1,34 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+description("Tests that no callbacks are invoked until permission is allowed.");
+window.jsTestIsAsync = true;
+
+function allowPermission() {
+    permissionSet = true;
+    if (window.testRunner)
+        testRunner.setUserMediaPermission(true);
+}
+
+var options = {audio: true, video: true};
+navigator.webkitGetUserMedia(options, function(stream) {
+   if (permissionSet) {
+        testPassed('Success callback invoked');
+        finishJSTest();
+        return;
+    }
+    testFailed('Success callback invoked unexpectedly');
+}, function(e) {
+    testFailed('Error callback invoked unexpectedly');
+    finishJSTest();
+});
+
+window.setTimeout(allowPermission, 100);
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/mediastream/delayed-permission-denied-expected.txt b/LayoutTests/fast/mediastream/delayed-permission-denied-expected.txt
new file mode 100644 (file)
index 0000000..aff67d0
--- /dev/null
@@ -0,0 +1,10 @@
+Tests that no callbacks are invoked until permission is denied.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS error.code is error.PERMISSION_DENIED
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/mediastream/delayed-permission-denied.html b/LayoutTests/fast/mediastream/delayed-permission-denied.html
new file mode 100644 (file)
index 0000000..66da4aa
--- /dev/null
@@ -0,0 +1,37 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+description("Tests that no callbacks are invoked until permission is denied.");
+window.jsTestIsAsync = true;
+
+function denyPermission() {
+    permissionSet = true;
+    if (window.testRunner)
+        testRunner.setUserMediaPermission(false);
+}
+
+var error;
+var options = {audio: true, video: true};
+navigator.webkitGetUserMedia(options, function(stream) {
+    testFailed('Success callback invoked unexpectedly');
+    finishJSTest();
+}, function(e) {
+    if (permissionSet) {
+        error = e;
+        shouldBe('error.code', 'error.PERMISSION_DENIED');
+        finishJSTest();
+        return;
+    }
+    testFailed('Error callback invoked unexpectedly');
+    finishJSTest();
+});
+
+window.setTimeout(denyPermission, 100);
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/mediastream/error-expected.txt b/LayoutTests/fast/mediastream/error-expected.txt
new file mode 100644 (file)
index 0000000..e629d22
--- /dev/null
@@ -0,0 +1,10 @@
+Tests UserMedia error callback using the mock service.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS error.code is error.PERMISSION_DENIED
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/mediastream/error.html b/LayoutTests/fast/mediastream/error.html
new file mode 100644 (file)
index 0000000..98c5158
--- /dev/null
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+description("Tests UserMedia error callback using the mock service.");
+window.jsTestIsAsync = true;
+
+if (window.testRunner)
+    testRunner.setUserMediaPermission(false);
+else
+    debug('This test can not be run without the testRunner');
+
+var error;
+var options = {audio:false, video:true};
+navigator.webkitGetUserMedia(options, function(stream) {
+    testFailed('Success callback invoked unexpectedly');
+    finishJSTest();
+}, function(e) {
+    error = e;
+    shouldBe('error.code', 'error.PERMISSION_DENIED');
+    finishJSTest();
+});
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/mediastream/success-expected.txt b/LayoutTests/fast/mediastream/success-expected.txt
new file mode 100644 (file)
index 0000000..8223ebb
--- /dev/null
@@ -0,0 +1,9 @@
+Tests UserMedia success callback using the mock service.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/mediastream/success.html b/LayoutTests/fast/mediastream/success.html
new file mode 100644 (file)
index 0000000..bcf1f26
--- /dev/null
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+description("Tests UserMedia success callback using the mock service.");
+window.jsTestIsAsync = true;
+
+if (window.testRunner)
+    testRunner.setUserMediaPermission(true);
+else
+    debug('This test can not be run without the testRunner');
+
+var options = {audio: true, video: true};
+navigator.webkitGetUserMedia(options, function(stream) {
+    finishJSTest();
+}, function(e) {
+    testFailed('Error callback invoked unexpectedly');
+    finishJSTest();
+});
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/media/media-stream/disconnected-frame-already-expected.txt b/LayoutTests/http/tests/media/media-stream/disconnected-frame-already-expected.txt
new file mode 100644 (file)
index 0000000..e505db9
--- /dev/null
@@ -0,0 +1,11 @@
+CONSOLE MESSAGE: line 24: NotSupportedError: DOM Exception 9: The implementation did not support the requested type of object or operation.
+Tests that when a getUserMedia request is made after its frame has been disconnected, no callbacks are made and no crash occurs.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+webkitGetUserMedia called on object with disconnected Frame.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/http/tests/media/media-stream/disconnected-frame-already.html b/LayoutTests/http/tests/media/media-stream/disconnected-frame-already.html
new file mode 100644 (file)
index 0000000..fbed903
--- /dev/null
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+description("Tests that when a getUserMedia request is made after its frame has been disconnected, no callbacks are made and no crash occurs.");
+window.jsTestIsAsync = true;
+
+if (window.testRunner)
+    testRunner.setUserMediaPermission(true);
+
+function onFirstIframeLoaded() {
+    iframeNavigator = iframe.contentWindow.navigator;
+    iframe.src = 'resources/disconnected-frame-already-inner2.html';
+}
+
+var error;
+var options = {audio: true, video: true};
+function onSecondIframeLoaded() {
+    setTimeout(finishTest, 100);
+
+    iframeNavigator.webkitGetUserMedia(options, function(stream) {
+        testFailed('Success callback invoked unexpectedly');
+        finishJSTest();
+    }, function(e) {
+        testFailed('Error callback invoked unexpectedly');
+        finishJSTest();
+    });
+}
+
+function finishTest() {
+    debug('webkitGetUserMedia called on object with disconnected Frame.');
+    finishJSTest();
+}
+
+var iframe = document.createElement('iframe');
+iframe.src = 'resources/disconnected-frame-already-inner1.html';
+document.body.appendChild(iframe);
+</script>
+<script src="../../../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/media/media-stream/disconnected-frame-expected.txt b/LayoutTests/http/tests/media/media-stream/disconnected-frame-expected.txt
new file mode 100644 (file)
index 0000000..efb78c8
--- /dev/null
@@ -0,0 +1,11 @@
+frame "<!--framePath //<!--frame0-->-->" - has 1 onunload handler(s)
+Tests that when a request is made on a UserMedia object and its Frame is disconnected before a callback is made, the error callback is invoked with the correct error message.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS No callbacks invoked
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/http/tests/media/media-stream/disconnected-frame-permission-denied-expected.txt b/LayoutTests/http/tests/media/media-stream/disconnected-frame-permission-denied-expected.txt
new file mode 100644 (file)
index 0000000..a724631
--- /dev/null
@@ -0,0 +1,13 @@
+frame "<!--framePath //<!--frame0-->-->" - has 1 onunload handler(s)
+Tests that when a getUserMedia request is made, permission is denied and its Frame is disconnected before a callback is made, the error callback is invoked with PERMISSION_DENIED.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS error.code is error.PERMISSION_DENIED
+
+PASS No callbacks invoked
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/http/tests/media/media-stream/disconnected-frame-permission-denied.html b/LayoutTests/http/tests/media/media-stream/disconnected-frame-permission-denied.html
new file mode 100644 (file)
index 0000000..7d19790
--- /dev/null
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+description("Tests that when a getUserMedia request is made, permission is denied and its Frame is disconnected before a callback is made, the error callback is invoked with PERMISSION_DENIED.");
+window.jsTestIsAsync = true;
+
+if (window.testRunner)
+    testRunner.setUserMediaPermission(false);
+else
+    debug('This test can not be run without the testRunner');
+
+var error;
+var options = {audio: true, video: true};
+function onIframeLoaded() {
+    iframeNavigator = iframe.contentWindow.navigator;
+    iframeNavigator.webkitGetUserMedia(options, function(stream) {
+        testFailed('Success callback invoked unexpectedly');
+        finishJSTest();
+    }, function(e) {
+        error = e;
+        shouldBe('error.code', 'error.PERMISSION_DENIED');
+        debug('');
+        iframe.src = 'data:text/html,This frame should be visible when the test completes';
+    });
+}
+
+function onIframeUnloaded() {
+    // Make another request, with permission already denied.
+    iframeNavigator.webkitGetUserMedia(options, function(stream) {
+        testFailed('Success callback invoked unexpectedly');
+        finishJSTest();
+    }, function(e) {
+        testFailed('Error callback invoked unexpectedly');
+        finishJSTest();
+    });
+    setTimeout(function() {
+        testPassed('No callbacks invoked');
+        finishJSTest();
+    }, 100);
+}
+
+var iframe = document.createElement('iframe');
+iframe.src = 'resources/disconnected-frame-inner.html';
+document.body.appendChild(iframe);
+
+</script>
+<script src="../../../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/media/media-stream/disconnected-frame.html b/LayoutTests/http/tests/media/media-stream/disconnected-frame.html
new file mode 100644 (file)
index 0000000..aec1c0d
--- /dev/null
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+description("Tests that when a request is made on a UserMedia object and its Frame is disconnected before a callback is made, the error callback is invoked with the correct error message.");
+window.jsTestIsAsync = true;
+
+if (window.testRunner)
+    testRunner.setUserMediaPermission(true);
+
+function onIframeLoaded() {
+    iframeNavigator = iframe.contentWindow.navigator;
+    iframe.src = 'data:text/html,This frame should be visible when the test completes';
+}
+
+function onIframeUnloaded() {
+    var options = {audio: true, video: true};
+    iframeNavigator.webkitGetUserMedia(options, function (stream) {
+        testFailed('Success callback invoked unexpectedly');
+        finishJSTest();
+    }, function(e) {
+        testFailed('Error callback invoked unexpectedly');
+        finishJSTest();
+    });
+
+    setTimeout(function() {
+        testPassed('No callbacks invoked');
+        finishJSTest();
+    }, 100);
+}
+
+var iframe = document.createElement('iframe');
+iframe.src = 'resources/disconnected-frame-inner.html';
+document.body.appendChild(iframe);
+
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/http/tests/media/media-stream/resources/disconnected-frame-already-inner1.html b/LayoutTests/http/tests/media/media-stream/resources/disconnected-frame-already-inner1.html
new file mode 100644 (file)
index 0000000..4dca350
--- /dev/null
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+  <head>
+  </head>
+  <body onload="window.parent.onFirstIframeLoaded()">
+    <p>This frame should be replaced before the test ends</p>
+  </body>
+</html>
diff --git a/LayoutTests/http/tests/media/media-stream/resources/disconnected-frame-already-inner2.html b/LayoutTests/http/tests/media/media-stream/resources/disconnected-frame-already-inner2.html
new file mode 100644 (file)
index 0000000..1e8de97
--- /dev/null
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+  <head>
+  </head>
+  <body onload="window.parent.onSecondIframeLoaded()">
+    <p>This frame should be visible when the test completes</p>
+  </body>
+</html>
diff --git a/LayoutTests/http/tests/media/media-stream/resources/disconnected-frame-inner.html b/LayoutTests/http/tests/media/media-stream/resources/disconnected-frame-inner.html
new file mode 100644 (file)
index 0000000..5086280
--- /dev/null
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+  <head>
+  </head>
+  <body onload="window.parent.onIframeLoaded()" onunload="window.parent.onIframeUnloaded();">
+    <p>This frame should be replaced before the test ends</p>
+  </body>
+</html>
index d10168f..bdfd412 100644 (file)
@@ -291,7 +291,43 @@ webkit.org/b/85211 ietestcenter/css3/flexbox/flexbox-align-stretch-001.htm [ Ima
 webkit.org/b/85212 ietestcenter/css3/flexbox/flexbox-layout-002.htm [ ImageOnlyFailure ]
 
 # Mediastream implementation is not complete yet.
-webkit.org/b/79203 fast/mediastream [ Skip ]
+webkit.org/b/79203 fast/mediastream/argument-types.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/getusermedia.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/MediaStream-add-ended-tracks.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/MediaStream-add-remove-tracks.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/MediaStream-add-tracks-to-inactive-stream.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/MediaStream-clone.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/MediaStreamConstructor.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/MediaStream-construct-with-ended-tracks.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/MediaStream-getTracks.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/MediaStream-MediaElement-srcObject.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/MediaStreamTrackEvent-constructor.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/MediaStreamTrack-getSources.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/MediaStreamTrack.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/MediaStreamTrack-onended.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/no-interface-object.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/RTCIceCandidate.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/RTCPeerConnection-AddRemoveStream.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/RTCPeerConnection-createAnswer.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/RTCPeerConnection-createOffer.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/RTCPeerConnection-datachannel.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/RTCPeerConnection-dtmf.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/RTCPeerConnection-events.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/RTCPeerConnection-getConfiguration.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/RTCPeerConnection-have-local-offer.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/RTCPeerConnection-have-local-pranswer.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/RTCPeerConnection-have-remote-offer.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/RTCPeerConnection-have-remote-pranswer.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/RTCPeerConnection.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/RTCPeerConnection-ice.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/RTCPeerConnection-localDescription.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/RTCPeerConnection-onnegotiationneeded.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/RTCPeerConnection-remoteDescription.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/RTCPeerConnection-stable.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/RTCPeerConnection-state.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/RTCPeerConnection-stats.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/RTCPeerConnection-statsSelector.html [ Skip ]
+webkit.org/b/79203 fast/mediastream/RTCSessionDescription.html [ Skip ]
 webkit.org/b/79203 fast/events/constructors/media-stream-event-constructor.html [ Skip ]
 webkit.org/b/79203 webaudio/mediastreamaudiodestinationnode.html [ Skip ]
 webkit.org/b/79203 webaudio/mediastreamaudiosourcenode.html [ Skip ]
index 2805760..99a1199 100644 (file)
@@ -157,6 +157,7 @@ http/tests/security/contentTypeOptions
 # Media Stream API is not yet enabled.
 fast/mediastream
 fast/events/constructors/media-stream-event-constructor.html
+http/tests/media/media-stream
 
 # Asserts in debug.
 [ Debug ] fast/images/large-size-image-crash.html [ Skip ]
index dc89bf7..74fe010 100644 (file)
@@ -1,3 +1,30 @@
+2014-09-01  Philippe Normand  <pnormand@igalia.com>
+
+        [WK2] UserMediaClient support
+        https://bugs.webkit.org/show_bug.cgi?id=123158
+
+        Reviewed by Benjamin Poulain.
+
+        Added document and frame accessors, needed by the
+        UserMediaRequestManager of the WebProcess. Also added two methods
+        used by the permission request manager to know if access to audio
+        or video devices is requested.
+
+        Tests: fast/mediastream/error.html
+               fast/mediastream/success.html
+               fast/mediastream/delayed-permission-allowed.html
+               fast/mediastream/delayed-permission-denied.html
+               http/tests/media/media-stream/disconnected-frame-already.html
+               http/tests/media/media-stream/disconnected-frame-permission-denied.html
+               http/tests/media/media-stream/disconnected-frame.html
+
+        * Modules/mediastream/UserMediaRequest.cpp:
+        (WebCore::UserMediaRequest::document):
+        (WebCore::UserMediaRequest::frame):
+        * Modules/mediastream/UserMediaRequest.h:
+        (WebCore::UserMediaRequest::requiresAudio):
+        (WebCore::UserMediaRequest::requiresVideo):
+
 2014-11-12  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
 
         [EFL] Clean up OwnPtr in RenderThemeEfl
index c8995b9..51d60ce 100644 (file)
@@ -44,8 +44,8 @@ class UserMediaClient {
 public:
     virtual void pageDestroyed() = 0;
 
-    virtual void requestPermission(PassRefPtr<UserMediaRequest>) = 0;
-    virtual void cancelRequest(UserMediaRequest*) = 0;
+    virtual void requestPermission(PassRef<UserMediaRequest>) = 0;
+    virtual void cancelRequest(UserMediaRequest&) = 0;
 
 protected:
     virtual ~UserMediaClient() { }
index 703ff40..a62ad1f 100644 (file)
@@ -39,8 +39,8 @@ public:
     ~UserMediaController();
 
     UserMediaClient* client() const { return m_client; }
-    void requestPermission(PassRefPtr<UserMediaRequest>);
-    void cancelRequest(UserMediaRequest*);
+    void requestPermission(PassRef<UserMediaRequest>);
+    void cancelRequest(UserMediaRequest&);
 
     static const char* supplementName();
     static UserMediaController* from(Page* page) { return static_cast<UserMediaController*>(Supplement<Page>::from(page, supplementName())); }
@@ -49,12 +49,12 @@ private:
     UserMediaClient* m_client;
 };
 
-inline void UserMediaController::requestPermission(PassRefPtr<UserMediaRequest> request)
+inline void UserMediaController::requestPermission(PassRef<UserMediaRequest> request)
 {
-    m_client->requestPermission(request);
+    m_client->requestPermission(WTF::move(request));
 }
 
-inline void UserMediaController::cancelRequest(UserMediaRequest* request)
+inline void UserMediaController::cancelRequest(UserMediaRequest& request)
 {
     m_client->cancelRequest(request);
 }
index 3d20618..cbd6fba 100644 (file)
@@ -40,6 +40,7 @@
 #include "Dictionary.h"
 #include "Document.h"
 #include "ExceptionCode.h"
+#include "Frame.h"
 #include "MediaConstraintsImpl.h"
 #include "MediaStream.h"
 #include "MediaStreamCenter.h"
@@ -123,7 +124,7 @@ void UserMediaRequest::constraintsValidated()
     callOnMainThread([protectedThis] {
         // 2 - The constraints are valid, ask the user for access to media.
         if (UserMediaController* controller = protectedThis->m_controller)
-            controller->requestPermission(protectedThis.get());
+            controller->requestPermission(*protectedThis.get());
     });
 }
 
@@ -201,7 +202,7 @@ void UserMediaRequest::contextDestroyed()
     Ref<UserMediaRequest> protect(*this);
 
     if (m_controller) {
-        m_controller->cancelRequest(this);
+        m_controller->cancelRequest(*this);
         m_controller = 0;
     }
 
index a04ef06..a6b4c38 100644 (file)
@@ -48,6 +48,7 @@ namespace WebCore {
 
 class Dictionary;
 class Document;
+class Frame;
 class MediaConstraints;
 class MediaStreamPrivate;
 class UserMediaController;
@@ -66,6 +67,9 @@ public:
     WEBCORE_EXPORT void userMediaAccessGranted();
     WEBCORE_EXPORT void userMediaAccessDenied();
 
+    bool requiresAudio() const { return m_audioConstraints; }
+    bool requiresVideo() const { return m_videoConstraints; }
+
 private:
     UserMediaRequest(ScriptExecutionContext*, UserMediaController*, PassRefPtr<MediaConstraints> audioConstraints, PassRefPtr<MediaConstraints> videoConstraints, PassRefPtr<NavigatorUserMediaSuccessCallback>, PassRefPtr<NavigatorUserMediaErrorCallback>);
 
index cfa24ce..927ac77 100644 (file)
@@ -36,8 +36,8 @@ namespace WebCore {
 
 class UserMediaClientRequestNotifier : public MockNotifier {
 public:
-    UserMediaClientRequestNotifier(PassRefPtr<UserMediaRequest> request, bool requestSuccess)
-        : m_request(request)
+    UserMediaClientRequestNotifier(PassRef<UserMediaRequest> request, bool requestSuccess)
+        : m_request(WTF::move(request))
         , m_requestSuccess(requestSuccess)
     {
     }
@@ -51,7 +51,7 @@ public:
     }
 
 private:
-    RefPtr<UserMediaRequest> m_request;
+    Ref<UserMediaRequest> m_request;
     bool m_requestSuccess;
 };
 
@@ -60,13 +60,13 @@ public:
     public:
     virtual void pageDestroyed() override { }
 
-    virtual void requestPermission(PassRefPtr<UserMediaRequest> request) override
+    virtual void requestPermission(PassRef<UserMediaRequest> request) override
     {
-        RefPtr<UserMediaClientRequestNotifier> notifier = adoptRef(new UserMediaClientRequestNotifier(request, true));
+        RefPtr<UserMediaClientRequestNotifier> notifier = adoptRef(new UserMediaClientRequestNotifier(WTF::move(request), true));
         m_timerEvents.append(adoptRef(new TimerEvent(this, notifier)));
     }
 
-    virtual void cancelRequest(UserMediaRequest* request) override
+    virtual void cancelRequest(UserMediaRequest& request) override
     {
         RefPtr<UserMediaClientRequestNotifier> notifier = adoptRef(new UserMediaClientRequestNotifier(request, false));
         m_timerEvents.append(adoptRef(new TimerEvent(this, notifier)));
index 42fe3ff..de0b5ef 100644 (file)
@@ -49,6 +49,7 @@ set(WebKit2_INCLUDE_DIRECTORIES
     "${WEBKIT2_DIR}/WebProcess/InjectedBundle/DOM"
     "${WEBKIT2_DIR}/WebProcess/Launching"
     "${WEBKIT2_DIR}/WebProcess/MediaCache"
+    "${WEBKIT2_DIR}/WebProcess/MediaStream"
     "${WEBKIT2_DIR}/WebProcess/Network"
     "${WEBKIT2_DIR}/WebProcess/Notifications"
     "${WEBKIT2_DIR}/WebProcess/OriginData"
@@ -300,6 +301,8 @@ set(WebKit2_SOURCES
     UIProcess/ResponsivenessTimer.cpp
     UIProcess/StatisticsRequest.cpp
     UIProcess/TextCheckerCompletion.cpp
+    UIProcess/UserMediaPermissionRequestManagerProxy.cpp
+    UIProcess/UserMediaPermissionRequestProxy.cpp
     UIProcess/VisitedLinkProvider.cpp
     UIProcess/WebApplicationCacheManagerProxy.cpp
     UIProcess/WebBackForwardList.cpp
@@ -388,6 +391,7 @@ set(WebKit2_SOURCES
     UIProcess/API/C/WKResourceCacheManager.cpp
     UIProcess/API/C/WKSessionStateRef.cpp
     UIProcess/API/C/WKTextChecker.cpp
+    UIProcess/API/C/WKUserMediaPermissionRequest.cpp
     UIProcess/API/C/WKVibration.cpp
     UIProcess/API/C/WKViewportAttributes.cpp
 
@@ -484,6 +488,8 @@ set(WebKit2_SOURCES
 
     WebProcess/MediaCache/WebMediaCacheManager.cpp
 
+    WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp
+
     WebProcess/Network/NetworkProcessConnection.cpp
     WebProcess/Network/WebResourceLoadScheduler.cpp
     WebProcess/Network/WebResourceLoader.cpp
@@ -535,6 +541,7 @@ set(WebKit2_SOURCES
     WebProcess/WebCoreSupport/WebPopupMenu.cpp
     WebProcess/WebCoreSupport/WebProgressTrackerClient.cpp
     WebProcess/WebCoreSupport/WebSearchPopupMenu.cpp
+    WebProcess/WebCoreSupport/WebUserMediaClient.cpp
     WebProcess/WebCoreSupport/WebVibrationClient.cpp
 
     WebProcess/WebPage/DrawingArea.cpp
index 86c0d4a..9e5d083 100644 (file)
@@ -1,3 +1,77 @@
+2014-09-01  Philippe Normand  <pnormand@igalia.com>
+
+        [WK2] UserMediaClient support
+        https://bugs.webkit.org/show_bug.cgi?id=123158
+
+        Reviewed by Benjamin Poulain.
+
+        Support for UserMediaPermissionRequest in WebKit2. It's
+        implemented similarily to the GeolocationPermissionRequest
+        support. When the WebPage requires this permission it sends a
+        message to the UI process which at some point grants or denies the
+        permission and sends the result back to the WebProcess.
+
+        * CMakeLists.txt: Generic CMake support for new files.
+        * Shared/API/c/WKBase.h: New type for UserMediaPermissionRequest.
+        * Shared/APIObject.h: Ditto.
+        * UIProcess/API/C/WKAPICast.h: PermissionRequest API mapping.
+        * UIProcess/API/APIUIClient.h: New decidePolicy handler for UserMediaPermissionRequest.
+        (API::UIClient::decidePolicyForUserMediaPermissionRequest):
+        * UIProcess/API/C/WKPage.cpp: Ditto.
+        (WKPageSetPageUIClient):
+        * UIProcess/API/C/WKPageUIClient.h: WKPageUIClient version bump to
+        5, including the new decidePolicyForUserMediaPermissionRequest member.
+        * UIProcess/API/C/WKUserMediaPermissionRequest.cpp: Added, C API
+        implementation of the UserMediaPermissionRequest.
+        (WKUserMediaPermissionRequestGetTypeID):
+        (WKUserMediaPermissionRequestAllow):
+        (WKUserMediaPermissionRequestDeny):
+        * UIProcess/API/C/WKUserMediaPermissionRequest.h: Added.
+        * UIProcess/API/C/WebKit2_C.h:
+        * UIProcess/UserMediaPermissionRequestManagerProxy.h: Added.
+        * UIProcess/UserMediaPermissionRequestProxy.cpp: Added, proxy
+        object for the UserMediaPermissionRequestType.
+        (WebKit::UserMediaPermissionRequestProxy::UserMediaPermissionRequestProxy):
+        (WebKit::UserMediaPermissionRequestProxy::allow):
+        (WebKit::UserMediaPermissionRequestProxy::deny):
+        (WebKit::UserMediaPermissionRequestProxy::invalidate):
+        * UIProcess/UserMediaPermissionRequestProxy.h: Added.
+        (WebKit::UserMediaPermissionRequestProxy::create):
+        (WebKit::UserMediaPermissionRequestProxy::mediaParameters):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::WebPageProxy):
+        (WebKit::WebPageProxy::requestUserMediaPermissionForFrame): Defer
+        UserPermissionRequest to the UIClient.
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in: New message to handle UserMediaPermissionRequests.
+        * WebKit2.xcodeproj/project.pbxproj:
+        * WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp: Added,
+        WebProcess side of the UserRequestManager, keeping track of each
+        permission request.
+        (WebKit::generateRequestID):
+        (WebKit::UserMediaPermissionRequestManager::UserMediaPermissionRequestManager):
+        (WebKit::UserMediaPermissionRequestManager::startRequest):
+        (WebKit::UserMediaPermissionRequestManager::cancelRequest):
+        (WebKit::UserMediaPermissionRequestManager::didReceiveUserMediaPermissionDecision):
+        * WebProcess/MediaStream/UserMediaPermissionRequestManager.h: Added.
+        * WebProcess/WebCoreSupport/WebUserMediaClient.cpp: Added,
+        WebProcess implementation of the WebCore::UserMediaClient.
+        (WebKit::WebUserMediaClient::WebUserMediaClient):
+        (WebKit::WebUserMediaClient::pageDestroyed):
+        (WebKit::WebUserMediaClient::requestPermission):
+        (WebKit::WebUserMediaClient::cancelRequest):
+        * WebProcess/WebCoreSupport/WebUserMediaClient.h: Added.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::WebPage): Create the
+        UserMediaPermissionRequestManager and register the UserMediaClient
+        to the page.
+        (WebKit::WebPage::didReceiveUserMediaPermissionDecision): Dispatch
+        decision to manager.
+        * WebProcess/WebPage/WebPage.h:
+        (WebKit::WebPage::userMediaPermissionRequestManager):
+        * WebProcess/WebPage/WebPage.messages.in: New Message to handle
+        permission decision result from the UI process.
+
 2014-11-11  Tim Horton  <timothy_horton@apple.com>
 
         Add support for mailto: link action menus
index 8d1e965..11ec548 100644 (file)
@@ -127,6 +127,7 @@ typedef const struct OpaqueWKProtectionSpace* WKProtectionSpaceRef;
 typedef const struct OpaqueWKTextChecker* WKTextCheckerRef;
 typedef const struct OpaqueWKSession* WKSessionRef;
 typedef const struct OpaqueWKSessionState* WKSessionStateRef;
+typedef const struct OpaqueWKUserMediaPermissionRequest* WKUserMediaPermissionRequestRef;
 typedef const struct OpaqueWKVibration* WKVibrationRef;
 typedef const struct OpaqueWKViewportAttributes* WKViewportAttributesRef;
 
index 922e6da..d4966ac 100644 (file)
@@ -132,6 +132,7 @@ public:
         Preferences,
         Session,
         TextChecker,
+        UserMediaPermissionRequest,
         Vibration,
         ViewportAttributes,
 
index b788d92..6aadb6a 100644 (file)
@@ -50,6 +50,7 @@ class ImmutableDictionary;
 class NativeWebKeyboardEvent;
 class NativeWebWheelEvent;
 class NotificationPermissionRequest;
+class UserMediaPermissionRequestProxy;
 class WebColorPickerResultListenerProxy;
 class WebFrameProxy;
 class WebOpenPanelParameters;
@@ -122,6 +123,7 @@ public:
 
     virtual bool runOpenPanel(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, WebKit::WebOpenPanelParameters*, WebKit::WebOpenPanelResultListenerProxy*) { return false; }
     virtual bool decidePolicyForGeolocationPermissionRequest(WebKit::WebPageProxy*, WebKit::WebFrameProxy*, WebKit::WebSecurityOrigin*, WebKit::GeolocationPermissionRequestProxy*) { return false; }
+    virtual bool decidePolicyForUserMediaPermissionRequest(WebKit::WebPageProxy&, WebKit::WebFrameProxy&, WebKit::WebSecurityOrigin&, WebKit::UserMediaPermissionRequestProxy&) { return false; }
     virtual bool decidePolicyForNotificationPermissionRequest(WebKit::WebPageProxy*, WebKit::WebSecurityOrigin*, WebKit::NotificationPermissionRequest*) { return false; }
 
     // Printing.
index 80221a9..5f44a69 100644 (file)
@@ -63,6 +63,7 @@ class AuthenticationDecisionListener;
 class DownloadProxy;
 class GeolocationPermissionRequestProxy;
 class NotificationPermissionRequest;
+class UserMediaPermissionRequestProxy;
 class WebApplicationCacheManagerProxy;
 class WebBackForwardList;
 class WebBackForwardListItem;
@@ -146,6 +147,7 @@ WK_ADD_API_MAPPING(WKRenderLayerRef, WebRenderLayer)
 WK_ADD_API_MAPPING(WKRenderObjectRef, WebRenderObject)
 WK_ADD_API_MAPPING(WKSessionStateRef, API::SessionState)
 WK_ADD_API_MAPPING(WKTextCheckerRef, WebTextChecker)
+WK_ADD_API_MAPPING(WKUserMediaPermissionRequestRef, UserMediaPermissionRequestProxy)
 WK_ADD_API_MAPPING(WKVibrationRef, WebVibrationProxy)
 WK_ADD_API_MAPPING(WKViewportAttributesRef, WebViewportAttributes)
 WK_ADD_API_MAPPING(WKInspectorRef, WebInspectorProxy)
index 35217e8..d739408 100644 (file)
@@ -74,7 +74,7 @@ template<> struct ClientTraits<WKPagePolicyClientBase> {
 };
 
 template<> struct ClientTraits<WKPageUIClientBase> {
-    typedef std::tuple<WKPageUIClientV0, WKPageUIClientV1, WKPageUIClientV2, WKPageUIClientV3, WKPageUIClientV4> Versions;
+    typedef std::tuple<WKPageUIClientV0, WKPageUIClientV1, WKPageUIClientV2, WKPageUIClientV3, WKPageUIClientV4, WKPageUIClientV5> Versions;
 };
 
 }
@@ -1499,6 +1499,15 @@ void WKPageSetPageUIClient(WKPageRef pageRef, const WKPageUIClientBase* wkClient
             return true;
         }
 
+        virtual bool decidePolicyForUserMediaPermissionRequest(WebPageProxy& page, WebFrameProxy& frame, WebSecurityOrigin& origin, UserMediaPermissionRequestProxy& permissionRequest) override
+        {
+            if (!m_client.decidePolicyForUserMediaPermissionRequest)
+                return false;
+
+            m_client.decidePolicyForUserMediaPermissionRequest(toAPI(&page), toAPI(&frame), toAPI(&origin), toAPI(&permissionRequest), m_client.base.clientInfo);
+            return true;
+        }
+
         virtual bool decidePolicyForNotificationPermissionRequest(WebPageProxy* page, WebSecurityOrigin* origin, NotificationPermissionRequest* permissionRequest) override
         {
             if (!m_client.decidePolicyForNotificationPermissionRequest)
index bc9eec7..72c159f 100644 (file)
@@ -90,6 +90,7 @@ typedef void (*WKPageDidBeginTrackingPotentialLongMousePressCallback)(WKPageRef
 typedef void (*WKPageDidRecognizeLongMousePressCallback)(WKPageRef page, WKTypeRef userData, const void *clientInfo);
 typedef void (*WKPageDidCancelTrackingPotentialLongMousePressCallback)(WKPageRef page, WKTypeRef userData, const void *clientInfo);
 typedef void (*WKPageIsPlayingAudioDidChangeCallback)(WKPageRef page, const void* clientInfo);
+typedef void (*WKPageDecidePolicyForUserMediaPermissionRequestCallback)(WKPageRef page, WKFrameRef frame, WKSecurityOriginRef origin, WKUserMediaPermissionRequestRef permissionRequest, const void* clientInfo);
 
 // Deprecated    
 typedef WKPageRef (*WKPageCreateNewPageCallback_deprecatedForUseWithV0)(WKPageRef page, WKDictionaryRef features, WKEventModifiers modifiers, WKEventMouseButton mouseButton, const void *clientInfo);
@@ -378,6 +379,74 @@ typedef struct WKPageUIClientV4 {
     WKPageIsPlayingAudioDidChangeCallback                               isPlayingAudioDidChange;
 } WKPageUIClientV4;
 
+typedef struct WKPageUIClientV5 {
+    WKPageUIClientBase                                                  base;
+
+    // Version 0.
+    WKPageCreateNewPageCallback_deprecatedForUseWithV0                  createNewPage_deprecatedForUseWithV0;
+    WKPageUIClientCallback                                              showPage;
+    WKPageUIClientCallback                                              close;
+    WKPageTakeFocusCallback                                             takeFocus;
+    WKPageFocusCallback                                                 focus;
+    WKPageUnfocusCallback                                               unfocus;
+    WKPageRunJavaScriptAlertCallback                                    runJavaScriptAlert;
+    WKPageRunJavaScriptConfirmCallback                                  runJavaScriptConfirm;
+    WKPageRunJavaScriptPromptCallback                                   runJavaScriptPrompt;
+    WKPageSetStatusTextCallback                                         setStatusText;
+    WKPageMouseDidMoveOverElementCallback_deprecatedForUseWithV0        mouseDidMoveOverElement_deprecatedForUseWithV0;
+    WKPageMissingPluginButtonClickedCallback_deprecatedForUseWithV0     missingPluginButtonClicked_deprecatedForUseWithV0;
+    WKPageDidNotHandleKeyEventCallback                                  didNotHandleKeyEvent;
+    WKPageDidNotHandleWheelEventCallback                                didNotHandleWheelEvent;
+    WKPageGetToolbarsAreVisibleCallback                                 toolbarsAreVisible;
+    WKPageSetToolbarsAreVisibleCallback                                 setToolbarsAreVisible;
+    WKPageGetMenuBarIsVisibleCallback                                   menuBarIsVisible;
+    WKPageSetMenuBarIsVisibleCallback                                   setMenuBarIsVisible;
+    WKPageGetStatusBarIsVisibleCallback                                 statusBarIsVisible;
+    WKPageSetStatusBarIsVisibleCallback                                 setStatusBarIsVisible;
+    WKPageGetIsResizableCallback                                        isResizable;
+    WKPageSetIsResizableCallback                                        setIsResizable;
+    WKPageGetWindowFrameCallback                                        getWindowFrame;
+    WKPageSetWindowFrameCallback                                        setWindowFrame;
+    WKPageRunBeforeUnloadConfirmPanelCallback                           runBeforeUnloadConfirmPanel;
+    WKPageUIClientCallback                                              didDraw;
+    WKPageUIClientCallback                                              pageDidScroll;
+    WKPageExceededDatabaseQuotaCallback                                 exceededDatabaseQuota;
+    WKPageRunOpenPanelCallback                                          runOpenPanel;
+    WKPageDecidePolicyForGeolocationPermissionRequestCallback           decidePolicyForGeolocationPermissionRequest;
+    WKPageHeaderHeightCallback                                          headerHeight;
+    WKPageFooterHeightCallback                                          footerHeight;
+    WKPageDrawHeaderCallback                                            drawHeader;
+    WKPageDrawFooterCallback                                            drawFooter;
+    WKPagePrintFrameCallback                                            printFrame;
+    WKPageUIClientCallback                                              runModal;
+    void*                                                               unused1; // Used to be didCompleteRubberBandForMainFrame
+    WKPageSaveDataToFileInDownloadsFolderCallback                       saveDataToFileInDownloadsFolder;
+    WKPageShouldInterruptJavaScriptCallback                             shouldInterruptJavaScript;
+
+    // Version 1.
+    WKPageCreateNewPageCallback                                         createNewPage;
+    WKPageMouseDidMoveOverElementCallback                               mouseDidMoveOverElement;
+    WKPageDecidePolicyForNotificationPermissionRequestCallback          decidePolicyForNotificationPermissionRequest;
+    WKPageUnavailablePluginButtonClickedCallback_deprecatedForUseWithV1 unavailablePluginButtonClicked_deprecatedForUseWithV1;
+
+    // Version 2.
+    WKPageShowColorPickerCallback                                       showColorPicker;
+    WKPageHideColorPickerCallback                                       hideColorPicker;
+    WKPageUnavailablePluginButtonClickedCallback                        unavailablePluginButtonClicked;
+    
+    // Version 3.
+    WKPagePinnedStateDidChangeCallback                                  pinnedStateDidChange;
+
+    // Version 4.
+    WKPageDidBeginTrackingPotentialLongMousePressCallback               didBeginTrackingPotentialLongMousePress;
+    WKPageDidRecognizeLongMousePressCallback                            didRecognizeLongMousePress;
+    WKPageDidCancelTrackingPotentialLongMousePressCallback              didCancelTrackingPotentialLongMousePress;
+    WKPageIsPlayingAudioDidChangeCallback                               isPlayingAudioDidChange;
+
+    // Version 5.
+    WKPageDecidePolicyForUserMediaPermissionRequestCallback             decidePolicyForUserMediaPermissionRequest;
+} WKPageUIClientV5;
+
 enum { kWKPageUIClientCurrentVersion WK_ENUM_DEPRECATED("Use an explicit version number instead") = 2 };
 typedef struct WKPageUIClient {
     int                                                                 version;
diff --git a/Source/WebKit2/UIProcess/API/C/WKUserMediaPermissionRequest.cpp b/Source/WebKit2/UIProcess/API/C/WKUserMediaPermissionRequest.cpp
new file mode 100644 (file)
index 0000000..05fd3e6
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2014 Igalia S.L
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "WKUserMediaPermissionRequest.h"
+
+#include "UserMediaPermissionRequestProxy.h"
+#include "WKAPICast.h"
+
+using namespace WebKit;
+
+WKTypeID WKUserMediaPermissionRequestGetTypeID()
+{
+    return toAPI(UserMediaPermissionRequestProxy::APIType);
+}
+
+void WKUserMediaPermissionRequestAllow(WKUserMediaPermissionRequestRef userMediaPermissionRequestRef)
+{
+    toImpl(userMediaPermissionRequestRef)->allow();
+}
+
+void WKUserMediaPermissionRequestDeny(WKUserMediaPermissionRequestRef userMediaPermissionRequestRef)
+{
+    toImpl(userMediaPermissionRequestRef)->deny();
+}
diff --git a/Source/WebKit2/UIProcess/API/C/WKUserMediaPermissionRequest.h b/Source/WebKit2/UIProcess/API/C/WKUserMediaPermissionRequest.h
new file mode 100644 (file)
index 0000000..545d318
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2014 Igalia S.L
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef WKUserMediaPermissionRequest_h
+#define WKUserMediaPermissionRequest_h
+
+#include <WebKit/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKUserMediaPermissionRequestGetTypeID();
+
+WK_EXPORT void WKUserMediaPermissionRequestAllow(WKUserMediaPermissionRequestRef);
+WK_EXPORT void WKUserMediaPermissionRequestDeny(WKUserMediaPermissionRequestRef);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKUserMediaPermissionRequest_h */
index 5a712cd..e32bacf 100644 (file)
@@ -57,6 +57,7 @@
 #include <WebKit/WKURL.h>
 #include <WebKit/WKURLRequest.h>
 #include <WebKit/WKURLResponse.h>
+#include <WebKit/WKUserMediaPermissionRequest.h>
 
 #if defined(__OBJC__) && __OBJC__
 #import <WebKit/WKView.h>
diff --git a/Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp b/Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.cpp
new file mode 100644 (file)
index 0000000..397e595
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "UserMediaPermissionRequestManagerProxy.h"
+
+#include "WebPageMessages.h"
+#include "WebPageProxy.h"
+#include "WebProcessProxy.h"
+
+namespace WebKit {
+
+UserMediaPermissionRequestManagerProxy::UserMediaPermissionRequestManagerProxy(WebPageProxy& page)
+    : m_page(page)
+{
+}
+
+void UserMediaPermissionRequestManagerProxy::invalidateRequests()
+{
+    for (auto& request : m_pendingRequests.values())
+        request->invalidate();
+
+    m_pendingRequests.clear();
+}
+
+PassRefPtr<UserMediaPermissionRequestProxy> UserMediaPermissionRequestManagerProxy::createRequest(uint64_t userMediaID, bool audio, bool video)
+{
+    RefPtr<UserMediaPermissionRequestProxy> request = UserMediaPermissionRequestProxy::create(*this, userMediaID, audio, video);
+    m_pendingRequests.add(userMediaID, request.get());
+    return request.release();
+}
+
+void UserMediaPermissionRequestManagerProxy::didReceiveUserMediaPermissionDecision(uint64_t userMediaID, bool allowed)
+{
+    if (!m_page.isValid())
+        return;
+
+    if (!m_pendingRequests.take(userMediaID))
+        return;
+
+#if ENABLE(MEDIA_STREAM)
+    m_page.process().send(Messages::WebPage::DidReceiveUserMediaPermissionDecision(userMediaID, allowed), m_page.pageID());
+#else
+    UNUSED_PARAM(allowed);
+#endif
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.h b/Source/WebKit2/UIProcess/UserMediaPermissionRequestManagerProxy.h
new file mode 100644 (file)
index 0000000..aa1713b
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef UserMediaPermissionRequestManagerProxy_h
+#define UserMediaPermissionRequestManagerProxy_h
+
+#include "UserMediaPermissionRequestProxy.h"
+#include <wtf/HashMap.h>
+
+namespace WebKit {
+
+class WebPageProxy;
+
+class UserMediaPermissionRequestManagerProxy {
+public:
+    explicit UserMediaPermissionRequestManagerProxy(WebPageProxy&);
+
+    void invalidateRequests();
+
+    // Create a request to be presented to the user.
+    PassRefPtr<UserMediaPermissionRequestProxy> createRequest(uint64_t userMediaID, bool audio, bool video);
+
+    // Called by UserMediaPermissionRequestProxy when a decision is made by the user.
+    void didReceiveUserMediaPermissionDecision(uint64_t, bool allow);
+
+private:
+    HashMap<uint64_t, RefPtr<UserMediaPermissionRequestProxy>> m_pendingRequests;
+    WebPageProxy& m_page;
+};
+
+} // namespace WebKit
+
+#endif // UserMediaPermissionRequestManagerProxy_h
diff --git a/Source/WebKit2/UIProcess/UserMediaPermissionRequestProxy.cpp b/Source/WebKit2/UIProcess/UserMediaPermissionRequestProxy.cpp
new file mode 100644 (file)
index 0000000..9508592
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "UserMediaPermissionRequestProxy.h"
+
+#include "APINumber.h"
+#include "UserMediaPermissionRequestManagerProxy.h"
+#include <wtf/text/StringHash.h>
+
+namespace WebKit {
+
+UserMediaPermissionRequestProxy::UserMediaPermissionRequestProxy(UserMediaPermissionRequestManagerProxy& manager, uint64_t userMediaID, bool audio, bool video)
+    : m_manager(manager)
+    , m_userMediaID(userMediaID)
+{
+    HashMap<String, RefPtr<API::Object>> parametersMap;
+    parametersMap.add(ASCIILiteral("audio"), API::Boolean::create(audio));
+    parametersMap.add(ASCIILiteral("video"), API::Boolean::create(video));
+    m_mediaParameters = ImmutableDictionary::create(WTF::move(parametersMap));
+}
+
+void UserMediaPermissionRequestProxy::allow()
+{
+    m_manager.didReceiveUserMediaPermissionDecision(m_userMediaID, true);
+}
+
+void UserMediaPermissionRequestProxy::deny()
+{
+    m_manager.didReceiveUserMediaPermissionDecision(m_userMediaID, false);
+}
+
+void UserMediaPermissionRequestProxy::invalidate()
+{
+    m_manager.invalidateRequests();
+}
+
+} // namespace WebKit
+
diff --git a/Source/WebKit2/UIProcess/UserMediaPermissionRequestProxy.h b/Source/WebKit2/UIProcess/UserMediaPermissionRequestProxy.h
new file mode 100644 (file)
index 0000000..f047272
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef UserMediaPermissionRequestProxy_h
+#define UserMediaPermissionRequestProxy_h
+
+#include "APIObject.h"
+#include "ImmutableDictionary.h"
+#include <wtf/PassRefPtr.h>
+
+namespace WebKit {
+
+class UserMediaPermissionRequestManagerProxy;
+
+class UserMediaPermissionRequestProxy : public API::ObjectImpl<API::Object::Type::UserMediaPermissionRequest> {
+public:
+    static PassRefPtr<UserMediaPermissionRequestProxy> create(UserMediaPermissionRequestManagerProxy& manager, uint64_t userMediaID, bool audio, bool video)
+    {
+        return adoptRef(new UserMediaPermissionRequestProxy(manager, userMediaID, audio, video));
+    }
+
+    void allow();
+    void deny();
+
+    void invalidate();
+
+    PassRefPtr<ImmutableDictionary> mediaParameters() const { return m_mediaParameters; }
+
+private:
+    UserMediaPermissionRequestProxy(UserMediaPermissionRequestManagerProxy&, uint64_t userMediaID, bool audio, bool video);
+
+    UserMediaPermissionRequestManagerProxy& m_manager;
+    uint64_t m_userMediaID;
+    RefPtr<ImmutableDictionary> m_mediaParameters;
+};
+
+} // namespace WebKit
+
+#endif // UserMediaPermissionRequestProxy_h
index 23f3bc4..43f0d6c 100644 (file)
@@ -55,6 +55,7 @@
 #include "TextChecker.h"
 #include "TextCheckerState.h"
 #include "TextIndicator.h"
+#include "UserMediaPermissionRequestProxy.h"
 #include "WKContextPrivate.h"
 #include "WebBackForwardList.h"
 #include "WebBackForwardListItem.h"
@@ -279,6 +280,7 @@ WebPageProxy::WebPageProxy(PageClient& pageClient, WebProcessProxy& process, uin
 #endif
     , m_geolocationPermissionRequestManager(*this)
     , m_notificationPermissionRequestManager(*this)
+    , m_userMediaPermissionRequestManager(*this)
     , m_viewState(ViewState::NoFlags)
     , m_viewWasEverInWindow(false)
     , m_backForwardList(WebBackForwardList::create(*this))
@@ -4716,6 +4718,18 @@ void WebPageProxy::requestGeolocationPermissionForFrame(uint64_t geolocationID,
     request->deny();
 }
 
+void WebPageProxy::requestUserMediaPermissionForFrame(uint64_t userMediaID, uint64_t frameID, String originIdentifier, bool audio, bool video)
+{
+    WebFrameProxy* frame = m_process->webFrame(frameID);
+    MESSAGE_CHECK(frame);
+
+    RefPtr<WebSecurityOrigin> origin = WebSecurityOrigin::create(SecurityOrigin::createFromDatabaseIdentifier(originIdentifier));
+    RefPtr<UserMediaPermissionRequestProxy> request = m_userMediaPermissionRequestManager.createRequest(userMediaID, audio, video);
+
+    if (!m_uiClient->decidePolicyForUserMediaPermissionRequest(*this, *frame, *origin.get(), *request.get()))
+        request->deny();
+}
+
 void WebPageProxy::requestNotificationPermission(uint64_t requestID, const String& originString)
 {
     if (!isRequestIDValid(requestID))
index cb24d78..307d8cb 100644 (file)
@@ -45,6 +45,7 @@
 #include "PlatformProcessIdentifier.h"
 #include "SandboxExtension.h"
 #include "ShareableBitmap.h"
+#include "UserMediaPermissionRequestManagerProxy.h"
 #include "VisibleContentRectUpdateInfo.h"
 #include "WKBase.h"
 #include "WKPagePrivate.h"
@@ -124,6 +125,7 @@ class DragData;
 class FloatRect;
 class GraphicsLayer;
 class IntSize;
+class MediaConstraintsImpl;
 class ProtectionSpace;
 class RunLoopObserver;
 class SharedBuffer;
@@ -1060,6 +1062,9 @@ private:
     void exceededDatabaseQuota(uint64_t frameID, const String& originIdentifier, const String& databaseName, const String& displayName, uint64_t currentQuota, uint64_t currentOriginUsage, uint64_t currentDatabaseUsage, uint64_t expectedUsage, PassRefPtr<Messages::WebPageProxy::ExceededDatabaseQuota::DelayedReply>);
     void reachedApplicationCacheOriginQuota(const String& originIdentifier, uint64_t currentQuota, uint64_t totalBytesNeeded, PassRefPtr<Messages::WebPageProxy::ReachedApplicationCacheOriginQuota::DelayedReply>);
     void requestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, String originIdentifier);
+
+    void requestUserMediaPermissionForFrame(uint64_t userMediaID, uint64_t frameID, String originIdentifier, bool audio, bool video);
+
     void runModal();
     void notifyScrollerThumbIsVisibleInRect(const WebCore::IntRect&);
     void recommendedScrollbarStyleDidChange(int32_t newStyle);
@@ -1396,6 +1401,8 @@ private:
     GeolocationPermissionRequestManagerProxy m_geolocationPermissionRequestManager;
     NotificationPermissionRequestManagerProxy m_notificationPermissionRequestManager;
 
+    UserMediaPermissionRequestManagerProxy m_userMediaPermissionRequestManager;
+
     WebCore::ViewState::Flags m_viewState;
     bool m_viewWasEverInWindow;
 
index f7f160b..7371609 100644 (file)
@@ -257,6 +257,11 @@ messages -> WebPageProxy {
     # Geolocation messages
     RequestGeolocationPermissionForFrame(uint64_t geolocationID, uint64_t frameID, String originIdentifier)
     
+#if ENABLE(MEDIA_STREAM)
+    # MediaSteam messages
+    RequestUserMediaPermissionForFrame(uint64_t userMediaID, uint64_t frameID, String originIdentifier, bool audio, bool video)
+#endif
+
     # Notification messages
     RequestNotificationPermission(uint64_t requestID, String originIdentifier)
     ShowNotification(String title, String body, String iconURL, String tag, String lang, String dir, String originIdentifier, uint64_t notificationID)
index 916139c..78a61de 100644 (file)
                3F889D14188778C900FEADAF /* WebVideoFullscreenManagerProxy.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3F889D12188778C900FEADAF /* WebVideoFullscreenManagerProxy.mm */; };
                3F889D15188778C900FEADAF /* WebVideoFullscreenManagerProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 3F889D13188778C900FEADAF /* WebVideoFullscreenManagerProxy.h */; };
                3F889D171887859300FEADAF /* WebVideoFullscreenManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3F889D0D1887699C00FEADAF /* WebVideoFullscreenManager.mm */; };
+               4A3CC18A19B063E700D14AEF /* UserMediaPermissionRequestManagerProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A410F3919AF7B04002EBAB5 /* UserMediaPermissionRequestManagerProxy.cpp */; };
+               4A3CC18B19B0640F00D14AEF /* UserMediaPermissionRequestManagerProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A410F3A19AF7B04002EBAB5 /* UserMediaPermissionRequestManagerProxy.h */; };
+               4A3CC18C19B0641500D14AEF /* UserMediaPermissionRequestProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A410F3B19AF7B04002EBAB5 /* UserMediaPermissionRequestProxy.cpp */; };
+               4A3CC18D19B0641900D14AEF /* UserMediaPermissionRequestProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A410F3C19AF7B04002EBAB5 /* UserMediaPermissionRequestProxy.h */; };
+               4A3CC18E19B07B8500D14AEF /* WKUserMediaPermissionRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A410F3519AF7AC3002EBAB5 /* WKUserMediaPermissionRequest.cpp */; };
+               4A3CC18F19B07B8A00D14AEF /* WKUserMediaPermissionRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A410F3619AF7AC3002EBAB5 /* WKUserMediaPermissionRequest.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               4A410F4419AF7B27002EBAB5 /* UserMediaPermissionRequestManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A410F4219AF7B27002EBAB5 /* UserMediaPermissionRequestManager.cpp */; };
+               4A410F4A19AF7B80002EBAB5 /* WebUserMediaClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A410F4819AF7B80002EBAB5 /* WebUserMediaClient.cpp */; };
                4F601432155C5AA2001FBDE0 /* BlockingResponseMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F601430155C5A32001FBDE0 /* BlockingResponseMap.h */; };
                51021E9C12B16788005C033C /* WebContextMenuClientMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51021E9B12B16788005C033C /* WebContextMenuClientMac.mm */; };
                510274321981AF8E008165ED /* WKOriginDataManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 755422BA18062B9C0046F6A8 /* WKOriginDataManager.h */; settings = {ATTRIBUTES = (Private, ); }; };
                3F889D12188778C900FEADAF /* WebVideoFullscreenManagerProxy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebVideoFullscreenManagerProxy.mm; path = ios/WebVideoFullscreenManagerProxy.mm; sourceTree = "<group>"; };
                3F889D13188778C900FEADAF /* WebVideoFullscreenManagerProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebVideoFullscreenManagerProxy.h; path = ios/WebVideoFullscreenManagerProxy.h; sourceTree = "<group>"; };
                3F889D1618877A2400FEADAF /* WebVideoFullscreenManagerProxy.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; name = WebVideoFullscreenManagerProxy.messages.in; path = ios/WebVideoFullscreenManagerProxy.messages.in; sourceTree = "<group>"; };
+               4A410F3519AF7AC3002EBAB5 /* WKUserMediaPermissionRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKUserMediaPermissionRequest.cpp; sourceTree = "<group>"; };
+               4A410F3619AF7AC3002EBAB5 /* WKUserMediaPermissionRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKUserMediaPermissionRequest.h; sourceTree = "<group>"; };
+               4A410F3919AF7B04002EBAB5 /* UserMediaPermissionRequestManagerProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMediaPermissionRequestManagerProxy.cpp; sourceTree = "<group>"; };
+               4A410F3A19AF7B04002EBAB5 /* UserMediaPermissionRequestManagerProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserMediaPermissionRequestManagerProxy.h; sourceTree = "<group>"; };
+               4A410F3B19AF7B04002EBAB5 /* UserMediaPermissionRequestProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMediaPermissionRequestProxy.cpp; sourceTree = "<group>"; };
+               4A410F3C19AF7B04002EBAB5 /* UserMediaPermissionRequestProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserMediaPermissionRequestProxy.h; sourceTree = "<group>"; };
+               4A410F4219AF7B27002EBAB5 /* UserMediaPermissionRequestManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMediaPermissionRequestManager.cpp; sourceTree = "<group>"; };
+               4A410F4319AF7B27002EBAB5 /* UserMediaPermissionRequestManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserMediaPermissionRequestManager.h; sourceTree = "<group>"; };
+               4A410F4819AF7B80002EBAB5 /* WebUserMediaClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebUserMediaClient.cpp; sourceTree = "<group>"; };
+               4A410F4919AF7B80002EBAB5 /* WebUserMediaClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebUserMediaClient.h; sourceTree = "<group>"; };
                4F601430155C5A32001FBDE0 /* BlockingResponseMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BlockingResponseMap.h; sourceTree = "<group>"; };
                510031F61379CACB00C8DFE4 /* SecItemShim.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = SecItemShim.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
                51021E9B12B16788005C033C /* WebContextMenuClientMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebContextMenuClientMac.mm; sourceTree = "<group>"; };
                        path = Cocoa;
                        sourceTree = "<group>";
                };
+               4A410F4119AF7B27002EBAB5 /* MediaStream */ = {
+                       isa = PBXGroup;
+                       children = (
+                               4A410F4219AF7B27002EBAB5 /* UserMediaPermissionRequestManager.cpp */,
+                               4A410F4319AF7B27002EBAB5 /* UserMediaPermissionRequestManager.h */,
+                       );
+                       path = MediaStream;
+                       sourceTree = "<group>";
+               };
                5105B0D2162F7A5E00E27709 /* Network */ = {
                        isa = PBXGroup;
                        children = (
                BC032D5C10F436D50058C15A /* WebProcess */ = {
                        isa = PBXGroup;
                        children = (
+                               4A410F4119AF7B27002EBAB5 /* MediaStream */,
                                512E352A130B559900ABD19A /* ApplicationCache */,
                                7C6E70F818B2D47E00F24E2E /* cocoa */,
                                3309344B1315B93A0097A7BC /* Cookies */,
                BC032D5D10F437220058C15A /* WebCoreSupport */ = {
                        isa = PBXGroup;
                        children = (
+                               4A410F4819AF7B80002EBAB5 /* WebUserMediaClient.cpp */,
+                               4A410F4919AF7B80002EBAB5 /* WebUserMediaClient.h */,
                                2D28F3DF1885CCB4004B9EAE /* ios */,
                                BC111ADE112F5B9A00337BAB /* mac */,
                                1A7284441959ED100007BCE5 /* SessionStateConversion.cpp */,
                BC032DC310F438260058C15A /* UIProcess */ = {
                        isa = PBXGroup;
                        children = (
+                               4A410F3919AF7B04002EBAB5 /* UserMediaPermissionRequestManagerProxy.cpp */,
+                               4A410F3A19AF7B04002EBAB5 /* UserMediaPermissionRequestManagerProxy.h */,
+                               4A410F3B19AF7B04002EBAB5 /* UserMediaPermissionRequestProxy.cpp */,
+                               4A410F3C19AF7B04002EBAB5 /* UserMediaPermissionRequestProxy.h */,
                                2DA944A81884E9AB00ED86DB /* ios */,
                                BC032DC410F4387C0058C15A /* API */,
                                512F588D12A8836F00629530 /* Authentication */,
                BC0C376610F807660076D7CB /* C */ = {
                        isa = PBXGroup;
                        children = (
+                               4A410F3519AF7AC3002EBAB5 /* WKUserMediaPermissionRequest.cpp */,
+                               4A410F3619AF7AC3002EBAB5 /* WKUserMediaPermissionRequest.h */,
                                5123CF18133D25E60056F800 /* cg */,
                                6EE849C41368D9040038D481 /* mac */,
                                BCB63477116BF10600603215 /* WebKit2_C.h */,
                                1AA41AB512C02EC4002BE67B /* EditorState.h in Headers */,
                                51B15A8513843A3900321AD8 /* EnvironmentUtilities.h in Headers */,
                                1A7C6CDB1378950800B9C04D /* EnvironmentVariables.h in Headers */,
+                               4A3CC18F19B07B8A00D14AEF /* WKUserMediaPermissionRequest.h in Headers */,
                                1AA575FB1496B52600A4EE06 /* EventDispatcher.h in Headers */,
                                1A90C1F41264FD71003E44D4 /* FindController.h in Headers */,
                                1A910071126675C4001842F5 /* TextIndicator.h in Headers */,
                                518353DB1885BF8C00D9FE44 /* IDBSerialization.h in Headers */,
                                1ADF591B1890528E0043C145 /* WKWebViewConfiguration.h in Headers */,
                                BC5744F012638FB3006F0F12 /* WebPopupItem.h in Headers */,
+                               4A3CC18D19B0641900D14AEF /* UserMediaPermissionRequestProxy.h in Headers */,
                                D3B9484711FF4B6500032B39 /* WebPopupMenu.h in Headers */,
                                BC574E631267D080006F0F12 /* WebPopupMenuProxy.h in Headers */,
                                7C8EB11718DB6A19007917C2 /* WKPreferencesPrivate.h in Headers */,
                                2D29ECD0192F2C2E00984B78 /* RemoteLayerTreeDisplayRefreshMonitor.h in Headers */,
                                3760881F150413E900FC82C7 /* WebRenderObject.h in Headers */,
                                33367630130C9998006C9DE2 /* WebResourceCacheManager.h in Headers */,
+                               4A3CC18B19B0640F00D14AEF /* UserMediaPermissionRequestManagerProxy.h in Headers */,
                                1AAF089B19267EE500B6390C /* WKUserScript.h in Headers */,
                                33367656130C9ECA006C9DE2 /* WebResourceCacheManagerMessages.h in Headers */,
                                2DA944A41884E4F000ED86DB /* GestureTypes.h in Headers */,
                        isa = PBXSourcesBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
+                               4A410F4419AF7B27002EBAB5 /* UserMediaPermissionRequestManager.cpp in Sources */,
                                BC5D24A116CC3B9E007D5461 /* ChildProcessMain.mm in Sources */,
+                               4A410F4A19AF7B80002EBAB5 /* WebUserMediaClient.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                1A0F29E3120B44420053D1B9 /* VisitedLinkProvider.cpp in Sources */,
                                A1DF631218E0B7C8003A3E2A /* DownloadClient.mm in Sources */,
                                1A0F29CB120B37160053D1B9 /* VisitedLinkTable.cpp in Sources */,
+                               4A3CC18A19B063E700D14AEF /* UserMediaPermissionRequestManagerProxy.cpp in Sources */,
                                1AC1337F18590AE400F3EC05 /* RemoteObjectRegistry.mm in Sources */,
                                CEDA12E2152CD1AE00D9E08D /* WebAlternativeTextClient.cpp in Sources */,
                                512E352E130B55AF00ABD19A /* WebApplicationCacheManager.cpp in Sources */,
                                51834592134532E90092B696 /* WebIconDatabaseClient.cpp in Sources */,
                                51D02F64132EC5B900BEAA96 /* WebIconDatabaseMessageReceiver.cpp in Sources */,
                                C57193BE18C14A44002D0F12 /* WKFormSelectControl.mm in Sources */,
+                               4A3CC18E19B07B8500D14AEF /* WKUserMediaPermissionRequest.cpp in Sources */,
                                2DDF731618E95060004F5A66 /* RemoteLayerBackingStoreCollection.mm in Sources */,
                                511B24A6132E095700065A0C /* WebIconDatabaseProxy.cpp in Sources */,
                                51D02F6B132EC73700BEAA96 /* WebIconDatabaseProxyMessageReceiver.cpp in Sources */,
                                BC407628124FF0400068F20A /* WKCertificateInfoMac.mm in Sources */,
                                515E7727183DD6F60007203F /* AsyncRequest.cpp in Sources */,
                                BCA284D61492F2C7001F9042 /* WKConnection.mm in Sources */,
+                               4A3CC18C19B0641500D14AEF /* UserMediaPermissionRequestProxy.cpp in Sources */,
                                0F0C365818C051BA00F607D7 /* RemoteLayerTreeHostIOS.mm in Sources */,
                                0F0C365C18C05CA100F607D7 /* RemoteScrollingCoordinatorProxyIOS.mm in Sources */,
                                BC4A6296147313A0006C681A /* WKConnectionRef.cpp in Sources */,
diff --git a/Source/WebKit2/WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp b/Source/WebKit2/WebProcess/MediaStream/UserMediaPermissionRequestManager.cpp
new file mode 100644 (file)
index 0000000..10f3f99
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "UserMediaPermissionRequestManager.h"
+
+#if ENABLE(MEDIA_STREAM)
+
+#include "WebCoreArgumentCoders.h"
+#include "WebFrame.h"
+#include "WebPage.h"
+#include "WebPageProxyMessages.h"
+#include <WebCore/Document.h>
+#include <WebCore/Frame.h>
+#include <WebCore/FrameLoader.h>
+#include <WebCore/SecurityOrigin.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+static uint64_t generateRequestID()
+{
+    static uint64_t uniqueRequestID = 1;
+    return uniqueRequestID++;
+}
+
+UserMediaPermissionRequestManager::UserMediaPermissionRequestManager(WebPage& page)
+    : m_page(page)
+{
+}
+
+void UserMediaPermissionRequestManager::startRequest(UserMediaRequest& request)
+{
+    Document* document = downcast<Document>(request.scriptExecutionContext());
+    Frame* frame = document ? document->frame() : nullptr;
+
+    if (!frame) {
+        request.userMediaAccessDenied();
+        return;
+    }
+
+    uint64_t requestID = generateRequestID();
+    m_idToRequestMap.add(requestID, &request);
+    m_requestToIDMap.add(&request, requestID);
+
+    WebFrame* webFrame = WebFrame::fromCoreFrame(*frame);
+    ASSERT(webFrame);
+
+    SecurityOrigin* origin = request.securityOrigin();
+    m_page.send(Messages::WebPageProxy::RequestUserMediaPermissionForFrame(requestID, webFrame->frameID(), origin->databaseIdentifier(), request.requiresAudio(), request.requiresVideo()));
+}
+
+void UserMediaPermissionRequestManager::cancelRequest(UserMediaRequest& request)
+{
+    uint64_t requestID = m_requestToIDMap.take(&request);
+    if (!requestID)
+        return;
+    m_idToRequestMap.remove(requestID);
+}
+
+void UserMediaPermissionRequestManager::didReceiveUserMediaPermissionDecision(uint64_t requestID, bool allowed)
+{
+    RefPtr<UserMediaRequest> request = m_idToRequestMap.take(requestID);
+    if (!request)
+        return;
+    m_requestToIDMap.remove(request);
+
+    if (allowed)
+        request->userMediaAccessGranted();
+    else
+        request->userMediaAccessDenied();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(MEDIA_STREAM)
diff --git a/Source/WebKit2/WebProcess/MediaStream/UserMediaPermissionRequestManager.h b/Source/WebKit2/WebProcess/MediaStream/UserMediaPermissionRequestManager.h
new file mode 100644 (file)
index 0000000..e88420a
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef UserMediaPermissionRequestManager_h
+#define UserMediaPermissionRequestManager_h
+
+#if ENABLE(MEDIA_STREAM)
+
+#include <WebCore/UserMediaRequest.h>
+#include <wtf/HashMap.h>
+#include <wtf/PassRef.h>
+#include <wtf/RefPtr.h>
+
+namespace WebKit {
+
+class WebPage;
+
+class UserMediaPermissionRequestManager {
+public:
+    explicit UserMediaPermissionRequestManager(WebPage&);
+
+    void startRequest(WebCore::UserMediaRequest&);
+    void cancelRequest(WebCore::UserMediaRequest&);
+
+    void didReceiveUserMediaPermissionDecision(uint64_t userMediaID, bool allowed);
+
+private:
+    WebPage& m_page;
+
+    HashMap<uint64_t, RefPtr<WebCore::UserMediaRequest>> m_idToRequestMap;
+    HashMap<RefPtr<WebCore::UserMediaRequest>, uint64_t> m_requestToIDMap;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(MEDIA_STREAM)
+
+#endif // UserMediaPermissionRequestManager_h
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebUserMediaClient.cpp b/Source/WebKit2/WebProcess/WebCoreSupport/WebUserMediaClient.cpp
new file mode 100644 (file)
index 0000000..80dd263
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+#include "WebUserMediaClient.h"
+
+#if ENABLE(MEDIA_STREAM)
+
+#include "UserMediaController.h"
+#include "UserMediaRequest.h"
+#include "WebPage.h"
+#include <WebCore/UserMediaRequest.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebUserMediaClient::WebUserMediaClient(WebPage& page)
+    : m_page(page)
+{
+}
+
+void WebUserMediaClient::pageDestroyed()
+{
+    delete this;
+}
+
+void WebUserMediaClient::requestPermission(PassRef<UserMediaRequest> prRequest)
+{
+    UserMediaRequest& request = prRequest.leakRef();
+    m_page.userMediaPermissionRequestManager().startRequest(request);
+}
+
+void WebUserMediaClient::cancelRequest(UserMediaRequest& request)
+{
+    m_page.userMediaPermissionRequestManager().cancelRequest(request);
+}
+
+} // namespace WebKit;
+
+#endif // MEDIA_STREAM
diff --git a/Source/WebKit2/WebProcess/WebCoreSupport/WebUserMediaClient.h b/Source/WebKit2/WebProcess/WebCoreSupport/WebUserMediaClient.h
new file mode 100644 (file)
index 0000000..f571664
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2014 Igalia S.L.
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef WebUserMediaClient_h
+#define WebUserMediaClient_h
+
+#if ENABLE(MEDIA_STREAM)
+
+#include <WebCore/UserMediaClient.h>
+#include <wtf/PassRefPtr.h>
+
+namespace WebKit {
+
+class WebPage;
+
+class WebUserMediaClient : public WebCore::UserMediaClient {
+public:
+    WebUserMediaClient(WebPage&);
+
+private:
+    virtual void pageDestroyed();
+    virtual void requestPermission(PassRef<WebCore::UserMediaRequest>) override;
+    virtual void cancelRequest(WebCore::UserMediaRequest&) override;
+
+    WebPage& m_page;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(MEDIA_STREAM)
+
+#endif // WebUserMediaClient_h
index fc956ed..7e80550 100644 (file)
@@ -98,6 +98,7 @@
 #include "WebProgressTrackerClient.h"
 #include "WebUndoStep.h"
 #include "WebUserContentController.h"
+#include "WebUserMediaClient.h"
 #include <JavaScriptCore/APICast.h>
 #include <WebCore/ArchiveResource.h>
 #include <WebCore/Chrome.h>
@@ -281,6 +282,9 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
 #if ENABLE(GEOLOCATION)
     , m_geolocationPermissionRequestManager(this)
 #endif
+#if ENABLE(MEDIA_STREAM)
+    , m_userMediaPermissionRequestManager(*this)
+#endif
     , m_canRunBeforeUnloadConfirmPanel(parameters.canRunBeforeUnloadConfirmPanel)
     , m_canRunModal(parameters.canRunModal)
     , m_isRunningModal(false)
@@ -386,6 +390,9 @@ WebPage::WebPage(uint64_t pageID, const WebPageCreationParameters& parameters)
 #if ENABLE(PROXIMITY_EVENTS)
     WebCore::provideDeviceProximityTo(m_page.get(), new WebDeviceProximityClient(this));
 #endif
+#if ENABLE(MEDIA_STREAM)
+    WebCore::provideUserMediaTo(m_page.get(), new WebUserMediaClient(*this));
+#endif
 
 #if ENABLE(REMOTE_INSPECTOR)
     m_page->setRemoteInspectionAllowed(true);
@@ -3252,6 +3259,13 @@ void WebPage::didReceiveNotificationPermissionDecision(uint64_t notificationID,
     notificationPermissionRequestManager()->didReceiveNotificationPermissionDecision(notificationID, allowed);
 }
 
+#if ENABLE(MEDIA_STREAM)
+void WebPage::didReceiveUserMediaPermissionDecision(uint64_t userMediaID, bool allowed)
+{
+    m_userMediaPermissionRequestManager.didReceiveUserMediaPermissionDecision(userMediaID, allowed);
+}
+#endif
+
 #if !PLATFORM(IOS)
 void WebPage::advanceToNextMisspelling(bool startBeforeSelection)
 {
index 44f6acb..1b72718 100644 (file)
@@ -44,6 +44,7 @@
 #include "Plugin.h"
 #include "SandboxExtension.h"
 #include "ShareableBitmap.h"
+#include "UserMediaPermissionRequestManager.h"
 #include <WebCore/DictationAlternative.h>
 #include <WebCore/DragData.h>
 #include <WebCore/Editor.h>
@@ -449,6 +450,10 @@ public:
     void restorePageState(const WebCore::HistoryItem&);
 #endif
 
+#if ENABLE(MEDIA_STREAM)
+    UserMediaPermissionRequestManager& userMediaPermissionRequestManager() { return m_userMediaPermissionRequestManager; }
+#endif
+
 #if PLATFORM(IOS)
     WebCore::FloatSize screenSize() const;
     WebCore::FloatSize availableScreenSize() const;
@@ -1019,6 +1024,10 @@ private:
 
     void didReceiveNotificationPermissionDecision(uint64_t notificationID, bool allowed);
 
+#if ENABLE(MEDIA_STREAM)
+    void didReceiveUserMediaPermissionDecision(uint64_t userMediaID, bool allowed);
+#endif
+
     void advanceToNextMisspelling(bool startBeforeSelection);
     void changeSpellingToWord(const String& word);
 #if USE(APPKIT)
@@ -1186,6 +1195,10 @@ private:
     GeolocationPermissionRequestManager m_geolocationPermissionRequestManager;
 #endif
 
+#if ENABLE(MEDIA_STREAM)
+    UserMediaPermissionRequestManager m_userMediaPermissionRequestManager;
+#endif
+
     std::unique_ptr<WebCore::PrintContext> m_printContext;
 #if PLATFORM(GTK)
     RefPtr<WebPrintOperationGtk> m_printOperation;
index 2e66d21..508c4de 100644 (file)
@@ -269,6 +269,11 @@ messages -> WebPage LegacyReceiver {
     DidReceiveGeolocationPermissionDecision(uint64_t geolocationID, bool allowed)
 #endif
 
+#if ENABLE(MEDIA_STREAM)
+    # MediaSteam
+    DidReceiveUserMediaPermissionDecision(uint64_t userMediaID, bool allowed)
+#endif
+
     # Notification
     DidReceiveNotificationPermissionDecision(uint64_t notificationID, bool allowed)
 
index cd21a73..2edca13 100644 (file)
@@ -1,3 +1,48 @@
+2014-09-01  Philippe Normand  <pnormand@igalia.com>
+
+        [WK2] UserMediaClient support
+        https://bugs.webkit.org/show_bug.cgi?id=123158
+
+        Reviewed by Benjamin Poulain.
+
+        Simple API test for the UserMedia permission request API. The
+        required test infrastructure is also added, inspired by the
+        Geolocation infrastructure.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: New API test for UserMedia
+        Permission request.
+        * TestWebKitAPI/Tests/WebKit2/UserMedia.cpp: Added.
+        (TestWebKitAPI::decidePolicyForUserMediaPermissionRequestCallBack):
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/WebKit2/getUserMedia.html: Added.
+        * WebKitTestRunner/InjectedBundle/Bindings/TestRunner.idl: new
+        helper method to set the permission request result without user interaction.
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp: Ditto.
+        (WTR::InjectedBundle::setUserMediaPermission):
+        * WebKitTestRunner/InjectedBundle/InjectedBundle.h: Ditto.
+        * WebKitTestRunner/InjectedBundle/TestRunner.cpp: Ditto.
+        (WTR::TestRunner::setUserMediaPermission):
+        * WebKitTestRunner/InjectedBundle/TestRunner.h: Ditto.
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::decidePolicyForUserMediaPermissionRequest): Permission
+        request handler.
+        (WTR::TestController::createOtherPage): Enable the new UserMedia
+        permission request handler.
+        (WTR::TestController::createWebViewWithOptions): Ditto.
+        (WTR::TestController::resetPreferencesToConsistentValues): Enable
+        MediaStream support, this is needed for getUserMedia.
+        (WTR::TestController::resetStateToConsistentValues): clear
+        UserMedia permissions list and flags.
+        (WTR::TestController::setUserMediaPermission): Set permission
+        request result and distpatch it.
+        (WTR::TestController::handleUserMediaPermissionRequest): Save
+        request and dispatch it.
+        (WTR::TestController::decidePolicyForUserMediaPermissionRequestIfPossible):
+        Dispatch cached permission requests.
+        * WebKitTestRunner/TestController.h:
+        * WebKitTestRunner/TestInvocation.cpp:
+        (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
+
 2014-11-11  David Kilzer  <ddkilzer@apple.com>
 
         webkit-patch --suggest-reviewers is broken with newer versions of git
index a30f7f4..50f40bc 100644 (file)
@@ -168,6 +168,8 @@ add_executable(TestJavaScriptCore
 )
 
 target_link_libraries(TestJavaScriptCore ${TestJavaScriptCore_LIBRARIES})
+add_dependencies(TestJavaScriptCore ${ForwardingHeadersForTestWebKitAPI_NAME})
+
 add_test(TestJavaScriptCore ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY}/JavaScriptCore/TestJavaScriptCore)
 set_tests_properties(TestJavaScriptCore PROPERTIES TIMEOUT 60)
 set_target_properties(TestJavaScriptCore PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${TESTWEBKITAPI_RUNTIME_OUTPUT_DIRECTORY}/JavaScriptCore)
index bd3ad6b..0b75479 100644 (file)
@@ -91,6 +91,7 @@ add_executable(TestWebKit2
     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ResizeWindowAfterCrash.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/RestoreSessionStateContainingFormData.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/ShouldGoToBackForwardListItem.cpp
+    ${TESTWEBKITAPI_DIR}/Tests/WebKit2/UserMedia.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/UserMessage.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WillSendSubmitEvent.cpp
     ${TESTWEBKITAPI_DIR}/Tests/WebKit2/WKPageGetScaleFactorNotZero.cpp
index 65b74ec..71faf41 100644 (file)
@@ -88,6 +88,7 @@
                37E1064D16976C8500B78BD0 /* DOMHTMLTableCellCellAbove.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37E1064A1697676400B78BD0 /* DOMHTMLTableCellCellAbove.mm */; };
                37E38C34169B7D010084C28C /* WebViewDidRemoveFrameFromHierarchy.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37E38C33169B7D010084C28C /* WebViewDidRemoveFrameFromHierarchy.mm */; };
                440A1D3914A0103A008A66F2 /* URL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 440A1D3814A0103A008A66F2 /* URL.cpp */; };
+               4A410F4C19AF7BD6002EBAB5 /* UserMedia.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A410F4B19AF7BD6002EBAB5 /* UserMedia.cpp */; };
                4BB4160216815B2600824238 /* JSWrapperForNodeInWebFrame.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BB4160116815B2600824238 /* JSWrapperForNodeInWebFrame.mm */; };
                4BB4160416815F9100824238 /* ElementAtPointInWebFrame.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BB4160316815F9100824238 /* ElementAtPointInWebFrame.mm */; };
                4BFDFFA71314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BFDFFA61314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp */; };
                37E38C33169B7D010084C28C /* WebViewDidRemoveFrameFromHierarchy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebViewDidRemoveFrameFromHierarchy.mm; sourceTree = "<group>"; };
                440A1D3814A0103A008A66F2 /* URL.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = URL.cpp; sourceTree = "<group>"; };
                44A622C114A0E2B60048515B /* WTFStringUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WTFStringUtilities.h; sourceTree = "<group>"; };
+               4A410F4B19AF7BD6002EBAB5 /* UserMedia.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMedia.cpp; sourceTree = "<group>"; };
+               4A410F4D19AF7BEF002EBAB5 /* getUserMedia.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = getUserMedia.html; sourceTree = "<group>"; };
                4BB4160116815B2600824238 /* JSWrapperForNodeInWebFrame.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = JSWrapperForNodeInWebFrame.mm; sourceTree = "<group>"; };
                4BB4160316815F9100824238 /* ElementAtPointInWebFrame.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ElementAtPointInWebFrame.mm; sourceTree = "<group>"; };
                4BFDFFA61314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HitTestResultNodeHandle_Bundle.cpp; sourceTree = "<group>"; };
                BC9096411255616000083756 /* WebKit2 */ = {
                        isa = PBXGroup;
                        children = (
+                               4A410F4B19AF7BD6002EBAB5 /* UserMedia.cpp */,
                                C0C5D3BB14598B6F00A802A6 /* mac */,
                                BC90977B125571AE00083756 /* Resources */,
                                BC246D8C132F115A00B56D7C /* AboutBlankLoad.cpp */,
                BC90977B125571AE00083756 /* Resources */ = {
                        isa = PBXGroup;
                        children = (
+                               4A410F4D19AF7BEF002EBAB5 /* getUserMedia.html */,
                                C045F9461385C2F800C0F3CD /* 18-characters.html */,
                                F6B7BE9617469B7E008A3445 /* associate-form-controls.html */,
                                76E182DE15475A8300F1FADD /* auto-submitting-form.html */,
                                51FCF79A1534AC6D00104491 /* ShouldGoToBackForwardListItem.cpp in Sources */,
                                1AFDE6561953B2C000C48FFA /* Optional.cpp in Sources */,
                                C540F776152E4DA000A40C8C /* SimplifyMarkup.mm in Sources */,
+                               4A410F4C19AF7BD6002EBAB5 /* UserMedia.cpp in Sources */,
                                C02B77F2126612140026BF0F /* SpacebarScrolling.cpp in Sources */,
                                93D3D19E17B1A84200C7C415 /* LayoutMilestonesWithAllContentInFrame.cpp in Sources */,
                                E194E1BB177E5145009C4D4E /* StopLoadingFromDidReceiveResponse.mm in Sources */,
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/UserMedia.cpp b/Tools/TestWebKitAPI/Tests/WebKit2/UserMedia.cpp
new file mode 100644 (file)
index 0000000..26f6cf6
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2014 Igalia S.L
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include "config.h"
+
+#if ENABLE(MEDIA_STREAM)
+#include "PlatformUtilities.h"
+#include "PlatformWebView.h"
+#include "Test.h"
+#include <WebKit/WKRetainPtr.h>
+#include <string.h>
+#include <vector>
+
+namespace TestWebKitAPI {
+
+static bool done;
+
+void decidePolicyForUserMediaPermissionRequestCallBack(WKPageRef, WKFrameRef, WKSecurityOriginRef, WKUserMediaPermissionRequestRef permissionRequest, const void* /* clientInfo */)
+{
+    WKUserMediaPermissionRequestAllow(permissionRequest);
+    done = true;
+}
+
+TEST(WebKit2, UserMediaBasic)
+{
+    auto context = adoptWK(WKContextCreate());
+    PlatformWebView webView(context.get());
+    WKPageUIClientV5 uiClient;
+    memset(&uiClient, 0, sizeof(uiClient));
+
+
+    uiClient.base.version = 5;
+    uiClient.decidePolicyForUserMediaPermissionRequest = decidePolicyForUserMediaPermissionRequestCallBack;
+
+    WKPageSetPageUIClient(webView.page(), &uiClient.base);
+
+    done = false;
+    auto url = adoptWK(Util::createURLForResource("getUserMedia", "html"));
+    WKPageLoadURL(webView.page(), url.get());
+
+    Util::run(&done);
+}
+
+} // namespace TestWebKitAPI
+
+#endif // ENABLE(MEDIA_STREAM)
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2/getUserMedia.html b/Tools/TestWebKitAPI/Tests/WebKit2/getUserMedia.html
new file mode 100644 (file)
index 0000000..e54f853
--- /dev/null
@@ -0,0 +1,14 @@
+<script>
+function gotUserMedia(mediaStream)
+{
+    console.log("Got user media");
+}
+
+function userMediaError(error)
+{
+    console.log(error);
+}
+
+var options = { audio: false, video: true};
+navigator.webkitGetUserMedia(options, gotUserMedia, userMediaError);
+</script>
index bb9a7a0..08a1898 100644 (file)
@@ -169,6 +169,9 @@ interface TestRunner {
     void setMockGeolocationPosition(double latitude, double longitude, double accuracy, [Default=Undefined] optional object altitude, optional object altitudeAccuracy, optional object heading, optional object speed);
     void setMockGeolocationPositionUnavailableError(DOMString errorMessage);
 
+    // MediaStream
+    void setUserMediaPermission(boolean value);
+
     // Audio testing.
     [PassContext] void setAudioResult(object data);
 
index ae6daca..279f97a 100644 (file)
@@ -458,6 +458,13 @@ void InjectedBundle::setMockGeolocationPositionUnavailableError(WKStringRef erro
     WKBundlePostMessage(m_bundle, messageName.get(), errorMessage);
 }
 
+void InjectedBundle::setUserMediaPermission(bool enabled)
+{
+    auto messageName = adoptWK(WKStringCreateWithUTF8CString("SetUserMediaPermission"));
+    auto messageBody = adoptWK(WKBooleanCreate(enabled));
+    WKBundlePostMessage(m_bundle, messageName.get(), messageBody.get());
+}
+
 void InjectedBundle::setCustomPolicyDelegate(bool enabled, bool permissive)
 {
     WKRetainPtr<WKStringRef> messageName(AdoptWK, WKStringCreateWithUTF8CString("SetCustomPolicyDelegate"));
index 9f76a9d..8f0a840 100644 (file)
@@ -92,6 +92,9 @@ public:
     void setMockGeolocationPosition(double latitude, double longitude, double accuracy, bool providesAltitude, double altitude, bool providesAltitudeAccuracy, double altitudeAccuracy, bool providesHeading, double heading, bool providesSpeed, double speed);
     void setMockGeolocationPositionUnavailableError(WKStringRef errorMessage);
 
+    // MediaStream.
+    void setUserMediaPermission(bool);
+
     // Policy delegate.
     void setCustomPolicyDelegate(bool enabled, bool permissive);
 
index d085f1a..d751b95 100644 (file)
@@ -720,6 +720,12 @@ void TestRunner::setMockGeolocationPositionUnavailableError(JSStringRef message)
     InjectedBundle::shared().setMockGeolocationPositionUnavailableError(messageWK.get());
 }
 
+void TestRunner::setUserMediaPermission(bool enabled)
+{
+    // FIXME: this should be done by frame.
+    InjectedBundle::shared().setUserMediaPermission(enabled);
+}
+
 bool TestRunner::callShouldCloseOnWebView()
 {
     WKBundleFrameRef mainFrame = WKBundlePageGetMainFrame(InjectedBundle::shared().page()->page());
index e21fff3..394e908 100644 (file)
@@ -252,6 +252,9 @@ public:
     void setMockGeolocationPosition(double latitude, double longitude, double accuracy, JSValueRef altitude, JSValueRef altitudeAccuracy, JSValueRef heading, JSValueRef speed);
     void setMockGeolocationPositionUnavailableError(JSStringRef message);
 
+    // MediaStream
+    void setUserMediaPermission(bool);
+
     void setPageVisibility(JSStringRef state);
     void resetPageVisibility();
 
index e34093d..3b89eb0 100644 (file)
@@ -189,6 +189,11 @@ static void decidePolicyForGeolocationPermissionRequest(WKPageRef, WKFrameRef, W
     TestController::shared().handleGeolocationPermissionRequest(permissionRequest);
 }
 
+static void decidePolicyForUserMediaPermissionRequest(WKPageRef, WKFrameRef, WKSecurityOriginRef, WKUserMediaPermissionRequestRef permissionRequest, const void* clientInfo)
+{
+    TestController::shared().handleUserMediaPermissionRequest(permissionRequest);
+}
+
 int TestController::getCustomTimeout()
 {
     return m_timeout;
@@ -203,8 +208,8 @@ WKPageRef TestController::createOtherPage(WKPageRef oldPage, WKURLRequestRef, WK
 
     view->resizeTo(800, 600);
 
-    WKPageUIClientV2 otherPageUIClient = {
-        { 2, view },
+    WKPageUIClientV5 otherPageUIClient = {
+        { 5, view },
         0, // createNewPage_deprecatedForUseWithV0
         0, // showPage
         closeOtherPage,
@@ -251,6 +256,12 @@ WKPageRef TestController::createOtherPage(WKPageRef oldPage, WKURLRequestRef, WK
         0, // showColorPicker
         0, // hideColorPicker
         0, // unavailablePluginButtonClicked
+        0, // pinnedStateDidChange
+        0, // didBeginTrackingPotentialLongMousePress
+        0, // didRecognizeLongMousePress
+        0, // didCancelTrackingPotentialLongMousePress
+        0, // isPlayingAudioDidChange
+        decidePolicyForUserMediaPermissionRequest,
     };
     WKPageSetPageUIClient(newPage, &otherPageUIClient.base);
 
@@ -409,8 +420,8 @@ void TestController::initialize(int argc, const char* argv[])
 void TestController::createWebViewWithOptions(WKDictionaryRef options)
 {
     m_mainWebView = std::make_unique<PlatformWebView>(m_context.get(), m_pageGroup.get(), nullptr, options);
-    WKPageUIClientV2 pageUIClient = {
-        { 2, m_mainWebView.get() },
+    WKPageUIClientV5 pageUIClient = {
+        { 5, m_mainWebView.get() },
         0, // createNewPage_deprecatedForUseWithV0
         0, // showPage
         0, // close
@@ -457,6 +468,12 @@ void TestController::createWebViewWithOptions(WKDictionaryRef options)
         0, // showColorPicker
         0, // hideColorPicker
         unavailablePluginButtonClicked,
+        0, // pinnedStateDidChange
+        0, // didBeginTrackingPotentialLongMousePress
+        0, // didRecognizeLongMousePress
+        0, // didCancelTrackingPotentialLongMousePress
+        0, // isPlayingAudioDidChange
+        decidePolicyForUserMediaPermissionRequest,
     };
     WKPageSetPageUIClient(m_mainWebView->page(), &pageUIClient.base);
 
@@ -546,6 +563,7 @@ void TestController::resetPreferencesToConsistentValues()
     WKPreferencesSetFontSmoothingLevel(preferences, kWKFontSmoothingLevelNoSubpixelAntiAliasing);
     WKPreferencesSetXSSAuditorEnabled(preferences, false);
     WKPreferencesSetWebAudioEnabled(preferences, true);
+    WKPreferencesSetMediaStreamEnabled(preferences, true);
     WKPreferencesSetDeveloperExtrasEnabled(preferences, true);
     WKPreferencesSetJavaScriptExperimentsEnabled(preferences, true);
     WKPreferencesSetJavaScriptCanOpenWindowsAutomatically(preferences, true);
@@ -649,6 +667,11 @@ bool TestController::resetStateToConsistentValues()
     m_isGeolocationPermissionSet = false;
     m_isGeolocationPermissionAllowed = false;
 
+    // Reset UserMedia permissions.
+    m_userMediaPermissionRequests.clear();
+    m_isUserMediaPermissionSet = false;
+    m_isUserMediaPermissionAllowed = false;
+
     // Reset Custom Policy Delegate.
     setCustomPolicyDelegate(false, false);
 
@@ -1366,6 +1389,33 @@ void TestController::handleGeolocationPermissionRequest(WKGeolocationPermissionR
     decidePolicyForGeolocationPermissionRequestIfPossible();
 }
 
+void TestController::setUserMediaPermission(bool enabled)
+{
+    m_isUserMediaPermissionSet = true;
+    m_isUserMediaPermissionAllowed = enabled;
+    decidePolicyForUserMediaPermissionRequestIfPossible();
+}
+
+void TestController::handleUserMediaPermissionRequest(WKUserMediaPermissionRequestRef userMediaPermissionRequest)
+{
+    m_userMediaPermissionRequests.append(userMediaPermissionRequest);
+    decidePolicyForUserMediaPermissionRequestIfPossible();
+}
+
+void TestController::decidePolicyForUserMediaPermissionRequestIfPossible()
+{
+    if (!m_isUserMediaPermissionSet)
+        return;
+
+    for (auto& request : m_userMediaPermissionRequests) {
+        if (m_isUserMediaPermissionAllowed)
+            WKUserMediaPermissionRequestAllow(request.get());
+        else
+            WKUserMediaPermissionRequestDeny(request.get());
+    }
+    m_userMediaPermissionRequests.clear();
+}
+
 void TestController::setCustomPolicyDelegate(bool enabled, bool permissive)
 {
     m_policyDelegateEnabled = enabled;
index 77d9b91..ada0a9e 100644 (file)
@@ -88,6 +88,10 @@ public:
     void setMockGeolocationPositionUnavailableError(WKStringRef errorMessage);
     void handleGeolocationPermissionRequest(WKGeolocationPermissionRequestRef);
 
+    // MediaStream.
+    void setUserMediaPermission(bool);
+    void handleUserMediaPermissionRequest(WKUserMediaPermissionRequestRef);
+
     // Policy delegate.
     void setCustomPolicyDelegate(bool enabled, bool permissive);
 
@@ -134,6 +138,7 @@ private:
     void updateLayoutTypeForTest(const TestInvocation&);
 
     void decidePolicyForGeolocationPermissionRequestIfPossible();
+    void decidePolicyForUserMediaPermissionRequestIfPossible();
 
     // WKContextInjectedBundleClient
     static void didReceiveMessageFromInjectedBundle(WKContextRef, WKStringRef messageName, WKTypeRef messageBody, const void*);
@@ -238,6 +243,10 @@ private:
     bool m_isGeolocationPermissionSet;
     bool m_isGeolocationPermissionAllowed;
 
+    Vector<WKRetainPtr<WKUserMediaPermissionRequestRef>> m_userMediaPermissionRequests;
+    bool m_isUserMediaPermissionSet;
+    bool m_isUserMediaPermissionAllowed;
+
     bool m_policyDelegateEnabled;
     bool m_policyDelegatePermissive;
 
index 3637703..87c46c4 100644 (file)
@@ -478,6 +478,13 @@ void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName
         return;
     }
 
+    if (WKStringIsEqualToUTF8CString(messageName, "SetUserMediaPermission")) {
+        ASSERT(WKGetTypeID(messageBody) == WKBooleanGetTypeID());
+        WKBooleanRef enabledWK = static_cast<WKBooleanRef>(messageBody);
+        TestController::shared().setUserMediaPermission(WKBooleanGetValue(enabledWK));
+        return;
+    }
+
     if (WKStringIsEqualToUTF8CString(messageName, "SetCustomPolicyDelegate")) {
         ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
         WKDictionaryRef messageBodyDictionary = static_cast<WKDictionaryRef>(messageBody);