Rebuild application version string.
This commit is contained in:
parent
c10072173e
commit
e65de81e03
|
@ -334,28 +334,9 @@ nsHttpHandler::Init()
|
||||||
}
|
}
|
||||||
mAppName.StripChars(R"( ()<>@,;:\"/[]?={})");
|
mAppName.StripChars(R"( ()<>@,;:\"/[]?={})");
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCString dynamicBuildID;
|
|
||||||
if (appInfo) {
|
|
||||||
appInfo->GetPlatformBuildID(dynamicBuildID);
|
|
||||||
if (dynamicBuildID.Length() > 8 )
|
|
||||||
dynamicBuildID.Left(dynamicBuildID, 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mAppVersionIsBuildID) {
|
BuildAppVersion();
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If there's no override set, set it to the dynamic BuildID
|
|
||||||
if (mAppVersion.IsEmpty())
|
|
||||||
mAppVersion.Assign(dynamicBuildID);
|
|
||||||
|
|
||||||
mSessionStartTime = NowInSeconds();
|
mSessionStartTime = NowInSeconds();
|
||||||
mHandlerActive = true;
|
mHandlerActive = true;
|
||||||
|
|
||||||
|
@ -374,8 +355,15 @@ nsHttpHandler::Init()
|
||||||
// Goanna slice version
|
// Goanna slice version
|
||||||
mProductSub.AssignLiteral(MOZILLA_UAVERSION);
|
mProductSub.AssignLiteral(MOZILLA_UAVERSION);
|
||||||
|
|
||||||
if (mProductSub.IsEmpty())
|
if (mProductSub.IsEmpty()) {
|
||||||
mProductSub.Assign(dynamicBuildID);
|
nsCString dynamicBuildID;
|
||||||
|
if (appInfo) {
|
||||||
|
appInfo->GetPlatformBuildID(dynamicBuildID);
|
||||||
|
if (dynamicBuildID.Length() > 8 )
|
||||||
|
dynamicBuildID.Left(dynamicBuildID, 8);
|
||||||
|
}
|
||||||
|
mProductSub.Assign(dynamicBuildID);
|
||||||
|
}
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
// dump user agent prefs
|
// dump user agent prefs
|
||||||
|
@ -681,6 +669,37 @@ nsHttpHandler::GenerateHostPort(const nsCString& host, int32_t port,
|
||||||
// nsHttpHandler <private>
|
// nsHttpHandler <private>
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void
|
||||||
|
nsHttpHandler::BuildAppVersion()
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIXULAppInfo> 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 &
|
const nsAFlatCString &
|
||||||
nsHttpHandler::UserAgent()
|
nsHttpHandler::UserAgent()
|
||||||
{
|
{
|
||||||
|
@ -851,21 +870,6 @@ nsHttpHandler::InitUserAgentComponents()
|
||||||
mDeviceModelId = mozilla::net::GetDeviceModelId();
|
mDeviceModelId = mozilla::net::GetDeviceModelId();
|
||||||
}
|
}
|
||||||
#endif // ANDROID
|
#endif // ANDROID
|
||||||
|
|
||||||
#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
|
#ifndef MOZ_UA_OS_AGNOSTIC
|
||||||
// Gather OS/CPU.
|
// Gather OS/CPU.
|
||||||
#if defined(XP_WIN)
|
#if defined(XP_WIN)
|
||||||
|
@ -993,6 +997,10 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref)
|
||||||
if (PREF_CHANGED(UA_PREF("appVersionIsBuildID"))) {
|
if (PREF_CHANGED(UA_PREF("appVersionIsBuildID"))) {
|
||||||
rv = prefs->GetBoolPref(UA_PREF("appVersionIsBuildID"), &cVar);
|
rv = prefs->GetBoolPref(UA_PREF("appVersionIsBuildID"), &cVar);
|
||||||
mAppVersionIsBuildID = (NS_SUCCEEDED(rv) && cVar);
|
mAppVersionIsBuildID = (NS_SUCCEEDED(rv) && cVar);
|
||||||
|
|
||||||
|
// Rebuild application version string.
|
||||||
|
BuildAppVersion();
|
||||||
|
|
||||||
mUserAgentIsDirty = true;
|
mUserAgentIsDirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -391,6 +391,7 @@ private:
|
||||||
//
|
//
|
||||||
// Useragent/prefs helper methods
|
// Useragent/prefs helper methods
|
||||||
//
|
//
|
||||||
|
void BuildAppVersion();
|
||||||
void BuildUserAgent();
|
void BuildUserAgent();
|
||||||
void InitUserAgentComponents();
|
void InitUserAgentComponents();
|
||||||
void PrefsChanged(nsIPrefBranch *prefs, const char *pref);
|
void PrefsChanged(nsIPrefBranch *prefs, const char *pref);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user