mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-04-07 10:02:24 +02:00
Merge branch 'master' into billboard
This commit is contained in:
commit
0645866549
16 changed files with 101 additions and 31 deletions
|
@ -19,16 +19,17 @@ Item {
|
|||
property string url: ""
|
||||
property string scriptUrl: null
|
||||
property bool useBackground: true
|
||||
property string userAgent: ""
|
||||
|
||||
onUrlChanged: {
|
||||
load(root.url, root.scriptUrl, root.useBackground);
|
||||
load(root.url, root.scriptUrl, root.useBackground, root.userAgent);
|
||||
}
|
||||
|
||||
onScriptUrlChanged: {
|
||||
if (root.item) {
|
||||
root.item.scriptUrl = root.scriptUrl;
|
||||
} 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) {
|
||||
root.item.useBackground = root.useBackground;
|
||||
} 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
|
||||
|
||||
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
|
||||
if (root.item != null) {
|
||||
root.item.url = "about:blank"
|
||||
|
@ -54,11 +63,12 @@ Item {
|
|||
root.item.url = url
|
||||
root.item.scriptUrl = scriptUrl
|
||||
root.item.useBackground = useBackground
|
||||
root.item.userAgent = userAgent
|
||||
})
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
load(root.url, root.scriptUrl, root.useBackground);
|
||||
load(root.url, root.scriptUrl, root.useBackground, root.userAgent);
|
||||
}
|
||||
|
||||
signal sendToScript(var message);
|
||||
|
|
|
@ -13,10 +13,10 @@ Item {
|
|||
property alias url: webViewCore.url
|
||||
property alias canGoBack: webViewCore.canGoBack
|
||||
property alias webViewCore: webViewCore
|
||||
property alias webViewCoreProfile: webViewCore.profile
|
||||
property string webViewCoreUserAgent
|
||||
|
||||
property bool useBackground: webViewCore.useBackground
|
||||
property string userAgent: webViewCore.profile.httpUserAgent
|
||||
property string userScriptUrl: ""
|
||||
property string urlTag: "noDownload=false";
|
||||
|
||||
|
@ -34,6 +34,10 @@ Item {
|
|||
permissionPopupBackground.visible = false;
|
||||
}
|
||||
|
||||
onUserAgentChanged: {
|
||||
webViewCore.profile.httpUserAgent = flick.userAgent;
|
||||
}
|
||||
|
||||
StylesUIt.HifiConstants {
|
||||
id: hifi
|
||||
}
|
||||
|
@ -74,7 +78,7 @@ Item {
|
|||
|
||||
function onLoadingChanged(loadRequest) {
|
||||
if (WebEngineView.LoadStartedStatus === loadRequest.status) {
|
||||
|
||||
webViewCore.profile.httpUserAgent = flick.userAgent;
|
||||
// Required to support clicking on "hifi://" links
|
||||
var url = loadRequest.url.toString();
|
||||
url = (url.indexOf("?") >= 0) ? url + urlTag : url + "?" + urlTag;
|
||||
|
@ -101,7 +105,6 @@ Item {
|
|||
height: parent.height
|
||||
backgroundColor: (flick.useBackground) ? "white" : "transparent"
|
||||
|
||||
profile: HFWebEngineProfile;
|
||||
settings.pluginsEnabled: true
|
||||
settings.touchIconsEnabled: true
|
||||
settings.allowRunningInsecureContent: true
|
||||
|
@ -136,8 +139,10 @@ Item {
|
|||
webChannel.registerObject("eventBridge", eventBridge);
|
||||
webChannel.registerObject("eventBridgeWrapper", eventBridgeWrapper);
|
||||
|
||||
if (webViewCoreUserAgent !== undefined) {
|
||||
webViewCore.profile.httpUserAgent = webViewCoreUserAgent
|
||||
if (flick.userAgent !== undefined) {
|
||||
webViewCore.profile.httpUserAgent = flick.userAgent;
|
||||
webViewCore.profile.offTheRecord = false;
|
||||
webViewCore.profile.storageName = "qmlWebEngine";
|
||||
} else {
|
||||
webViewCore.profile.httpUserAgent += " (VircadiaInterface)";
|
||||
}
|
||||
|
|
|
@ -11,12 +11,11 @@ Item {
|
|||
property alias url: webViewCore.url
|
||||
property alias canGoBack: webViewCore.canGoBack
|
||||
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 urlTag: "noDownload=false";
|
||||
property string urlTag: "noDownload=false"
|
||||
|
||||
signal newViewRequestedCallback(var request)
|
||||
signal loadingChangedCallback(var loadRequest)
|
||||
|
|
|
@ -24,6 +24,7 @@ Item {
|
|||
property alias flickable: webroot.interactive
|
||||
property alias blurOnCtrlShift: webroot.blurOnCtrlShift
|
||||
property alias useBackground: webroot.useBackground
|
||||
property alias userAgent: webroot.userAgent
|
||||
|
||||
function stop() {
|
||||
webroot.stop();
|
||||
|
@ -37,8 +38,6 @@ Item {
|
|||
}
|
||||
*/
|
||||
|
||||
property alias viewProfile: webroot.webViewCoreProfile
|
||||
|
||||
FlickableWebViewCore {
|
||||
id: webroot
|
||||
width: parent.width
|
||||
|
|
|
@ -39,6 +39,7 @@ const char* WebEntityRenderer::URL_PROPERTY = "url";
|
|||
const char* WebEntityRenderer::SCRIPT_URL_PROPERTY = "scriptURL";
|
||||
const char* WebEntityRenderer::GLOBAL_POSITION_PROPERTY = "globalPosition";
|
||||
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(QSharedPointer<OffscreenQmlSurface>&, bool&, std::vector<QMetaObject::Connection>&)> WebEntityRenderer::_releaseWebSurfaceOperator = nullptr;
|
||||
|
@ -193,6 +194,7 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene
|
|||
_webSurface->getRootItem()->setProperty(URL_PROPERTY, newSourceURL);
|
||||
_webSurface->getRootItem()->setProperty(SCRIPT_URL_PROPERTY, _scriptURL);
|
||||
_webSurface->getRootItem()->setProperty(USE_BACKGROUND_PROPERTY, _useBackground);
|
||||
_webSurface->getRootItem()->setProperty(USER_AGENT_PROPERTY, _userAgent);
|
||||
_webSurface->getSurfaceContext()->setContextProperty(GLOBAL_POSITION_PROPERTY, vec3toVariant(_contextPosition));
|
||||
_webSurface->setMaxFps((QUrl(newSourceURL).host().endsWith("youtube.com", Qt::CaseInsensitive)) ? YOUTUBE_MAX_FPS : _maxFPS);
|
||||
::hifi::scripting::setLocalAccessSafeThread(false);
|
||||
|
@ -230,6 +232,14 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene
|
|||
_useBackground = useBackground;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto userAgent = entity->getUserAgent();
|
||||
if (_userAgent != userAgent) {
|
||||
_webSurface->getRootItem()->setProperty(USER_AGENT_PROPERTY, userAgent);
|
||||
_userAgent = userAgent;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
auto contextPosition = entity->getWorldPosition();
|
||||
|
|
|
@ -36,6 +36,7 @@ public:
|
|||
static const char* SCRIPT_URL_PROPERTY;
|
||||
static const char* GLOBAL_POSITION_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 acquireWebSurface(const QString& url, bool htmlContent, QSharedPointer<OffscreenQmlSurface>& webSurface, bool& cachedWebSurface) {
|
||||
|
@ -95,6 +96,7 @@ private:
|
|||
QString _scriptURL;
|
||||
uint8_t _maxFPS;
|
||||
bool _useBackground;
|
||||
QString _userAgent;
|
||||
WebInputMode _inputMode;
|
||||
|
||||
glm::vec3 _contextPosition;
|
||||
|
|
|
@ -604,6 +604,7 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
|||
CHECK_PROPERTY_CHANGE(PROP_INPUT_MODE, inputMode);
|
||||
CHECK_PROPERTY_CHANGE(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, showKeyboardFocusHighlight);
|
||||
CHECK_PROPERTY_CHANGE(PROP_WEB_USE_BACKGROUND, useBackground);
|
||||
CHECK_PROPERTY_CHANGE(PROP_USER_AGENT, userAgent);
|
||||
|
||||
// Polyline
|
||||
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,
|
||||
* <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.
|
||||
* @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>
|
||||
* var METERS_TO_INCHES = 39.3701;
|
||||
* var entity = Entities.addEntity({
|
||||
|
@ -1828,6 +1832,7 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool
|
|||
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_WEB_USE_BACKGROUND, useBackground);
|
||||
COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_USER_AGENT, userAgent);
|
||||
}
|
||||
|
||||
// PolyVoxel only
|
||||
|
@ -2210,6 +2215,7 @@ void EntityItemProperties::copyFromScriptValue(const QScriptValue& object, bool
|
|||
COPY_PROPERTY_FROM_QSCRIPTVALUE_ENUM(inputMode, InputMode);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(showKeyboardFocusHighlight, bool, setShowKeyboardFocusHighlight);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(useBackground, bool, setUseBackground);
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(userAgent, QString, setUserAgent);
|
||||
|
||||
// Polyline
|
||||
COPY_PROPERTY_FROM_QSCRIPTVALUE(linePoints, qVectorVec3, setLinePoints);
|
||||
|
@ -2503,6 +2509,7 @@ void EntityItemProperties::merge(const EntityItemProperties& other) {
|
|||
COPY_PROPERTY_IF_CHANGED(inputMode);
|
||||
COPY_PROPERTY_IF_CHANGED(showKeyboardFocusHighlight);
|
||||
COPY_PROPERTY_IF_CHANGED(useBackground);
|
||||
COPY_PROPERTY_IF_CHANGED(userAgent);
|
||||
|
||||
// Polyline
|
||||
COPY_PROPERTY_IF_CHANGED(linePoints);
|
||||
|
@ -2904,6 +2911,7 @@ bool EntityItemProperties::getPropertyInfo(const QString& propertyName, EntityPr
|
|||
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_WEB_USE_BACKGROUND, useBackground, useBackground, bool);
|
||||
ADD_PROPERTY_TO_MAP(PROP_USER_AGENT, UserAgent, userAgent, QString);
|
||||
|
||||
// Polyline
|
||||
ADD_PROPERTY_TO_MAP(PROP_LINE_POINTS, LinePoints, linePoints, QVector<vec3>);
|
||||
|
@ -3335,6 +3343,7 @@ OctreeElement::AppendState EntityItemProperties::encodeEntityEditPacket(PacketTy
|
|||
APPEND_ENTITY_PROPERTY(PROP_INPUT_MODE, (uint32_t)properties.getInputMode());
|
||||
APPEND_ENTITY_PROPERTY(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, properties.getShowKeyboardFocusHighlight());
|
||||
APPEND_ENTITY_PROPERTY(PROP_WEB_USE_BACKGROUND, properties.getUseBackground());
|
||||
APPEND_ENTITY_PROPERTY(PROP_USER_AGENT, properties.getUserAgent());
|
||||
}
|
||||
|
||||
if (properties.getType() == EntityTypes::Line) {
|
||||
|
@ -3810,6 +3819,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_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, bool, setShowKeyboardFocusHighlight);
|
||||
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) {
|
||||
|
@ -4198,6 +4208,7 @@ void EntityItemProperties::markAllChanged() {
|
|||
_inputModeChanged = true;
|
||||
_showKeyboardFocusHighlightChanged = true;
|
||||
_useBackgroundChanged = true;
|
||||
_userAgentChanged = true;
|
||||
|
||||
// Polyline
|
||||
_linePointsChanged = true;
|
||||
|
@ -4894,6 +4905,9 @@ QList<QString> EntityItemProperties::listChangedProperties() {
|
|||
if (useBackgroundChanged()) {
|
||||
out += "useBackground";
|
||||
}
|
||||
if (userAgentChanged()) {
|
||||
out += "userAgent";
|
||||
}
|
||||
|
||||
// Shape
|
||||
if (shapeChanged()) {
|
||||
|
|
|
@ -368,6 +368,7 @@ public:
|
|||
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_WEB_USE_BACKGROUND, UseBackground, useBackground, bool, true);
|
||||
DEFINE_PROPERTY_REF(PROP_USER_AGENT, UserAgent, userAgent, QString, WebEntityItem::DEFAULT_USER_AGENT);
|
||||
|
||||
// Polyline
|
||||
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_SHOW_KEYBOARD_FOCUS_HIGHLIGHT = PROP_DERIVED_5,
|
||||
PROP_WEB_USE_BACKGROUND = PROP_DERIVED_6,
|
||||
PROP_USER_AGENT = PROP_DERIVED_7,
|
||||
|
||||
// Polyline
|
||||
PROP_LINE_POINTS = PROP_DERIVED_0,
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "EntityTreeElement.h"
|
||||
|
||||
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;
|
||||
|
||||
EntityItemPointer WebEntityItem::factory(const EntityItemID& entityID, const EntityItemProperties& properties) {
|
||||
|
@ -62,6 +63,7 @@ EntityItemProperties WebEntityItem::getProperties(const EntityPropertyFlags& des
|
|||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(inputMode, getInputMode);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(showKeyboardFocusHighlight, getShowKeyboardFocusHighlight);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(useBackground, getUseBackground);
|
||||
COPY_ENTITY_PROPERTY_TO_PROPERTIES(userAgent, getUserAgent);
|
||||
return properties;
|
||||
}
|
||||
|
||||
|
@ -83,6 +85,7 @@ bool WebEntityItem::setSubClassProperties(const EntityItemProperties& properties
|
|||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(inputMode, setInputMode);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(showKeyboardFocusHighlight, setShowKeyboardFocusHighlight);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(useBackground, setUseBackground);
|
||||
SET_ENTITY_PROPERTY_FROM_PROPERTIES(userAgent, setUserAgent);
|
||||
|
||||
return somethingChanged;
|
||||
}
|
||||
|
@ -112,6 +115,7 @@ int WebEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data, i
|
|||
READ_ENTITY_PROPERTY(PROP_INPUT_MODE, WebInputMode, setInputMode);
|
||||
READ_ENTITY_PROPERTY(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, bool, setShowKeyboardFocusHighlight);
|
||||
READ_ENTITY_PROPERTY(PROP_WEB_USE_BACKGROUND, bool, setUseBackground);
|
||||
READ_ENTITY_PROPERTY(PROP_USER_AGENT, QString, setUserAgent);
|
||||
|
||||
return bytesRead;
|
||||
}
|
||||
|
@ -129,6 +133,7 @@ EntityPropertyFlags WebEntityItem::getEntityProperties(EncodeBitstreamParams& pa
|
|||
requestedProperties += PROP_INPUT_MODE;
|
||||
requestedProperties += PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT;
|
||||
requestedProperties += PROP_WEB_USE_BACKGROUND;
|
||||
requestedProperties += PROP_USER_AGENT;
|
||||
return requestedProperties;
|
||||
}
|
||||
|
||||
|
@ -155,6 +160,7 @@ void WebEntityItem::appendSubclassData(OctreePacketData* packetData, EncodeBitst
|
|||
APPEND_ENTITY_PROPERTY(PROP_INPUT_MODE, (uint32_t)getInputMode());
|
||||
APPEND_ENTITY_PROPERTY(PROP_SHOW_KEYBOARD_FOCUS_HIGHLIGHT, getShowKeyboardFocusHighlight());
|
||||
APPEND_ENTITY_PROPERTY(PROP_WEB_USE_BACKGROUND, getUseBackground());
|
||||
APPEND_ENTITY_PROPERTY(PROP_USER_AGENT, getUserAgent());
|
||||
}
|
||||
|
||||
void WebEntityItem::setColor(const glm::u8vec3& value) {
|
||||
|
@ -282,6 +288,17 @@ bool WebEntityItem::getUseBackground() const {
|
|||
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 {
|
||||
return resultWithReadLock<PulsePropertyGroup>([&] {
|
||||
return _pulseProperties;
|
||||
|
|
|
@ -75,6 +75,10 @@ public:
|
|||
|
||||
bool getUseBackground() const;
|
||||
void setUseBackground(bool value);
|
||||
|
||||
static const QString DEFAULT_USER_AGENT;
|
||||
QString getUserAgent() const;
|
||||
void setUserAgent(const QString& value);
|
||||
|
||||
PulsePropertyGroup getPulseProperties() const;
|
||||
|
||||
|
@ -90,6 +94,7 @@ protected:
|
|||
WebInputMode _inputMode;
|
||||
bool _showKeyboardFocusHighlight;
|
||||
bool _useBackground;
|
||||
QString _userAgent;
|
||||
bool _localSafeContext { false };
|
||||
};
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@ namespace NetworkingConstants {
|
|||
// 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
|
||||
// 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.
|
||||
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.
|
||||
const QByteArray VIRCADIA_USER_AGENT = "Mozilla/5.0 (VircadiaInterface)";
|
||||
|
||||
const QString WEB_ENGINE_USER_AGENT = "Chrome/48.0 (VircadiaInterface)";
|
||||
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) 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");
|
||||
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 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";
|
||||
|
||||
// WebEntity Defaults
|
||||
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";
|
||||
|
||||
|
|
|
@ -284,6 +284,7 @@ enum class EntityVersion : PacketVersion {
|
|||
ModelBlendshapes,
|
||||
TransparentWeb,
|
||||
UseOriginalPivot,
|
||||
UserAgent,
|
||||
AllBillboardMode,
|
||||
|
||||
// Add new versions above here
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
//
|
||||
// Created by Kunal Gosar on 2017-03-10.
|
||||
// Copyright 2017 High Fidelity, Inc.
|
||||
// Copyright 2021 Vircadia contributors.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
@ -25,7 +26,7 @@
|
|||
|
||||
namespace {
|
||||
|
||||
bool isAuthableHighFidelityURL(const QUrl& url) {
|
||||
bool isAuthableMetaverseURL(const QUrl& url) {
|
||||
auto metaverseServerURL = MetaverseAPI::getCurrentMetaverseServerURL();
|
||||
static QStringList HF_HOSTS = {
|
||||
metaverseServerURL.toString()
|
||||
|
@ -70,7 +71,7 @@ void RequestFilters::interceptHFWebEngineRequest(QWebEngineUrlRequestInfo& info,
|
|||
}
|
||||
|
||||
// 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>();
|
||||
if (isAuthable) {
|
||||
// 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());
|
||||
}
|
||||
}
|
||||
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) {
|
||||
|
|
|
@ -610,6 +610,9 @@
|
|||
"scriptURL": {
|
||||
"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": {
|
||||
"tooltip": "Used to align entities to the grid, or floor of the environment.",
|
||||
"skipJSProperty": true
|
||||
|
|
|
@ -794,6 +794,12 @@ const GROUPS = [
|
|||
type: "string",
|
||||
propertyID: "scriptURL",
|
||||
placeholder: "URL",
|
||||
},
|
||||
{
|
||||
label: "User Agent",
|
||||
type: "string",
|
||||
propertyID: "userAgent",
|
||||
placeholder: "User Agent",
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue