~mozillateam/firefox/firefox.disco

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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 @@
     MOZ_APP_BASENAME="$WITH_APP_BASENAME"
 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
+
 # Special cases where we need to AC_DEFINE something. Also a holdover for apps
 # that haven't made a confvars.sh yet. Don't add new stuff here, use
 # MOZ_BUILD_APP.
@@ -4050,6 +4060,7 @@
 AC_SUBST(MOZ_APP_DISPLAYNAME)
 AC_SUBST(MOZ_APP_BASENAME)
 AC_SUBST(MOZ_APP_VENDOR)
+AC_SUBST(MOZ_UA_VENDOR)
 AC_SUBST(MOZ_APP_PROFILE)
 AC_SUBST(MOZ_APP_ID)
 AC_SUBST(MOZ_APP_ANDROID_VERSION_CODE)
Index: b/build/moz.configure/old.configure
===================================================================
--- a/build/moz.configure/old.configure
+++ b/build/moz.configure/old.configure
@@ -262,6 +262,7 @@
     '--with-system-nss',
     '--with-system-png',
     '--with-system-zlib',
+    '--with-ua-vendor',
     '--with-unify-dist',
     '--with-user-appdir',
     '--x-includes',
Index: b/netwerk/protocol/http/moz.build
===================================================================
--- a/netwerk/protocol/http/moz.build
+++ b/netwerk/protocol/http/moz.build
@@ -154,4 +154,7 @@
             HAS_CONNECTX=True,
         )
 
+if CONFIG['MOZ_UA_VENDOR']:
+    DEFINES['MOZ_UA_VENDOR'] = '"%s"' % CONFIG['MOZ_UA_VENDOR']
+
 include('/tools/fuzzing/libfuzzer-config.mozbuild')