mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 08:49:05 +02:00
Merge pull request #988 from digisomni/feature/web-entity-user-agent
Feature/web entity user agent
This commit is contained in:
commit
312dc9fe22
16 changed files with 101 additions and 31 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,13 +37,21 @@ 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 to "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"
|
||||||
|
@ -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,10 @@ 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 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 +34,10 @@ Item {
|
||||||
permissionPopupBackground.visible = false;
|
permissionPopupBackground.visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onUserAgentChanged: {
|
||||||
|
webViewCore.profile.httpUserAgent = flick.userAgent;
|
||||||
|
}
|
||||||
|
|
||||||
StylesUIt.HifiConstants {
|
StylesUIt.HifiConstants {
|
||||||
id: hifi
|
id: hifi
|
||||||
}
|
}
|
||||||
|
@ -74,7 +78,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 +105,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 +139,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,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 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)
|
||||||
|
|
|
@ -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,8 +38,6 @@ Item {
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
property alias viewProfile: webroot.webViewCoreProfile
|
|
||||||
|
|
||||||
FlickableWebViewCore {
|
FlickableWebViewCore {
|
||||||
id: webroot
|
id: webroot
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
|
@ -39,6 +39,7 @@ const char* WebEntityRenderer::URL_PROPERTY = "url";
|
||||||
const char* WebEntityRenderer::SCRIPT_URL_PROPERTY = "scriptURL";
|
const char* WebEntityRenderer::SCRIPT_URL_PROPERTY = "scriptURL";
|
||||||
const char* WebEntityRenderer::GLOBAL_POSITION_PROPERTY = "globalPosition";
|
const char* WebEntityRenderer::GLOBAL_POSITION_PROPERTY = "globalPosition";
|
||||||
const char* WebEntityRenderer::USE_BACKGROUND_PROPERTY = "useBackground";
|
const char* WebEntityRenderer::USE_BACKGROUND_PROPERTY = "useBackground";
|
||||||
|
const char* WebEntityRenderer::USER_AGENT_PROPERTY = "userAgent";
|
||||||
|
|
||||||
std::function<void(QString, bool, QSharedPointer<OffscreenQmlSurface>&, bool&)> WebEntityRenderer::_acquireWebSurfaceOperator = nullptr;
|
std::function<void(QString, bool, QSharedPointer<OffscreenQmlSurface>&, bool&)> WebEntityRenderer::_acquireWebSurfaceOperator = nullptr;
|
||||||
std::function<void(QSharedPointer<OffscreenQmlSurface>&, bool&, std::vector<QMetaObject::Connection>&)> WebEntityRenderer::_releaseWebSurfaceOperator = nullptr;
|
std::function<void(QSharedPointer<OffscreenQmlSurface>&, bool&, std::vector<QMetaObject::Connection>&)> WebEntityRenderer::_releaseWebSurfaceOperator = nullptr;
|
||||||
|
@ -194,6 +195,7 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene
|
||||||
_webSurface->getRootItem()->setProperty(URL_PROPERTY, newSourceURL);
|
_webSurface->getRootItem()->setProperty(URL_PROPERTY, newSourceURL);
|
||||||
_webSurface->getRootItem()->setProperty(SCRIPT_URL_PROPERTY, _scriptURL);
|
_webSurface->getRootItem()->setProperty(SCRIPT_URL_PROPERTY, _scriptURL);
|
||||||
_webSurface->getRootItem()->setProperty(USE_BACKGROUND_PROPERTY, _useBackground);
|
_webSurface->getRootItem()->setProperty(USE_BACKGROUND_PROPERTY, _useBackground);
|
||||||
|
_webSurface->getRootItem()->setProperty(USER_AGENT_PROPERTY, _userAgent);
|
||||||
_webSurface->getSurfaceContext()->setContextProperty(GLOBAL_POSITION_PROPERTY, vec3toVariant(_contextPosition));
|
_webSurface->getSurfaceContext()->setContextProperty(GLOBAL_POSITION_PROPERTY, vec3toVariant(_contextPosition));
|
||||||
_webSurface->setMaxFps((QUrl(newSourceURL).host().endsWith("youtube.com", Qt::CaseInsensitive)) ? YOUTUBE_MAX_FPS : _maxFPS);
|
_webSurface->setMaxFps((QUrl(newSourceURL).host().endsWith("youtube.com", Qt::CaseInsensitive)) ? YOUTUBE_MAX_FPS : _maxFPS);
|
||||||
::hifi::scripting::setLocalAccessSafeThread(false);
|
::hifi::scripting::setLocalAccessSafeThread(false);
|
||||||
|
@ -231,6 +233,14 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene
|
||||||
_useBackground = useBackground;
|
_useBackground = useBackground;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
auto userAgent = entity->getUserAgent();
|
||||||
|
if (_userAgent != userAgent) {
|
||||||
|
_webSurface->getRootItem()->setProperty(USER_AGENT_PROPERTY, userAgent);
|
||||||
|
_userAgent = userAgent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
auto contextPosition = entity->getWorldPosition();
|
auto contextPosition = entity->getWorldPosition();
|
||||||
|
|
|
@ -36,6 +36,7 @@ public:
|
||||||
static const char* SCRIPT_URL_PROPERTY;
|
static const char* SCRIPT_URL_PROPERTY;
|
||||||
static const char* GLOBAL_POSITION_PROPERTY;
|
static const char* GLOBAL_POSITION_PROPERTY;
|
||||||
static const char* USE_BACKGROUND_PROPERTY;
|
static const char* USE_BACKGROUND_PROPERTY;
|
||||||
|
static const char* USER_AGENT_PROPERTY;
|
||||||
|
|
||||||
static void setAcquireWebSurfaceOperator(std::function<void(const QString&, bool, QSharedPointer<OffscreenQmlSurface>&, bool&)> acquireWebSurfaceOperator) { _acquireWebSurfaceOperator = acquireWebSurfaceOperator; }
|
static void setAcquireWebSurfaceOperator(std::function<void(const QString&, bool, QSharedPointer<OffscreenQmlSurface>&, bool&)> acquireWebSurfaceOperator) { _acquireWebSurfaceOperator = acquireWebSurfaceOperator; }
|
||||||
static void acquireWebSurface(const QString& url, bool htmlContent, QSharedPointer<OffscreenQmlSurface>& webSurface, bool& cachedWebSurface) {
|
static void acquireWebSurface(const QString& url, bool htmlContent, QSharedPointer<OffscreenQmlSurface>& webSurface, bool& cachedWebSurface) {
|
||||||
|
@ -97,6 +98,7 @@ private:
|
||||||
QString _scriptURL;
|
QString _scriptURL;
|
||||||
uint8_t _maxFPS;
|
uint8_t _maxFPS;
|
||||||
bool _useBackground;
|
bool _useBackground;
|
||||||
|
QString _userAgent;
|
||||||
WebInputMode _inputMode;
|
WebInputMode _inputMode;
|
||||||
|
|
||||||
glm::vec3 _contextPosition;
|
glm::vec3 _contextPosition;
|
||||||
|
|
|
@ -604,6 +604,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
||||||
CHECK_PROPERTY_CHANGE(PROP_INPUT_MODE, inputMode);
|
CHECK_PROPERTY_CHANGE(PROP_INPUT_MODE, inputMode);
|
||||||
CHECK_PROPERTY_CHANGE(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, showKeyboardFocusHighlight);
|
CHECK_PROPERTY_CHANGE(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, showKeyboardFocusHighlight);
|
||||||
CHECK_PROPERTY_CHANGE(PROP_WEB_USE_BACKGROUND, useBackground);
|
CHECK_PROPERTY_CHANGE(PROP_WEB_USE_BACKGROUND, useBackground);
|
||||||
|
CHECK_PROPERTY_CHANGE(PROP_USER_AGENT, userAgent);
|
||||||
|
|
||||||
// Polyline
|
// Polyline
|
||||||
CHECK_PROPERTY_CHANGE(PROP_LINE_POINTS, linePoints);
|
CHECK_PROPERTY_CHANGE(PROP_LINE_POINTS, linePoints);
|
||||||
|
@ -1391,6 +1392,9 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
||||||
* @property {boolean} useBackground=true - <code>true</code> if the web entity should have a background,
|
* @property {boolean} useBackground=true - <code>true</code> if the web entity should have a background,
|
||||||
* <code>false</code> if the web entity's background should be transparent. The webpage must have CSS properties for transparency set
|
* <code>false</code> if the web entity's background should be transparent. The webpage must have CSS properties for transparency set
|
||||||
* on the <code>background-color</code> for this property to have an effect.
|
* on the <code>background-color</code> for this property to have an effect.
|
||||||
|
* @property {string} userAgent - The user agent for the web entity to use when visiting web pages.
|
||||||
|
* Default value: <code>Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko)
|
||||||
|
* Chrome/69.0.3497.113 Mobile Safari/537.36</code>
|
||||||
* @example <caption>Create a Web entity displaying at 1920 x 1080 resolution.</caption>
|
* @example <caption>Create a Web entity displaying at 1920 x 1080 resolution.</caption>
|
||||||
* var METERS_TO_INCHES = 39.3701;
|
* var METERS_TO_INCHES = 39.3701;
|
||||||
* var entity = Entities.addEntity({
|
* var entity = Entities.addEntity({
|
||||||
|
@ -1830,6 +1834,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_INPUT_MODE, inputMode, getInputModeAsString());
|
COPY_PROPERTY_TO_QSCRIPTVALUE_GETTER(PROP_INPUT_MODE, inputMode, getInputModeAsString());
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, showKeyboardFocusHighlight);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, showKeyboardFocusHighlight);
|
||||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_WEB_USE_BACKGROUND, useBackground);
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_WEB_USE_BACKGROUND, useBackground);
|
||||||
|
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_USER_AGENT, userAgent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// PolyVoxel only
|
// PolyVoxel only
|
||||||
|
@ -2213,6 +2218,7 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool
|
||||||
COPY_PROPERTY_FROM_QSCRIPTVALUE_ENUM(inputMode, InputMode);
|
COPY_PROPERTY_FROM_QSCRIPTVALUE_ENUM(inputMode, InputMode);
|
||||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(showKeyboardFocusHighlight, bool, setShowKeyboardFocusHighlight);
|
COPY_PROPERTY_FROM_QSCRIPTVALUE(showKeyboardFocusHighlight, bool, setShowKeyboardFocusHighlight);
|
||||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(useBackground, bool, setUseBackground);
|
COPY_PROPERTY_FROM_QSCRIPTVALUE(useBackground, bool, setUseBackground);
|
||||||
|
COPY_PROPERTY_FROM_QSCRIPTVALUE(userAgent, QString, setUserAgent);
|
||||||
|
|
||||||
// Polyline
|
// Polyline
|
||||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(linePoints, qVectorVec3, setLinePoints);
|
COPY_PROPERTY_FROM_QSCRIPTVALUE(linePoints, qVectorVec3, setLinePoints);
|
||||||
|
@ -2506,6 +2512,7 @@ void EntityItemProperties::merge(const EntityItemProperties& other) {
|
||||||
COPY_PROPERTY_IF_CHANGED(inputMode);
|
COPY_PROPERTY_IF_CHANGED(inputMode);
|
||||||
COPY_PROPERTY_IF_CHANGED(showKeyboardFocusHighlight);
|
COPY_PROPERTY_IF_CHANGED(showKeyboardFocusHighlight);
|
||||||
COPY_PROPERTY_IF_CHANGED(useBackground);
|
COPY_PROPERTY_IF_CHANGED(useBackground);
|
||||||
|
COPY_PROPERTY_IF_CHANGED(userAgent);
|
||||||
|
|
||||||
// Polyline
|
// Polyline
|
||||||
COPY_PROPERTY_IF_CHANGED(linePoints);
|
COPY_PROPERTY_IF_CHANGED(linePoints);
|
||||||
|
@ -2907,6 +2914,7 @@ bool EntityItemProperties::getPropertyInfo(const QString& propertyName, EntityPr
|
||||||
ADD_PROPERTY_TO_MAP(PROP_INPUT_MODE, InputMode, inputMode, WebInputMode);
|
ADD_PROPERTY_TO_MAP(PROP_INPUT_MODE, InputMode, inputMode, WebInputMode);
|
||||||
ADD_PROPERTY_TO_MAP(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, ShowKeyboardFocusHighlight, showKeyboardFocusHighlight, bool);
|
ADD_PROPERTY_TO_MAP(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, ShowKeyboardFocusHighlight, showKeyboardFocusHighlight, bool);
|
||||||
ADD_PROPERTY_TO_MAP(PROP_WEB_USE_BACKGROUND, useBackground, useBackground, bool);
|
ADD_PROPERTY_TO_MAP(PROP_WEB_USE_BACKGROUND, useBackground, useBackground, bool);
|
||||||
|
ADD_PROPERTY_TO_MAP(PROP_USER_AGENT, UserAgent, userAgent, QString);
|
||||||
|
|
||||||
// Polyline
|
// Polyline
|
||||||
ADD_PROPERTY_TO_MAP(PROP_LINE_POINTS, LinePoints, linePoints, QVector<vec3>);
|
ADD_PROPERTY_TO_MAP(PROP_LINE_POINTS, LinePoints, linePoints, QVector<vec3>);
|
||||||
|
@ -3339,6 +3347,7 @@ OctreeElement::AppendState EntityItemProperties::encodeEntityEditPacket(PacketTy
|
||||||
APPEND_ENTITY_PROPERTY(PROP_INPUT_MODE, (uint32_t)properties.getInputMode());
|
APPEND_ENTITY_PROPERTY(PROP_INPUT_MODE, (uint32_t)properties.getInputMode());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, properties.getShowKeyboardFocusHighlight());
|
APPEND_ENTITY_PROPERTY(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, properties.getShowKeyboardFocusHighlight());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_WEB_USE_BACKGROUND, properties.getUseBackground());
|
APPEND_ENTITY_PROPERTY(PROP_WEB_USE_BACKGROUND, properties.getUseBackground());
|
||||||
|
APPEND_ENTITY_PROPERTY(PROP_USER_AGENT, properties.getUserAgent());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties.getType() == EntityTypes::Line) {
|
if (properties.getType() == EntityTypes::Line) {
|
||||||
|
@ -3816,6 +3825,7 @@ bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_INPUT_MODE, WebInputMode, setInputMode);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_INPUT_MODE, WebInputMode, setInputMode);
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, bool, setShowKeyboardFocusHighlight);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, bool, setShowKeyboardFocusHighlight);
|
||||||
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_WEB_USE_BACKGROUND, bool, setUseBackground);
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_WEB_USE_BACKGROUND, bool, setUseBackground);
|
||||||
|
READ_ENTITY_PROPERTY_TO_PROPERTIES(PROP_USER_AGENT, QString, setUserAgent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (properties.getType() == EntityTypes::Line) {
|
if (properties.getType() == EntityTypes::Line) {
|
||||||
|
@ -4205,6 +4215,7 @@ void EntityItemProperties::markAllChanged() {
|
||||||
_inputModeChanged = true;
|
_inputModeChanged = true;
|
||||||
_showKeyboardFocusHighlightChanged = true;
|
_showKeyboardFocusHighlightChanged = true;
|
||||||
_useBackgroundChanged = true;
|
_useBackgroundChanged = true;
|
||||||
|
_userAgentChanged = true;
|
||||||
|
|
||||||
// Polyline
|
// Polyline
|
||||||
_linePointsChanged = true;
|
_linePointsChanged = true;
|
||||||
|
@ -4901,6 +4912,9 @@ QList<QString> EntityItemProperties::listChangedProperties() {
|
||||||
if (useBackgroundChanged()) {
|
if (useBackgroundChanged()) {
|
||||||
out += "useBackground";
|
out += "useBackground";
|
||||||
}
|
}
|
||||||
|
if (userAgentChanged()) {
|
||||||
|
out += "userAgent";
|
||||||
|
}
|
||||||
|
|
||||||
// Shape
|
// Shape
|
||||||
if (shapeChanged()) {
|
if (shapeChanged()) {
|
||||||
|
|
|
@ -368,6 +368,7 @@ public:
|
||||||
DEFINE_PROPERTY_REF_ENUM(PROP_INPUT_MODE, InputMode, inputMode, WebInputMode, WebInputMode::TOUCH);
|
DEFINE_PROPERTY_REF_ENUM(PROP_INPUT_MODE, InputMode, inputMode, WebInputMode, WebInputMode::TOUCH);
|
||||||
DEFINE_PROPERTY_REF(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, ShowKeyboardFocusHighlight, showKeyboardFocusHighlight, bool, true);
|
DEFINE_PROPERTY_REF(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, ShowKeyboardFocusHighlight, showKeyboardFocusHighlight, bool, true);
|
||||||
DEFINE_PROPERTY_REF(PROP_WEB_USE_BACKGROUND, UseBackground, useBackground, bool, true);
|
DEFINE_PROPERTY_REF(PROP_WEB_USE_BACKGROUND, UseBackground, useBackground, bool, true);
|
||||||
|
DEFINE_PROPERTY_REF(PROP_USER_AGENT, UserAgent, userAgent, QString, WebEntityItem::DEFAULT_USER_AGENT);
|
||||||
|
|
||||||
// Polyline
|
// Polyline
|
||||||
DEFINE_PROPERTY_REF(PROP_LINE_POINTS, LinePoints, linePoints, QVector<glm::vec3>, ENTITY_ITEM_DEFAULT_EMPTY_VEC3_QVEC);
|
DEFINE_PROPERTY_REF(PROP_LINE_POINTS, LinePoints, linePoints, QVector<glm::vec3>, ENTITY_ITEM_DEFAULT_EMPTY_VEC3_QVEC);
|
||||||
|
|
|
@ -320,6 +320,7 @@ enum EntityPropertyList {
|
||||||
PROP_INPUT_MODE = PROP_DERIVED_4,
|
PROP_INPUT_MODE = PROP_DERIVED_4,
|
||||||
PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT = PROP_DERIVED_5,
|
PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT = PROP_DERIVED_5,
|
||||||
PROP_WEB_USE_BACKGROUND = PROP_DERIVED_6,
|
PROP_WEB_USE_BACKGROUND = PROP_DERIVED_6,
|
||||||
|
PROP_USER_AGENT = PROP_DERIVED_7,
|
||||||
|
|
||||||
// Polyline
|
// Polyline
|
||||||
PROP_LINE_POINTS = PROP_DERIVED_0,
|
PROP_LINE_POINTS = PROP_DERIVED_0,
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "EntityTreeElement.h"
|
#include "EntityTreeElement.h"
|
||||||
|
|
||||||
const QString WebEntityItem::DEFAULT_SOURCE_URL = NetworkingConstants::WEB_ENTITY_DEFAULT_SOURCE_URL;
|
const QString WebEntityItem::DEFAULT_SOURCE_URL = NetworkingConstants::WEB_ENTITY_DEFAULT_SOURCE_URL;
|
||||||
|
const QString WebEntityItem::DEFAULT_USER_AGENT = NetworkingConstants::WEB_ENTITY_DEFAULT_USER_AGENT;
|
||||||
const uint8_t WebEntityItem::DEFAULT_MAX_FPS = 10;
|
const uint8_t WebEntityItem::DEFAULT_MAX_FPS = 10;
|
||||||
|
|
||||||
EntityItemPointer WebEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
EntityItemPointer WebEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||||
|
@ -63,6 +64,7 @@ EntityItemProperties WebEntityItem::getProperties(const EntityPropertyFlags& des
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(inputMode, getInputMode);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(inputMode, getInputMode);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(showKeyboardFocusHighlight, getShowKeyboardFocusHighlight);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(showKeyboardFocusHighlight, getShowKeyboardFocusHighlight);
|
||||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(useBackground, getUseBackground);
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(useBackground, getUseBackground);
|
||||||
|
COPY_ENTITY_PROPERTY_TO_PROPERTIES(userAgent, getUserAgent);
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,6 +87,7 @@ bool WebEntityItem::setSubClassProperties(const EntityItemProperties& properties
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(inputMode, setInputMode);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(inputMode, setInputMode);
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(showKeyboardFocusHighlight, setShowKeyboardFocusHighlight);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(showKeyboardFocusHighlight, setShowKeyboardFocusHighlight);
|
||||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(useBackground, setUseBackground);
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(useBackground, setUseBackground);
|
||||||
|
SET_ENTITY_PROPERTY_FROM_PROPERTIES(userAgent, setUserAgent);
|
||||||
|
|
||||||
return somethingChanged;
|
return somethingChanged;
|
||||||
}
|
}
|
||||||
|
@ -115,6 +118,7 @@ int WebEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, i
|
||||||
READ_ENTITY_PROPERTY(PROP_INPUT_MODE, WebInputMode, setInputMode);
|
READ_ENTITY_PROPERTY(PROP_INPUT_MODE, WebInputMode, setInputMode);
|
||||||
READ_ENTITY_PROPERTY(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, bool, setShowKeyboardFocusHighlight);
|
READ_ENTITY_PROPERTY(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, bool, setShowKeyboardFocusHighlight);
|
||||||
READ_ENTITY_PROPERTY(PROP_WEB_USE_BACKGROUND, bool, setUseBackground);
|
READ_ENTITY_PROPERTY(PROP_WEB_USE_BACKGROUND, bool, setUseBackground);
|
||||||
|
READ_ENTITY_PROPERTY(PROP_USER_AGENT, QString, setUserAgent);
|
||||||
|
|
||||||
return bytesRead;
|
return bytesRead;
|
||||||
}
|
}
|
||||||
|
@ -133,6 +137,7 @@ EntityPropertyFlags WebEntityItem::getEntityProperties(EncodeBitstreamParams& pa
|
||||||
requestedProperties += PROP_INPUT_MODE;
|
requestedProperties += PROP_INPUT_MODE;
|
||||||
requestedProperties += PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT;
|
requestedProperties += PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT;
|
||||||
requestedProperties += PROP_WEB_USE_BACKGROUND;
|
requestedProperties += PROP_WEB_USE_BACKGROUND;
|
||||||
|
requestedProperties += PROP_USER_AGENT;
|
||||||
return requestedProperties;
|
return requestedProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,6 +165,7 @@ void WebEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitst
|
||||||
APPEND_ENTITY_PROPERTY(PROP_INPUT_MODE, (uint32_t)getInputMode());
|
APPEND_ENTITY_PROPERTY(PROP_INPUT_MODE, (uint32_t)getInputMode());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, getShowKeyboardFocusHighlight());
|
APPEND_ENTITY_PROPERTY(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, getShowKeyboardFocusHighlight());
|
||||||
APPEND_ENTITY_PROPERTY(PROP_WEB_USE_BACKGROUND, getUseBackground());
|
APPEND_ENTITY_PROPERTY(PROP_WEB_USE_BACKGROUND, getUseBackground());
|
||||||
|
APPEND_ENTITY_PROPERTY(PROP_USER_AGENT, getUserAgent());
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec3 WebEntityItem::getRaycastDimensions() const {
|
glm::vec3 WebEntityItem::getRaycastDimensions() const {
|
||||||
|
@ -365,6 +371,17 @@ bool WebEntityItem::getUseBackground() const {
|
||||||
return resultWithReadLock<bool>([&] { return _useBackground; });
|
return resultWithReadLock<bool>([&] { return _useBackground; });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebEntityItem::setUserAgent(const QString& value) {
|
||||||
|
withWriteLock([&] {
|
||||||
|
_needsRenderUpdate |= _userAgent != value;
|
||||||
|
_userAgent = value;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
QString WebEntityItem::getUserAgent() const {
|
||||||
|
return resultWithReadLock<QString>([&] { return _userAgent; });
|
||||||
|
}
|
||||||
|
|
||||||
PulsePropertyGroup WebEntityItem::getPulseProperties() const {
|
PulsePropertyGroup WebEntityItem::getPulseProperties() const {
|
||||||
return resultWithReadLock<PulsePropertyGroup>([&] {
|
return resultWithReadLock<PulsePropertyGroup>([&] {
|
||||||
return _pulseProperties;
|
return _pulseProperties;
|
||||||
|
|
|
@ -89,6 +89,10 @@ public:
|
||||||
|
|
||||||
bool getUseBackground() const;
|
bool getUseBackground() const;
|
||||||
void setUseBackground(bool value);
|
void setUseBackground(bool value);
|
||||||
|
|
||||||
|
static const QString DEFAULT_USER_AGENT;
|
||||||
|
QString getUserAgent() const;
|
||||||
|
void setUserAgent(const QString& value);
|
||||||
|
|
||||||
PulsePropertyGroup getPulseProperties() const;
|
PulsePropertyGroup getPulseProperties() const;
|
||||||
|
|
||||||
|
@ -105,6 +109,7 @@ protected:
|
||||||
WebInputMode _inputMode;
|
WebInputMode _inputMode;
|
||||||
bool _showKeyboardFocusHighlight;
|
bool _showKeyboardFocusHighlight;
|
||||||
bool _useBackground;
|
bool _useBackground;
|
||||||
|
QString _userAgent;
|
||||||
bool _localSafeContext { false };
|
bool _localSafeContext { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,8 @@ namespace NetworkingConstants {
|
||||||
// You can avoid changing that and still effectively use a connected domain on staging
|
// You can avoid changing that and still effectively use a connected domain on staging
|
||||||
// if you manually generate a personal access token for the domains scope
|
// if you manually generate a personal access token for the domains scope
|
||||||
// at https://staging.highfidelity.com/user/tokens/new?for_domain_server=true
|
// at https://staging.highfidelity.com/user/tokens/new?for_domain_server=true
|
||||||
|
|
||||||
|
const QString WEB_ENGINE_VERSION = "Chrome/69.0.3497.113";
|
||||||
|
|
||||||
// For now we only have one Metaverse server.
|
// For now we only have one Metaverse server.
|
||||||
const QUrl METAVERSE_SERVER_URL_STABLE { "https://metaverse.vircadia.com/live" };
|
const QUrl METAVERSE_SERVER_URL_STABLE { "https://metaverse.vircadia.com/live" };
|
||||||
|
@ -37,15 +39,16 @@ namespace NetworkingConstants {
|
||||||
// Use a custom User-Agent to avoid ModSecurity filtering, e.g. by hosting providers.
|
// Use a custom User-Agent to avoid ModSecurity filtering, e.g. by hosting providers.
|
||||||
const QByteArray VIRCADIA_USER_AGENT = "Mozilla/5.0 (VircadiaInterface)";
|
const QByteArray VIRCADIA_USER_AGENT = "Mozilla/5.0 (VircadiaInterface)";
|
||||||
|
|
||||||
const QString WEB_ENGINE_USER_AGENT = "Chrome/48.0 (VircadiaInterface)";
|
const QString WEB_ENGINE_USER_AGENT = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) " + WEB_ENGINE_VERSION + " Mobile Safari/537.36";
|
||||||
const QString METAVERSE_USER_AGENT = "Chrome/48.0 (VircadiaInterface)";
|
const QString MOBILE_USER_AGENT = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) " + WEB_ENGINE_VERSION + " Mobile Safari/537.36";
|
||||||
const QString MOBILE_USER_AGENT = "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Mobile Safari/537.36";
|
|
||||||
|
|
||||||
const QUrl BUILDS_XML_URL("https://highfidelity.com/builds.xml");
|
|
||||||
const QUrl MASTER_BUILDS_XML_URL("https://highfidelity.com/dev-builds.xml");
|
|
||||||
|
|
||||||
// WebEntity Defaults
|
// WebEntity Defaults
|
||||||
const QString WEB_ENTITY_DEFAULT_SOURCE_URL = "https://vircadia.com/";
|
const QString WEB_ENTITY_DEFAULT_SOURCE_URL = "https://vircadia.com/";
|
||||||
|
const QString WEB_ENTITY_DEFAULT_USER_AGENT = WEB_ENGINE_USER_AGENT;
|
||||||
|
|
||||||
|
// Builds URLs
|
||||||
|
const QUrl BUILDS_XML_URL("https://highfidelity.com/builds.xml");
|
||||||
|
const QUrl MASTER_BUILDS_XML_URL("https://highfidelity.com/dev-builds.xml");
|
||||||
|
|
||||||
const QString DEFAULT_AVATAR_COLLISION_SOUND_URL = "https://hifi-public.s3.amazonaws.com/sounds/Collisions-otherorganic/Body_Hits_Impact.wav";
|
const QString DEFAULT_AVATAR_COLLISION_SOUND_URL = "https://hifi-public.s3.amazonaws.com/sounds/Collisions-otherorganic/Body_Hits_Impact.wav";
|
||||||
|
|
||||||
|
|
|
@ -284,6 +284,7 @@ enum class EntityVersion : PacketVersion {
|
||||||
ModelBlendshapes,
|
ModelBlendshapes,
|
||||||
TransparentWeb,
|
TransparentWeb,
|
||||||
UseOriginalPivot,
|
UseOriginalPivot,
|
||||||
|
UserAgent,
|
||||||
|
|
||||||
// Add new versions above here
|
// Add new versions above here
|
||||||
NUM_PACKET_TYPE,
|
NUM_PACKET_TYPE,
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
//
|
//
|
||||||
// Created by Kunal Gosar on 2017-03-10.
|
// Created by Kunal Gosar on 2017-03-10.
|
||||||
// Copyright 2017 High Fidelity, Inc.
|
// Copyright 2017 High Fidelity, Inc.
|
||||||
|
// Copyright 2021 Vircadia contributors.
|
||||||
//
|
//
|
||||||
// Distributed under the Apache License, Version 2.0.
|
// Distributed under the Apache License, Version 2.0.
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
@ -25,7 +26,7 @@
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
bool isAuthableHighFidelityURL(const QUrl& url) {
|
bool isAuthableMetaverseURL(const QUrl& url) {
|
||||||
auto metaverseServerURL = MetaverseAPI::getCurrentMetaverseServerURL();
|
auto metaverseServerURL = MetaverseAPI::getCurrentMetaverseServerURL();
|
||||||
static QStringList HF_HOSTS = {
|
static QStringList HF_HOSTS = {
|
||||||
metaverseServerURL.toString()
|
metaverseServerURL.toString()
|
||||||
|
@ -70,7 +71,7 @@ void RequestFilters::interceptHFWebEngineRequest(QWebEngineUrlRequestInfo& info,
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if this is a request to a highfidelity URL
|
// check if this is a request to a highfidelity URL
|
||||||
bool isAuthable = isAuthableHighFidelityURL(info.requestUrl());
|
bool isAuthable = isAuthableMetaverseURL(info.requestUrl());
|
||||||
auto accountManager = DependencyManager::get<AccountManager>();
|
auto accountManager = DependencyManager::get<AccountManager>();
|
||||||
if (isAuthable) {
|
if (isAuthable) {
|
||||||
// if we have an access token, add it to the right HTTP header for authorization
|
// if we have an access token, add it to the right HTTP header for authorization
|
||||||
|
@ -82,13 +83,6 @@ void RequestFilters::interceptHFWebEngineRequest(QWebEngineUrlRequestInfo& info,
|
||||||
info.setHttpHeader(OAUTH_AUTHORIZATION_HEADER.toLocal8Bit(), bearerTokenString.toLocal8Bit());
|
info.setHttpHeader(OAUTH_AUTHORIZATION_HEADER.toLocal8Bit(), bearerTokenString.toLocal8Bit());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static const QString USER_AGENT = "User-Agent";
|
|
||||||
const QString tokenStringMobile{ NetworkingConstants::MOBILE_USER_AGENT };
|
|
||||||
const QString tokenStringMetaverse{ NetworkingConstants::METAVERSE_USER_AGENT };
|
|
||||||
const QString tokenStringLimitedCommerce{ "Chrome/48.0 (VircadiaInterface limitedCommerce)" };
|
|
||||||
|
|
||||||
const QString tokenString = !isAuthable ? tokenStringMobile : (accountManager->getLimitedCommerce() ? tokenStringLimitedCommerce : tokenStringMetaverse);
|
|
||||||
info.setHttpHeader(USER_AGENT.toLocal8Bit(), tokenString.toLocal8Bit());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RequestFilters::interceptFileType(QWebEngineUrlRequestInfo& info) {
|
void RequestFilters::interceptFileType(QWebEngineUrlRequestInfo& info) {
|
||||||
|
|
|
@ -619,6 +619,9 @@
|
||||||
"scriptURL": {
|
"scriptURL": {
|
||||||
"tooltip": "The URL of a script to inject into the web page."
|
"tooltip": "The URL of a script to inject into the web page."
|
||||||
},
|
},
|
||||||
|
"userAgent": {
|
||||||
|
"tooltip": "The user agent that the web entity will use when visiting web pages."
|
||||||
|
},
|
||||||
"alignToGrid": {
|
"alignToGrid": {
|
||||||
"tooltip": "Used to align entities to the grid, or floor of the environment.",
|
"tooltip": "Used to align entities to the grid, or floor of the environment.",
|
||||||
"skipJSProperty": true
|
"skipJSProperty": true
|
||||||
|
|
|
@ -805,6 +805,12 @@ const GROUPS = [
|
||||||
type: "string",
|
type: "string",
|
||||||
propertyID: "scriptURL",
|
propertyID: "scriptURL",
|
||||||
placeholder: "URL",
|
placeholder: "URL",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "User Agent",
|
||||||
|
type: "string",
|
||||||
|
propertyID: "userAgent",
|
||||||
|
placeholder: "User Agent",
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue