From 8acb30da8e1f19d8c906539cd0e16b1280e1fca2 Mon Sep 17 00:00:00 2001 From: "James B. Pollack" Date: Sun, 24 Jul 2016 16:54:00 -0700 Subject: [PATCH] add permissions bar --- interface/resources/qml/Browser.qml | 86 ++++++++++++++++++- .../resources/qml/controls-uit/WebView.qml | 4 - 2 files changed, 83 insertions(+), 7 deletions(-) diff --git a/interface/resources/qml/Browser.qml b/interface/resources/qml/Browser.qml index 3057cd3330..9d709a309f 100644 --- a/interface/resources/qml/Browser.qml +++ b/interface/resources/qml/Browser.qml @@ -16,6 +16,7 @@ ScrollingWindow { destroyOnHidden: true width: 800 height: 600 + property variant permissionsBar: {'securityOrigin':'none','feature':'none'} property alias webView: webview x: 100 y: 100 @@ -32,6 +33,21 @@ ScrollingWindow { } } + function showPermissionsBar(){ + console.log('should show permissions bar') + permissionsContainer.visible=true; + } + + function hidePermissionsBar(){ + console.log('should hide permissions bar') + permissionsContainer.visible=false; + } + + function allowPermissions(){ + webview.grantFeaturePermission(permissionsBar.securityOrigin, permissionsBar.feature, true); + hidePermissionsBar(); + } + Item { id:item width: pane.contentWidth @@ -70,6 +86,7 @@ ScrollingWindow { size: 48 MouseArea { anchors.fill: parent; onClicked: webview.goForward() } } + } Item { @@ -116,6 +133,7 @@ ScrollingWindow { if (text.indexOf("http") != 0) { text = "http://" + text } + root.hidePermissionsBar(); webview.url = text break; } @@ -123,16 +141,78 @@ ScrollingWindow { } } + Rectangle { + id:permissionsContainer + visible:false + color: "#000000" + width: parent.width + anchors.top: buttons.bottom + height:40 + z:100 + gradient: Gradient { + GradientStop { position: 0.0; color: "black" } + GradientStop { position: 1.0; color: "grey" } + } + + RalewayLight { + id: permissionsInfo + anchors.right:permissionsRow.left + anchors.rightMargin: 32 + anchors.topMargin:8 + anchors.top:parent.top + text: "This site wants to use your microphone/camera" + size: 18 + color: hifi.colors.white + } + + Row { + id: permissionsRow + spacing: 4 + anchors.top:parent.top + anchors.topMargin: 8 + anchors.right: parent.right + visible: true + z:101 + + Button { + id:allow + text: "Allow" + color: hifi.buttons.blue + colorScheme: root.colorScheme + width: 120 + enabled: true + onClicked: root.allowPermissions(); + z:101 + } + + Button { + id:block + text: "Block" + color: hifi.buttons.red + colorScheme: root.colorScheme + width: 120 + enabled: true + onClicked: root.hidePermissionsBar(); + z:101 + } + } + } + + + + WebEngineView { id: webview - url: "http://highfidelity.com" + url: "https://highfidelity.com" anchors.top: buttons.bottom anchors.topMargin: 8 anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right onFeaturePermissionRequested: { - grantFeaturePermission(securityOrigin, feature, true); + permissionsBar.securityOrigin =securityOrigin; + permissionsBar.feature = feature; + root.showPermissionsBar(); } onLoadingChanged: { if (loadRequest.status === WebEngineView.LoadSucceededStatus) { @@ -164,4 +244,4 @@ ScrollingWindow { break; } } -} // dialog +} // dialog \ No newline at end of file diff --git a/interface/resources/qml/controls-uit/WebView.qml b/interface/resources/qml/controls-uit/WebView.qml index acd0e1ae12..4c165fc587 100644 --- a/interface/resources/qml/controls-uit/WebView.qml +++ b/interface/resources/qml/controls-uit/WebView.qml @@ -48,10 +48,6 @@ WebEngineView { } } - onFeaturePermissionRequested: { - grantFeaturePermission(securityOrigin, feature, true); - } - onLoadingChanged: { // Required to support clicking on "hifi://" links if (WebEngineView.LoadStartedStatus == loadRequest.status) {