Description: Add "Ubuntu" to the platform part of the UA string
Author: Chris Coulson <chris.coulson@canonical.com>
Forwarded: not-needed

Index: b/netwerk/protocol/http/nsHttpHandler.cpp
===================================================================
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -236,6 +236,9 @@
       mLegacyAppName("Mozilla"),
       mLegacyAppVersion("5.0"),
       mProduct("Gecko"),
+#ifdef MOZ_UA_VENDOR
+      mVendor(MOZ_UA_VENDOR),
+#endif
       mCompatFirefoxEnabled(false),
       mUserAgentIsDirty(true),
       mAcceptLanguagesIsDirty(true),
@@ -520,6 +523,9 @@
   LOG(("> misc = %s\n", mMisc.get()));
   LOG(("> product = %s\n", mProduct.get()));
   LOG(("> product-sub = %s\n", mProductSub.get()));
+#ifdef MOZ_UA_VENDOR
+  LOG(("> vendor = %s\n", mVendor.get()));
+#endif
   LOG(("> app-name = %s\n", mAppName.get()));
   LOG(("> app-version = %s\n", mAppVersion.get()));
   LOG(("> compat-firefox = %s\n", mCompatFirefox.get()));
@@ -877,7 +883,11 @@
                          mOscpu.Length() + mMisc.Length() + mProduct.Length() +
                          mProductSub.Length() + mAppName.Length() +
                          mAppVersion.Length() + mCompatFirefox.Length() +
-                         mCompatDevice.Length() + mDeviceModelId.Length() + 13);
+                         mCompatDevice.Length() + mDeviceModelId.Length() +
+#ifdef MOZ_UA_VENDOR
+                         mVendor.Length() +
+#endif
+                         15);
 
   // Application portion
   mUserAgent.Assign(mLegacyAppName);
@@ -893,6 +903,10 @@
     mUserAgent.AppendLiteral("; ");
   }
 #endif
+#ifdef MOZ_UA_VENDOR
+  mUserAgent += mVendor;
+  mUserAgent.AppendLiteral("; ");
+#endif
   if (!mCompatDevice.IsEmpty()) {
     mUserAgent += mCompatDevice;
     mUserAgent.AppendLiteral("; ");
Index: b/netwerk/protocol/http/nsHttpHandler.h
===================================================================
--- a/netwerk/protocol/http/nsHttpHandler.h
+++ b/netwerk/protocol/http/nsHttpHandler.h
@@ -514,6 +514,7 @@
   // useragent components
   nsCString mLegacyAppName;
   nsCString mLegacyAppVersion;
+  nsCString mVendor;
   nsCString mPlatform;
   nsCString mOscpu;
   nsCString mMisc;
Index: b/old-configure.in
===================================================================
--- a/old-configure.in
+++ b/old-configure.in
@@ -1969,6 +1969,16 @@
   AC_MSG_RESULT([no])
 fi
 
+# Allow someone to add a vendor component to the default user agent string
+MOZ_ARG_WITH_STRING(ua-vendor,
+[--with-ua-vendor=VENDOR sets MOZ_UA_VENDOR to VENDOR],
+WITH_UA_VENDOR=$withval,
+)
+
+if test -n "$WITH_UA_VENDOR" ; then
+    MOZ_UA_VENDOR="$WITH_UA_VENDOR"
+fi
+
 dnl ========================================================
 dnl Ensure Android SDK and build-tools versions depending on
 dnl mobile target.
@@ -4050,6 +4060,7 @@
 
 AC_SUBST(MOZ_APP_DISPLAYNAME)
 AC_SUBST(MOZ_APP_VENDOR)
+AC_SUBST(MOZ_UA_VENDOR)
 AC_SUBST(MOZ_APP_PROFILE)
 AC_SUBST(MOZ_APP_ID)
 AC_SUBST(MAR_CHANNEL_ID)
Index: b/build/moz.configure/old.configure
===================================================================
--- a/build/moz.configure/old.configure
+++ b/build/moz.configure/old.configure
@@ -262,6 +262,7 @@
     "--with-macbundlename-prefix",
     "--with-system-libevent",
     "--with-system-png",
+    "--with-ua-vendor",
     "--with-user-appdir",
     "--x-includes",
     "--x-libraries",
Index: b/netwerk/protocol/http/moz.build
===================================================================
--- a/netwerk/protocol/http/moz.build
+++ b/netwerk/protocol/http/moz.build
@@ -154,4 +154,7 @@
     elif CONFIG["HOST_MAJOR_VERSION"] >= "15":
         DEFINES["HAS_CONNECTX"] = True
 
+if CONFIG["MOZ_UA_VENDOR"]:
+    DEFINES["MOZ_UA_VENDOR"] = "\"%s\"" % CONFIG["MOZ_UA_VENDOR"]
+
 include("/tools/fuzzing/libfuzzer-config.mozbuild")
