mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-05-29 15:31:39 +02:00
Add QML portions of userAgent handling. (FML)
This commit is contained in:
parent
f8119daa47
commit
dac9c49175
4 changed files with 37 additions and 18 deletions
|
@ -19,16 +19,17 @@ Item {
|
||||||
property string url: ""
|
property string url: ""
|
||||||
property string scriptUrl: null
|
property string scriptUrl: null
|
||||||
property bool useBackground: true
|
property bool useBackground: true
|
||||||
|
property string userAgent: ""
|
||||||
|
|
||||||
onUrlChanged: {
|
onUrlChanged: {
|
||||||
load(root.url, root.scriptUrl, root.useBackground);
|
load(root.url, root.scriptUrl, root.useBackground, root.userAgent);
|
||||||
}
|
}
|
||||||
|
|
||||||
onScriptUrlChanged: {
|
onScriptUrlChanged: {
|
||||||
if (root.item) {
|
if (root.item) {
|
||||||
root.item.scriptUrl = root.scriptUrl;
|
root.item.scriptUrl = root.scriptUrl;
|
||||||
} else {
|
} else {
|
||||||
load(root.url, root.scriptUrl, root.useBackground);
|
load(root.url, root.scriptUrl, root.useBackground, root.userAgent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,14 +37,22 @@ Item {
|
||||||
if (root.item) {
|
if (root.item) {
|
||||||
root.item.useBackground = root.useBackground;
|
root.item.useBackground = root.useBackground;
|
||||||
} else {
|
} else {
|
||||||
load(root.url, root.scriptUrl, root.useBackground);
|
load(root.url, root.scriptUrl, root.useBackground, root.userAgent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
onUserAgentChanged: {
|
||||||
|
if (root.item) {
|
||||||
|
root.item.userAgent = root.userAgent;
|
||||||
|
} else {
|
||||||
|
load(root.url, root.scriptUrl, root.useBackground, root.userAgent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
property var item: null
|
property var item: null
|
||||||
|
|
||||||
function load(url, scriptUrl, useBackground) {
|
function load(url, scriptUrl, useBackground, userAgent) {
|
||||||
// Ensure we reset any existing item to "about:blank" to ensure web audio stops: DEV-2375
|
// Ensure we reset any existing item toB "about:blank" to ensure web audio stops: DEV-2375
|
||||||
if (root.item != null) {
|
if (root.item != null) {
|
||||||
root.item.url = "about:blank"
|
root.item.url = "about:blank"
|
||||||
root.item.destroy()
|
root.item.destroy()
|
||||||
|
@ -54,11 +63,12 @@ Item {
|
||||||
root.item.url = url
|
root.item.url = url
|
||||||
root.item.scriptUrl = scriptUrl
|
root.item.scriptUrl = scriptUrl
|
||||||
root.item.useBackground = useBackground
|
root.item.useBackground = useBackground
|
||||||
|
root.item.userAgent = userAgent
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
load(root.url, root.scriptUrl, root.useBackground);
|
load(root.url, root.scriptUrl, root.useBackground, root.userAgent);
|
||||||
}
|
}
|
||||||
|
|
||||||
signal sendToScript(var message);
|
signal sendToScript(var message);
|
||||||
|
|
|
@ -13,10 +13,11 @@ Item {
|
||||||
property alias url: webViewCore.url
|
property alias url: webViewCore.url
|
||||||
property alias canGoBack: webViewCore.canGoBack
|
property alias canGoBack: webViewCore.canGoBack
|
||||||
property alias webViewCore: webViewCore
|
property alias webViewCore: webViewCore
|
||||||
property alias webViewCoreProfile: webViewCore.profile
|
// property alias webViewCoreProfile: webViewCore.profile
|
||||||
property string webViewCoreUserAgent
|
property string webViewCoreUserAgent
|
||||||
|
|
||||||
property bool useBackground: webViewCore.useBackground
|
property bool useBackground: webViewCore.useBackground
|
||||||
|
property string userAgent: webViewCore.profile.httpUserAgent
|
||||||
property string userScriptUrl: ""
|
property string userScriptUrl: ""
|
||||||
property string urlTag: "noDownload=false";
|
property string urlTag: "noDownload=false";
|
||||||
|
|
||||||
|
@ -34,6 +35,10 @@ Item {
|
||||||
permissionPopupBackground.visible = false;
|
permissionPopupBackground.visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onUserAgentChanged: {
|
||||||
|
webViewCore.profile.httpUserAgent = flick.userAgent;
|
||||||
|
}
|
||||||
|
|
||||||
StylesUIt.HifiConstants {
|
StylesUIt.HifiConstants {
|
||||||
id: hifi
|
id: hifi
|
||||||
}
|
}
|
||||||
|
@ -74,7 +79,7 @@ Item {
|
||||||
|
|
||||||
function onLoadingChanged(loadRequest) {
|
function onLoadingChanged(loadRequest) {
|
||||||
if (WebEngineView.LoadStartedStatus === loadRequest.status) {
|
if (WebEngineView.LoadStartedStatus === loadRequest.status) {
|
||||||
|
webViewCore.profile.httpUserAgent = flick.userAgent;
|
||||||
// Required to support clicking on "hifi://" links
|
// Required to support clicking on "hifi://" links
|
||||||
var url = loadRequest.url.toString();
|
var url = loadRequest.url.toString();
|
||||||
url = (url.indexOf("?") >= 0) ? url + urlTag : url + "?" + urlTag;
|
url = (url.indexOf("?") >= 0) ? url + urlTag : url + "?" + urlTag;
|
||||||
|
@ -101,7 +106,6 @@ Item {
|
||||||
height: parent.height
|
height: parent.height
|
||||||
backgroundColor: (flick.useBackground) ? "white" : "transparent"
|
backgroundColor: (flick.useBackground) ? "white" : "transparent"
|
||||||
|
|
||||||
profile: HFWebEngineProfile;
|
|
||||||
settings.pluginsEnabled: true
|
settings.pluginsEnabled: true
|
||||||
settings.touchIconsEnabled: true
|
settings.touchIconsEnabled: true
|
||||||
settings.allowRunningInsecureContent: true
|
settings.allowRunningInsecureContent: true
|
||||||
|
@ -136,8 +140,10 @@ Item {
|
||||||
webChannel.registerObject("eventBridge", eventBridge);
|
webChannel.registerObject("eventBridge", eventBridge);
|
||||||
webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper);
|
webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper);
|
||||||
|
|
||||||
if (webViewCoreUserAgent !== undefined) {
|
if (flick.userAgent !== undefined) {
|
||||||
webViewCore.profile.httpUserAgent = webViewCoreUserAgent
|
webViewCore.profile.httpUserAgent = flick.userAgent;
|
||||||
|
webViewCore.profile.offTheRecord = false;
|
||||||
|
webViewCore.profile.storageName = "qmlWebEngine";
|
||||||
} else {
|
} else {
|
||||||
webViewCore.profile.httpUserAgent += " (VircadiaInterface)";
|
webViewCore.profile.httpUserAgent += " (VircadiaInterface)";
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,12 +11,12 @@ Item {
|
||||||
property alias url: webViewCore.url
|
property alias url: webViewCore.url
|
||||||
property alias canGoBack: webViewCore.canGoBack
|
property alias canGoBack: webViewCore.canGoBack
|
||||||
property alias webViewCore: webViewCore
|
property alias webViewCore: webViewCore
|
||||||
property alias webViewCoreProfile: webViewCore.profile
|
// property alias webViewCoreProfile: webViewCore.profile
|
||||||
property string webViewCoreUserAgent
|
|
||||||
|
|
||||||
property bool useBackground: webViewCore.useBackground
|
property alias useBackground: webViewCore.useBackground
|
||||||
|
property alias userAgent: webViewCore.userAgent
|
||||||
property string userScriptUrl: ""
|
property string userScriptUrl: ""
|
||||||
property string urlTag: "noDownload=false";
|
property string urlTag: "noDownload=false"
|
||||||
|
|
||||||
signal newViewRequestedCallback(var request)
|
signal newViewRequestedCallback(var request)
|
||||||
signal loadingChangedCallback(var loadRequest)
|
signal loadingChangedCallback(var loadRequest)
|
||||||
|
@ -43,10 +43,12 @@ Item {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onLoadingChanged(loadRequest) {
|
function onLoadingChanged(loadRequest) {
|
||||||
|
webViewCore.profile.httpUserAgent: "LOLICON"
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlsUit.ProxyWebView {
|
ControlsUit.ProxyWebView {
|
||||||
id: webViewCore
|
id:
|
||||||
|
profile: WebEngineProfile { httpUserAgent: "TEST2"}
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height
|
height: parent.height
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ Item {
|
||||||
property alias flickable: webroot.interactive
|
property alias flickable: webroot.interactive
|
||||||
property alias blurOnCtrlShift: webroot.blurOnCtrlShift
|
property alias blurOnCtrlShift: webroot.blurOnCtrlShift
|
||||||
property alias useBackground: webroot.useBackground
|
property alias useBackground: webroot.useBackground
|
||||||
|
property alias userAgent: webroot.userAgent
|
||||||
|
|
||||||
function stop() {
|
function stop() {
|
||||||
webroot.stop();
|
webroot.stop();
|
||||||
|
@ -37,13 +38,13 @@ Item {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
property alias viewProfile: webroot.webViewCoreProfile
|
// property alias viewProfile: webroot.webViewCoreProfile
|
||||||
|
|
||||||
FlickableWebViewCore {
|
FlickableWebViewCore {
|
||||||
id: webroot
|
id: webroot
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: keyboardEnabled && keyboardRaised ? parent.height - keyboard.height : parent.height
|
height: keyboardEnabled && keyboardRaised ? parent.height - keyboard.height : parent.height
|
||||||
|
|
||||||
onLoadingChangedCallback: {
|
onLoadingChangedCallback: {
|
||||||
keyboardRaised = false;
|
keyboardRaised = false;
|
||||||
punctuationMode = false;
|
punctuationMode = false;
|
||||||
|
|
Loading…
Reference in a new issue