diff --git a/interface/resources/qml/Web3DSurface.qml b/interface/resources/qml/Web3DSurface.qml index e9c8d119d6..3bee87d669 100644 --- a/interface/resources/qml/Web3DSurface.qml +++ b/interface/resources/qml/Web3DSurface.qml @@ -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); diff --git a/interface/resources/qml/controls/+webengine/FlickableWebViewCore.qml b/interface/resources/qml/controls/+webengine/FlickableWebViewCore.qml index a0585ae053..e7d4f645aa 100644 --- a/interface/resources/qml/controls/+webengine/FlickableWebViewCore.qml +++ b/interface/resources/qml/controls/+webengine/FlickableWebViewCore.qml @@ -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)"; } diff --git a/interface/resources/qml/controls/FlickableWebViewCore.qml b/interface/resources/qml/controls/FlickableWebViewCore.qml index 35f3182f98..3e2e74b3d5 100644 --- a/interface/resources/qml/controls/FlickableWebViewCore.qml +++ b/interface/resources/qml/controls/FlickableWebViewCore.qml @@ -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) diff --git a/interface/resources/qml/controls/WebView.qml b/interface/resources/qml/controls/WebView.qml index b46c8c904d..ebef5f85c5 100644 --- a/interface/resources/qml/controls/WebView.qml +++ b/interface/resources/qml/controls/WebView.qml @@ -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 diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp index 8b41a85cf8..23f506a795 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.cpp @@ -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&, bool&)> WebEntityRenderer::_acquireWebSurfaceOperator = nullptr; std::function&, bool&, std::vector&)> WebEntityRenderer::_releaseWebSurfaceOperator = nullptr; @@ -194,6 +195,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); @@ -231,6 +233,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(); diff --git a/libraries/entities-renderer/src/RenderableWebEntityItem.h b/libraries/entities-renderer/src/RenderableWebEntityItem.h index 63ec722811..7288a380d3 100644 --- a/libraries/entities-renderer/src/RenderableWebEntityItem.h +++ b/libraries/entities-renderer/src/RenderableWebEntityItem.h @@ -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&, bool&)> acquireWebSurfaceOperator) { _acquireWebSurfaceOperator = acquireWebSurfaceOperator; } static void acquireWebSurface(const QString& url, bool htmlContent, QSharedPointer& webSurface, bool& cachedWebSurface) { @@ -97,6 +98,7 @@ private: QString _scriptURL; uint8_t _maxFPS; bool _useBackground; + QString _userAgent; WebInputMode _inputMode; glm::vec3 _contextPosition; diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 5b4b60e599..47871736de 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -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 - true if the web entity should have a background, * false if the web entity's background should be transparent. The webpage must have CSS properties for transparency set * on the background-color 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: 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 * @example Create a Web entity displaying at 1920 x 1080 resolution. * var METERS_TO_INCHES = 39.3701; * 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(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 @@ -2213,6 +2218,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); @@ -2506,6 +2512,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); @@ -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_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); @@ -3339,6 +3347,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) { @@ -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_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) { @@ -4205,6 +4215,7 @@ void EntityItemProperties::markAllChanged() { _inputModeChanged = true; _showKeyboardFocusHighlightChanged = true; _useBackgroundChanged = true; + _userAgentChanged = true; // Polyline _linePointsChanged = true; @@ -4901,6 +4912,9 @@ QList EntityItemProperties::listChangedProperties() { if (useBackgroundChanged()) { out += "useBackground"; } + if (userAgentChanged()) { + out += "userAgent"; + } // Shape if (shapeChanged()) { diff --git a/libraries/entities/src/EntityItemProperties.h b/libraries/entities/src/EntityItemProperties.h index f056187d4f..40c376e0e3 100644 --- a/libraries/entities/src/EntityItemProperties.h +++ b/libraries/entities/src/EntityItemProperties.h @@ -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, ENTITY_ITEM_DEFAULT_EMPTY_VEC3_QVEC); diff --git a/libraries/entities/src/EntityPropertyFlags.h b/libraries/entities/src/EntityPropertyFlags.h index 35c1f9a908..aed0d6c458 100644 --- a/libraries/entities/src/EntityPropertyFlags.h +++ b/libraries/entities/src/EntityPropertyFlags.h @@ -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, diff --git a/libraries/entities/src/WebEntityItem.cpp b/libraries/entities/src/WebEntityItem.cpp index 61a1ed18c5..1e3b932b6a 100644 --- a/libraries/entities/src/WebEntityItem.cpp +++ b/libraries/entities/src/WebEntityItem.cpp @@ -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) { @@ -63,6 +64,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; } @@ -85,6 +87,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; } @@ -115,6 +118,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; } @@ -133,6 +137,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; } @@ -160,6 +165,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()); } glm::vec3 WebEntityItem::getRaycastDimensions() const { @@ -365,6 +371,17 @@ bool WebEntityItem::getUseBackground() const { return resultWithReadLock([&] { return _useBackground; }); } +void WebEntityItem::setUserAgent(const QString& value) { + withWriteLock([&] { + _needsRenderUpdate |= _userAgent != value; + _userAgent = value; + }); +} + +QString WebEntityItem::getUserAgent() const { + return resultWithReadLock([&] { return _userAgent; }); +} + PulsePropertyGroup WebEntityItem::getPulseProperties() const { return resultWithReadLock([&] { return _pulseProperties; diff --git a/libraries/entities/src/WebEntityItem.h b/libraries/entities/src/WebEntityItem.h index 4b39261bfb..f5cbac43cc 100644 --- a/libraries/entities/src/WebEntityItem.h +++ b/libraries/entities/src/WebEntityItem.h @@ -89,6 +89,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; @@ -105,6 +109,7 @@ protected: WebInputMode _inputMode; bool _showKeyboardFocusHighlight; bool _useBackground; + QString _userAgent; bool _localSafeContext { false }; }; diff --git a/libraries/networking/src/NetworkingConstants.h b/libraries/networking/src/NetworkingConstants.h index b64a0845ac..ccdb9ea75c 100644 --- a/libraries/networking/src/NetworkingConstants.h +++ b/libraries/networking/src/NetworkingConstants.h @@ -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"; diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index 5c98cf6fdd..5d105dc38f 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -284,6 +284,7 @@ enum class EntityVersion : PacketVersion { ModelBlendshapes, TransparentWeb, UseOriginalPivot, + UserAgent, // Add new versions above here NUM_PACKET_TYPE, diff --git a/libraries/ui/src/ui/types/RequestFilters.cpp b/libraries/ui/src/ui/types/RequestFilters.cpp index 0eea5230ca..ceac3d00e8 100644 --- a/libraries/ui/src/ui/types/RequestFilters.cpp +++ b/libraries/ui/src/ui/types/RequestFilters.cpp @@ -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(); 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) { diff --git a/scripts/system/create/assets/data/createAppTooltips.json b/scripts/system/create/assets/data/createAppTooltips.json index 7c70a8dea8..a3feabe965 100644 --- a/scripts/system/create/assets/data/createAppTooltips.json +++ b/scripts/system/create/assets/data/createAppTooltips.json @@ -619,6 +619,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 diff --git a/scripts/system/create/entityProperties/html/js/entityProperties.js b/scripts/system/create/entityProperties/html/js/entityProperties.js index 592808bd15..f255f618dc 100644 --- a/scripts/system/create/entityProperties/html/js/entityProperties.js +++ b/scripts/system/create/entityProperties/html/js/entityProperties.js @@ -805,6 +805,12 @@ const GROUPS = [ type: "string", propertyID: "scriptURL", placeholder: "URL", + }, + { + label: "User Agent", + type: "string", + propertyID: "userAgent", + placeholder: "User Agent", } ] },