From d9f17c9f8b973c4fd4799f2370e620cadae82910 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sun, 5 Apr 2020 16:40:21 +0200 Subject: Issue #1505 - Part 3: Make native mode actually native again. --- netwerk/protocol/http/nsHttpHandler.cpp | 40 +++++++++++++++++++++++++++++---- 1 file changed, 36 insertions(+), 4 deletions(-) (limited to 'netwerk') diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index 36f50a57f..7a29e041b 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -174,6 +174,7 @@ nsHttpHandler::nsHttpHandler() , mLegacyAppName("Mozilla") , mLegacyAppVersion("5.0") , mProduct("Goanna") + , mCompatGeckoEnabled(false) , mAppBuildID("20200101") , mCompatFirefoxEnabled(false) , mCompatFirefoxVersion("68.9") @@ -292,8 +293,13 @@ nsHttpHandler::Init() nsHttpChannelAuthProvider::InitializePrefs(); // rv: should have the Firefox/Gecko compatversion for web compatibility + // when in either compatmodes mMisc.AssignLiteral("rv:"); - mMisc += mCompatFirefoxVersion; + if (mCompatGeckoEnabled) { + mMisc += mCompatFirefoxVersion; + } else { + mMisc += MOZILLA_UAVERSION; + } mCompatGecko.AssignLiteral("Gecko/20100101"); mCompatFirefox.AssignLiteral("Firefox/"); @@ -338,8 +344,12 @@ nsHttpHandler::Init() do_GetService("@mozilla.org/network/request-context-service;1"); // Goanna slice version - mProductSub.AssignLiteral(MOZILLA_UAVERSION); - + if (mCompatGeckoEnabled) { + mProductSub.AssignLiteral(MOZILLA_UAVERSION); + } else { + mProductSub.Assign(mAppBuildID); + } + // In case MOZILLA_UAVERSION is empty for some odd reason... if (mProductSub.IsEmpty()) { mProductSub.Assign(mAppBuildID); } @@ -934,6 +944,24 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref) if (PREF_CHANGED(UA_PREF("compatMode.gecko"))) { rv = prefs->GetBoolPref(UA_PREF("compatMode.gecko"), &cVar); mCompatGeckoEnabled = (NS_SUCCEEDED(rv) && cVar); + + // Rebuild rv: and Goanna slice version + mMisc.AssignLiteral("rv:"); + if (mCompatGeckoEnabled) { + mMisc += mCompatFirefoxVersion; + } else { + mMisc += MOZILLA_UAVERSION; + } + + if (mCompatGeckoEnabled) { + mProductSub.AssignLiteral(MOZILLA_UAVERSION); + } else { + mProductSub.Assign(mAppBuildID); + } + // In case MOZILLA_UAVERSION is empty for some odd reason... + if (mProductSub.IsEmpty()) { + mProductSub.Assign(mAppBuildID); + } mUserAgentIsDirty = true; } @@ -952,7 +980,11 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref) // rebuild mMisc and compatMode slice mMisc.AssignLiteral("rv:"); - mMisc += mCompatFirefoxVersion; + if (mCompatGeckoEnabled) { + mMisc += mCompatFirefoxVersion; + } else { + mMisc += MOZILLA_UAVERSION; + } mCompatFirefox.AssignLiteral("Firefox/"); mCompatFirefox += mCompatFirefoxVersion; -- cgit v1.2.3