From 84fc500ff22c7bee3103b9e259dced27e165e0e0 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Fri, 14 Feb 2020 10:32:41 +0100 Subject: [Network] Bump http channel default Firefox CompatMode init value. --- netwerk/protocol/http/nsHttpHandler.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'netwerk/protocol/http/nsHttpHandler.cpp') diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index 0f4c94202..2691a2a77 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -199,7 +199,7 @@ nsHttpHandler::nsHttpHandler() , mLegacyAppVersion("5.0") , mProduct("Goanna") , mCompatFirefoxEnabled(false) - , mCompatFirefoxVersion("52.9") + , mCompatFirefoxVersion("68.9") , mUserAgentIsDirty(true) , mAcceptLanguagesIsDirty(true) , mPromptTempRedirect(true) -- cgit v1.2.3 From 92edec6f587ae6b86c9b27947113997972ce0c1a Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Sat, 22 Feb 2020 20:10:23 -0500 Subject: Issue #1053 - Remove android support from netwerk --- netwerk/protocol/http/nsHttpHandler.cpp | 28 +--------------------------- 1 file changed, 1 insertion(+), 27 deletions(-) (limited to 'netwerk/protocol/http/nsHttpHandler.cpp') diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index 2691a2a77..e1b7c9bff 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -127,30 +127,6 @@ NewURI(const nsACString &aSpec, return NS_OK; } -#ifdef ANDROID -static nsCString -GetDeviceModelId() { - // Assumed to be running on the main thread - // We need the device property in either case - nsAutoCString deviceModelId; - nsCOMPtr infoService = do_GetService("@mozilla.org/system-info;1"); - MOZ_ASSERT(infoService, "Could not find a system info service"); - nsAutoString androidDevice; - nsresult rv = infoService->GetPropertyAsAString(NS_LITERAL_STRING("device"), androidDevice); - if (NS_SUCCEEDED(rv)) { - deviceModelId = NS_LossyConvertUTF16toASCII(androidDevice); - } - nsAutoCString deviceString; - rv = Preferences::GetCString(UA_PREF("device_string"), &deviceString); - if (NS_SUCCEEDED(rv)) { - deviceString.Trim(" ", true, true); - deviceString.ReplaceSubstring(NS_LITERAL_CSTRING("%DEVICEID%"), deviceModelId); - return deviceString; - } - return deviceModelId; -} -#endif - //----------------------------------------------------------------------------- // nsHttpHandler //----------------------------------------------------------------------------- @@ -792,9 +768,7 @@ nsHttpHandler::InitUserAgentComponents() #ifndef MOZ_UA_OS_AGNOSTIC // Gather platform. mPlatform.AssignLiteral( -#if defined(ANDROID) - "Android" -#elif defined(XP_WIN) +#if defined(XP_WIN) "Windows" #elif defined(XP_MACOSX) "Macintosh" -- cgit v1.2.3 From d6bcaa649127bc524087452c389f6dcee118cbfb Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Sat, 22 Feb 2020 20:48:32 -0500 Subject: Issue #1053 - Remove android support from netwerk/protocol/http/nsHttpHandler.cpp --- netwerk/protocol/http/nsHttpHandler.cpp | 55 --------------------------------- 1 file changed, 55 deletions(-) (limited to 'netwerk/protocol/http/nsHttpHandler.cpp') diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index e1b7c9bff..32e50712f 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -783,49 +783,6 @@ nsHttpHandler::InitUserAgentComponents() #endif -#ifdef ANDROID - nsCOMPtr infoService = do_GetService("@mozilla.org/system-info;1"); - MOZ_ASSERT(infoService, "Could not find a system info service"); - nsresult rv; - // Add the Android version number to the Fennec platform identifier. -#if defined MOZ_WIDGET_ANDROID -#ifndef MOZ_UA_OS_AGNOSTIC // Don't add anything to mPlatform since it's empty. - nsAutoString androidVersion; - rv = infoService->GetPropertyAsAString( - NS_LITERAL_STRING("release_version"), androidVersion); - if (NS_SUCCEEDED(rv)) { - mPlatform += " "; - // If the 2nd character is a ".", we know the major version is a single - // digit. If we're running on a version below 4 we pretend to be on - // Android KitKat (4.4) to work around scripts sniffing for low versions. - if (androidVersion[1] == 46 && androidVersion[0] < 52) { - mPlatform += "4.4"; - } else { - mPlatform += NS_LossyConvertUTF16toASCII(androidVersion); - } - } -#endif -#endif - // Add the `Mobile` or `Tablet` or `TV` token when running on device. - bool isTablet; - rv = infoService->GetPropertyAsBool(NS_LITERAL_STRING("tablet"), &isTablet); - if (NS_SUCCEEDED(rv) && isTablet) { - mCompatDevice.AssignLiteral("Tablet"); - } else { - bool isTV; - rv = infoService->GetPropertyAsBool(NS_LITERAL_STRING("tv"), &isTV); - if (NS_SUCCEEDED(rv) && isTV) { - mCompatDevice.AssignLiteral("TV"); - } else { - mCompatDevice.AssignLiteral("Mobile"); - } - } - - if (Preferences::GetBool(UA_PREF("use_device"), false)) { - mDeviceModelId = mozilla::net::GetDeviceModelId(); - } -#endif // ANDROID - #ifdef MOZ_MULET { // Add the `Mobile` or `Tablet` or `TV` token when running in the b2g @@ -1005,18 +962,6 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref) mUserAgentIsDirty = true; } -#ifdef ANDROID - // general.useragent.use_device - if (PREF_CHANGED(UA_PREF("use_device"))) { - if (Preferences::GetBool(UA_PREF("use_device"), false)) { - mDeviceModelId = mozilla::net::GetDeviceModelId(); - } else { - mDeviceModelId = EmptyCString(); - } - mUserAgentIsDirty = true; - } -#endif - // // HTTP options // -- cgit v1.2.3 From 02327fa74537330180ad07067a4d5b3c3b0fc71b Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sun, 5 Apr 2020 11:48:09 +0200 Subject: Issue #1505 - Rebuild application version string To respond dynamically to the pref change, the mAppVersion string needs to be rebuilt. Includes some minor improvements for corner cases and removes leftover b2g junk. --- netwerk/protocol/http/nsHttpHandler.cpp | 82 ++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 37 deletions(-) (limited to 'netwerk/protocol/http/nsHttpHandler.cpp') diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index 32e50712f..cb3c7ae04 100644 --- a/netwerk/protocol/http/nsHttpHandler.cpp +++ b/netwerk/protocol/http/nsHttpHandler.cpp @@ -310,28 +310,9 @@ nsHttpHandler::Init() } mAppName.StripChars(R"( ()<>@,;:\"/[]?={})"); } - - nsCString dynamicBuildID; - if (appInfo) { - appInfo->GetPlatformBuildID(dynamicBuildID); - if (dynamicBuildID.Length() > 8 ) - dynamicBuildID.Left(dynamicBuildID, 8); - } - if (mAppVersionIsBuildID) { - // Override BuildID - mAppVersion.AssignLiteral(MOZ_UA_BUILDID); - } else if (appInfo) { - appInfo->GetVersion(mAppVersion); - } else { - // Fall back to platform if appInfo is unavailable - mAppVersion.AssignLiteral(MOZILLA_UAVERSION); - } + BuildAppVersion(); - // If there's no override set, set it to the dynamic BuildID - if (mAppVersion.IsEmpty()) - mAppVersion.Assign(dynamicBuildID); - mSessionStartTime = NowInSeconds(); mHandlerActive = true; @@ -350,8 +331,15 @@ nsHttpHandler::Init() // Goanna slice version mProductSub.AssignLiteral(MOZILLA_UAVERSION); - if (mProductSub.IsEmpty()) - mProductSub.Assign(dynamicBuildID); + if (mProductSub.IsEmpty()) { + nsCString dynamicBuildID; + if (appInfo) { + appInfo->GetPlatformBuildID(dynamicBuildID); + if (dynamicBuildID.Length() > 8 ) + dynamicBuildID.Left(dynamicBuildID, 8); + } + mProductSub.Assign(dynamicBuildID); + } #if DEBUG // dump user agent prefs @@ -657,6 +645,37 @@ nsHttpHandler::GenerateHostPort(const nsCString& host, int32_t port, // nsHttpHandler //----------------------------------------------------------------------------- +void +nsHttpHandler::BuildAppVersion() +{ + nsCOMPtr appInfo = do_GetService("@mozilla.org/xre/app-info;1"); + + nsCString dynamicBuildID; + if (appInfo) { + appInfo->GetPlatformBuildID(dynamicBuildID); + if (dynamicBuildID.Length() > 8 ) + dynamicBuildID.Left(dynamicBuildID, 8); + } + + if (mAppVersionIsBuildID) { + // Override BuildID + mAppVersion.Assign(dynamicBuildID); + } else if (appInfo) { + appInfo->GetVersion(mAppVersion); + } else { + // Fall back to platform if appInfo is unavailable + mAppVersion.AssignLiteral(MOZILLA_UAVERSION); + } + + // If there's still no version set, set it to a fixed BuildID + if (mAppVersion.IsEmpty()) { + mAppVersion.AssignLiteral(MOZ_UA_BUILDID); + } + if (mAppVersion.IsEmpty()) { + mAppVersion.AssignLiteral("20200101"); + } +} + const nsAFlatCString & nsHttpHandler::UserAgent() { @@ -782,21 +801,6 @@ nsHttpHandler::InitUserAgentComponents() ); #endif - -#ifdef MOZ_MULET - { - // Add the `Mobile` or `Tablet` or `TV` token when running in the b2g - // desktop simulator via preference. - nsCString deviceType; - nsresult rv = Preferences::GetCString("devtools.useragent.device_type", &deviceType); - if (NS_SUCCEEDED(rv)) { - mCompatDevice.Assign(deviceType); - } else { - mCompatDevice.AssignLiteral("Mobile"); - } - } -#endif // MOZ_MULET - #ifndef MOZ_UA_OS_AGNOSTIC // Gather OS/CPU. #if defined(XP_WIN) @@ -924,6 +928,10 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref) if (PREF_CHANGED(UA_PREF("appVersionIsBuildID"))) { rv = prefs->GetBoolPref(UA_PREF("appVersionIsBuildID"), &cVar); mAppVersionIsBuildID = (NS_SUCCEEDED(rv) && cVar); + + // Rebuild application version string. + BuildAppVersion(); + mUserAgentIsDirty = true; } -- cgit v1.2.3 From 747632bd64adc5f400abe7d5f0da02573560a264 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sun, 5 Apr 2020 16:38:22 +0200 Subject: Issue #1505 - Part 2: Store application build ID in nsHttpHandler Since we're needing to reuse this several times, it makes it simpler to just get it once in init and storing it. --- netwerk/protocol/http/nsHttpHandler.cpp | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'netwerk/protocol/http/nsHttpHandler.cpp') diff --git a/netwerk/protocol/http/nsHttpHandler.cpp b/netwerk/protocol/http/nsHttpHandler.cpp index cb3c7ae04..36f50a57f 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") + , mAppBuildID("20200101") , mCompatFirefoxEnabled(false) , mCompatFirefoxVersion("68.9") , mUserAgentIsDirty(true) @@ -301,6 +302,14 @@ nsHttpHandler::Init() nsCOMPtr appInfo = do_GetService("@mozilla.org/xre/app-info;1"); + nsCString dynamicBuildID; + if (appInfo) { + appInfo->GetPlatformBuildID(dynamicBuildID); + if (dynamicBuildID.Length() > 8 ) + dynamicBuildID.Left(dynamicBuildID, 8); + } + mAppBuildID.Assign(dynamicBuildID); + mAppName.AssignLiteral(MOZ_APP_UA_NAME); if (mAppName.Length() == 0 && appInfo) { // Try to get the UA name from appInfo, falling back to the name @@ -332,13 +341,7 @@ nsHttpHandler::Init() mProductSub.AssignLiteral(MOZILLA_UAVERSION); if (mProductSub.IsEmpty()) { - nsCString dynamicBuildID; - if (appInfo) { - appInfo->GetPlatformBuildID(dynamicBuildID); - if (dynamicBuildID.Length() > 8 ) - dynamicBuildID.Left(dynamicBuildID, 8); - } - mProductSub.Assign(dynamicBuildID); + mProductSub.Assign(mAppBuildID); } #if DEBUG @@ -650,16 +653,9 @@ nsHttpHandler::BuildAppVersion() { nsCOMPtr appInfo = do_GetService("@mozilla.org/xre/app-info;1"); - nsCString dynamicBuildID; - if (appInfo) { - appInfo->GetPlatformBuildID(dynamicBuildID); - if (dynamicBuildID.Length() > 8 ) - dynamicBuildID.Left(dynamicBuildID, 8); - } - if (mAppVersionIsBuildID) { - // Override BuildID - mAppVersion.Assign(dynamicBuildID); + // Override with BuildID + mAppVersion.Assign(mAppBuildID); } else if (appInfo) { appInfo->GetVersion(mAppVersion); } else { -- cgit v1.2.3 From 1b8788aecbfd130a71757c7a99fc432b88f94026 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/protocol/http/nsHttpHandler.cpp') 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