add permissions bar

This commit is contained in:
James B. Pollack 2016-07-24 16:54:00 -07:00
parent aacddcf66d
commit 8acb30da8e
2 changed files with 83 additions and 7 deletions

View file

@ -16,6 +16,7 @@ ScrollingWindow {
destroyOnHidden: true destroyOnHidden: true
width: 800 width: 800
height: 600 height: 600
property variant permissionsBar: {'securityOrigin':'none','feature':'none'}
property alias webView: webview property alias webView: webview
x: 100 x: 100
y: 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 { Item {
id:item id:item
width: pane.contentWidth width: pane.contentWidth
@ -70,6 +86,7 @@ ScrollingWindow {
size: 48 size: 48
MouseArea { anchors.fill: parent; onClicked: webview.goForward() } MouseArea { anchors.fill: parent; onClicked: webview.goForward() }
} }
} }
Item { Item {
@ -116,6 +133,7 @@ ScrollingWindow {
if (text.indexOf("http") != 0) { if (text.indexOf("http") != 0) {
text = "http://" + text text = "http://" + text
} }
root.hidePermissionsBar();
webview.url = text webview.url = text
break; 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 { WebEngineView {
id: webview id: webview
url: "http://highfidelity.com" url: "https://highfidelity.com"
anchors.top: buttons.bottom anchors.top: buttons.bottom
anchors.topMargin: 8 anchors.topMargin: 8
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
onFeaturePermissionRequested: { onFeaturePermissionRequested: {
grantFeaturePermission(securityOrigin, feature, true); permissionsBar.securityOrigin =securityOrigin;
permissionsBar.feature = feature;
root.showPermissionsBar();
} }
onLoadingChanged: { onLoadingChanged: {
if (loadRequest.status === WebEngineView.LoadSucceededStatus) { if (loadRequest.status === WebEngineView.LoadSucceededStatus) {
@ -164,4 +244,4 @@ ScrollingWindow {
break; break;
} }
} }
} // dialog } // dialog

View file

@ -48,10 +48,6 @@ WebEngineView {
} }
} }
onFeaturePermissionRequested: {
grantFeaturePermission(securityOrigin, feature, true);
}
onLoadingChanged: { onLoadingChanged: {
// Required to support clicking on "hifi://" links // Required to support clicking on "hifi://" links
if (WebEngineView.LoadStartedStatus == loadRequest.status) { if (WebEngineView.LoadStartedStatus == loadRequest.status) {