Source

Target

Showing with 31 additions and 21 deletions
......@@ -332,11 +332,11 @@ void QWebEnginePagePrivate::runMediaAccessPermissionRequest(const QUrl &security
Q_Q(QWebEnginePage);
QWebEnginePage::Feature requestedFeature;
if (requestFlags.testFlag(WebContentsAdapterClient::MediaAudioCapture) && requestFlags.testFlag(WebContentsAdapterClient::MediaVideoCapture))
requestedFeature = QWebEnginePage::MediaAudioVideoDevices;
requestedFeature = QWebEnginePage::MediaAudioVideoCapture;
else if (requestFlags.testFlag(WebContentsAdapterClient::MediaAudioCapture))
requestedFeature = QWebEnginePage::MediaAudioDevices;
requestedFeature = QWebEnginePage::MediaAudioCapture;
else if (requestFlags.testFlag(WebContentsAdapterClient::MediaVideoCapture))
requestedFeature = QWebEnginePage::MediaVideoDevices;
requestedFeature = QWebEnginePage::MediaVideoCapture;
else
return;
Q_EMIT q->featurePermissionRequested(securityOrigin, requestedFeature);
......@@ -745,16 +745,16 @@ void QWebEnginePage::setFeaturePermission(const QUrl &securityOrigin, QWebEngine
Q_D(QWebEnginePage);
WebContentsAdapterClient::MediaRequestFlags flags = WebContentsAdapterClient::MediaNone;
switch (feature) {
case MediaAudioVideoDevices:
case MediaAudioDevices:
case MediaVideoDevices:
case MediaAudioVideoCapture:
case MediaAudioCapture:
case MediaVideoCapture:
if (policy != PermissionUnknown) {
if (policy == PermissionDeniedByUser)
flags = WebContentsAdapterClient::MediaNone;
else {
if (feature == MediaAudioDevices)
if (feature == MediaAudioCapture)
flags = WebContentsAdapterClient::MediaAudioCapture;
else if (feature == MediaVideoDevices)
else if (feature == MediaVideoCapture)
flags = WebContentsAdapterClient::MediaVideoCapture;
else
flags = WebContentsAdapterClient::MediaRequestFlags(WebContentsAdapterClient::MediaVideoCapture | WebContentsAdapterClient::MediaAudioCapture);
......
......@@ -122,7 +122,8 @@ public:
FindBackward = 1,
FindCaseSensitively = 2,
};
Q_DECLARE_FLAGS(FindFlags, FindFlag)
Q_DECLARE_FLAGS(FindFlags, FindFlag);
enum WebWindowType {
WebBrowserWindow,
WebBrowserTab,
......@@ -136,12 +137,15 @@ public:
};
enum Feature {
Notifications,
Geolocation,
MediaAudioDevices,
MediaVideoDevices,
MediaAudioVideoDevices
#ifndef Q_QDOC
Notifications = 0,
Geolocation = 1,
#endif
MediaAudioCapture = 2,
MediaVideoCapture,
MediaAudioVideoCapture
};
// Ex-QWebFrame enum
enum FileSelectionMode {
......
......@@ -151,11 +151,9 @@
This enum describes the platform feature access categories that the user may be asked to grant or deny access to.
\value Notifications Grants access to display notifications to the user.
\value Geolocation The geographic location devices that may be available.
\value MediaAudioDevices Audio devices such as speakers or microphones
\value MediaVideoDevices Video devices, e.g. cameras
\value MediaAudioVideoDevices Both Audio and Video devices.
\value MediaAudioCapture Audio capture devices such a microphones
\value MediaVideoCapture Video devices, e.g. cameras
\value MediaAudioVideoCapture Both Audio and Video capture devices.
\sa featurePermissionRequested(), featurePermissionRequestCanceled(), setFeaturePermission(), PermissionPolicy
......
......@@ -3635,14 +3635,14 @@ void tst_QWebEnginePage::getUserMediaRequest()
QVERIFY(evaluateJavaScriptSync(page, QStringLiteral("!!navigator.webkitGetUserMedia")).toBool());
evaluateJavaScriptSync(page, QStringLiteral("navigator.webkitGetUserMedia({audio: true}, function() {}, function(){})"));
QTRY_VERIFY_WITH_TIMEOUT(page->gotFeatureRequest(QWebEnginePage::MediaAudioDevices), 100);
QTRY_VERIFY_WITH_TIMEOUT(page->gotFeatureRequest(QWebEnginePage::MediaAudioCapture), 100);
// Might end up failing due to the lack of physical media devices deeper in the content layer, so the JS callback is not guaranteed to be called,
// but at least we go through that code path, potentially uncovering failing assertions.
page->acceptPendingRequest();
page->runJavaScript(QStringLiteral("errorCallbackCalled = false;"));
evaluateJavaScriptSync(page, QStringLiteral("navigator.webkitGetUserMedia({audio: true, video: true}, function() {}, function(){errorCallbackCalled = true;})"));
QTRY_VERIFY_WITH_TIMEOUT(page->gotFeatureRequest(QWebEnginePage::MediaAudioVideoDevices), 100);
QTRY_VERIFY_WITH_TIMEOUT(page->gotFeatureRequest(QWebEnginePage::MediaAudioVideoCapture), 100);
page->rejectPendingRequest(); // Should always end up calling the error callback in JS.
QTRY_VERIFY_WITH_TIMEOUT(evaluateJavaScriptSync(page, QStringLiteral("errorCallbackCalled;")).toBool(), 100);
delete page;
......
......@@ -70,6 +70,7 @@ ApplicationWindow {
Settings {
property alias autoLoadImages: loadImages.checked;
property alias javaScriptEnabled: javaScriptEnabled.checked;
property alias errorPageEnabled: errorPageEnabled.checked;
}
// Make sure the Qt.WindowFullscreenButtonHint is set on Mac.
......@@ -215,6 +216,13 @@ ApplicationWindow {
checked: WebEngine.settings.javascriptEnabled
onCheckedChanged: WebEngine.settings.javascriptEnabled = checked
}
MenuItem {
id: errorPageEnabled
text: "ErrorPage On"
checkable: true
checked: WebEngine.settings.errorPageEnabled
onCheckedChanged: WebEngine.settings.errorPageEnabled = checked
}
}
}
}
......