diff --git a/mozilla/browser/app/Makefile.in b/mozilla/browser/app/Makefile.in index f73d817497b..4a517076bee 100644 --- a/mozilla/browser/app/Makefile.in +++ b/mozilla/browser/app/Makefile.in @@ -168,7 +168,7 @@ include $(topsrcdir)/config/static-rules.mk endif APP_VERSION = $(shell cat $(srcdir)/../config/version.txt) -DEFINES += -DAPP_VERSION=\"$(APP_VERSION)\" +DEFINES += -DAPP_VERSION="$(APP_VERSION)" ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) ifdef BUILD_STATIC_LIBS diff --git a/mozilla/browser/app/nsBrowserApp.cpp b/mozilla/browser/app/nsBrowserApp.cpp index fe2a57937ad..ddae23868bf 100644 --- a/mozilla/browser/app/nsBrowserApp.cpp +++ b/mozilla/browser/app/nsBrowserApp.cpp @@ -46,7 +46,7 @@ static const nsXREAppData kAppData = { "Mozilla", "Firefox", - APP_VERSION, + NS_STRINGIFY(APP_VERSION), NS_STRINGIFY(BUILD_ID), // ec8030f7-c20a-464f-9b0e-13a3a9e97384 { 0xec8030f7, 0xc20a, 0x464f, { 0x9b, 0x0e, 0x13, 0xa3, 0xa9, 0xe9, 0x73, 0x84 } }, diff --git a/mozilla/browser/app/profile/firefox.js b/mozilla/browser/app/profile/firefox.js index 7ac5d57c265..acdefd38813 100644 --- a/mozilla/browser/app/profile/firefox.js +++ b/mozilla/browser/app/profile/firefox.js @@ -129,8 +129,7 @@ pref("keyword.URL", "http://www.google.com/search?btnI=I%27m+Feeling+Lucky&ie=UT pref("general.useragent.locale", "@AB_CD@"); pref("general.skins.selectedSkin", "classic/1.0"); -pref("general.useragent.vendor", "Firefox"); -pref("general.useragent.vendorSub", @APP_VERSION@); +pref("general.useragent.extra.firefox", "Firefox/@APP_VERSION@"); pref("general.smoothScroll", false); #ifdef XP_UNIX diff --git a/mozilla/calendar/sunbird/app/Makefile.in b/mozilla/calendar/sunbird/app/Makefile.in index f6bcef798fa..b7774068daf 100644 --- a/mozilla/calendar/sunbird/app/Makefile.in +++ b/mozilla/calendar/sunbird/app/Makefile.in @@ -168,7 +168,7 @@ include $(topsrcdir)/config/static-rules.mk endif APP_VERSION = $(shell cat $(srcdir)/../config/version.txt) -DEFINES += -DAPP_VERSION=\"$(APP_VERSION)\" +DEFINES += -DAPP_VERSION="$(APP_VERSION)" ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) ifdef BUILD_STATIC_LIBS diff --git a/mozilla/calendar/sunbird/app/nsCalendarApp.cpp b/mozilla/calendar/sunbird/app/nsCalendarApp.cpp index 600733b5c85..534d30d0c94 100644 --- a/mozilla/calendar/sunbird/app/nsCalendarApp.cpp +++ b/mozilla/calendar/sunbird/app/nsCalendarApp.cpp @@ -48,7 +48,7 @@ static const nsXREAppData kAppData = { "Mozilla", "Sunbird", - APP_VERSION, + NS_STRINGIFY(APP_VERSION), NS_STRINGIFY(BUILD_ID), // {718e30fb-e89b-41dd-9da7-e25a45638b28} { 0x718e30fb, 0xe89b, 0x41dd, { 0x9d, 0xa7, 0xe2, 0x5a, 0x45, 0x63, 0x8b, 0x28 } }, diff --git a/mozilla/calendar/sunbird/app/profile/sunbird.js b/mozilla/calendar/sunbird/app/profile/sunbird.js index 7e31aa78160..1b70b70c930 100644 --- a/mozilla/calendar/sunbird/app/profile/sunbird.js +++ b/mozilla/calendar/sunbird/app/profile/sunbird.js @@ -81,10 +81,7 @@ pref("update.extensions.count", 0); pref("general.useragent.locale", "chrome://global/locale/intl.properties"); pref("general.useragent.contentlocale", "chrome://browser-region/locale/region.properties"); -pref("general.useragent.vendor", "Mozilla Sunbird"); -pref("general.useragent.vendorSub", -#expand __APP_VERSION__ -); +#expand pref("general.useragent.extra.sunbird", "Mozilla Sunbird/__APP_VERSION__"); // Scripts & Windows prefs pref("dom.disable_open_during_load", true); diff --git a/mozilla/composer/app/profile/all.js b/mozilla/composer/app/profile/all.js index fe31ccb284a..e96ca40b987 100644 --- a/mozilla/composer/app/profile/all.js +++ b/mozilla/composer/app/profile/all.js @@ -36,8 +36,7 @@ * ***** END LICENSE BLOCK ***** */ pref("general.skins.selectedSkin", "modern/1.0"); -pref("general.useragent.vendor", "Mozilla (standalone) Composer"); -pref("general.useragent.vendorSub", "0.0.1"); +pref("general.useragent.extra.composer", "Mozilla (standalone) Composer/0.0.1"); pref("general.startup.browser", false); pref("general.startup.editor", true); diff --git a/mozilla/mail/app/Makefile.in b/mozilla/mail/app/Makefile.in index a53451ba325..2e8677e1587 100644 --- a/mozilla/mail/app/Makefile.in +++ b/mozilla/mail/app/Makefile.in @@ -91,6 +91,10 @@ ifneq (,$(filter gtk gtk2 xlib,$(MOZ_WIDGET_TOOLKIT))) LIBS += $(XLDFLAGS) $(XLIBS) endif +ifdef MOZ_JPROF +LIBS += -ljprof +endif + ifndef MOZ_WINCONSOLE ifdef MOZ_DEBUG MOZ_WINCONSOLE = 1 @@ -146,7 +150,7 @@ include $(topsrcdir)/config/static-rules.mk endif APP_VERSION = $(shell cat $(srcdir)/../config/version.txt) -DEFINES += -DAPP_VERSION=\"$(APP_VERSION)\" +DEFINES += -DAPP_VERSION="$(APP_VERSION)" ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) ifdef BUILD_STATIC_LIBS diff --git a/mozilla/mail/app/nsMailApp.cpp b/mozilla/mail/app/nsMailApp.cpp index b1d12d4a750..b714f5f1ff1 100644 --- a/mozilla/mail/app/nsMailApp.cpp +++ b/mozilla/mail/app/nsMailApp.cpp @@ -47,7 +47,7 @@ static const nsXREAppData kAppData = { 0, "Thunderbird", - APP_VERSION, + NS_STRINGIFY(APP_VERSION), NS_STRINGIFY(BUILD_ID), // {3550f703-e582-4d05-9a08-453d09bdfdc6} { 0x3550f703, 0xe582, 0x4d05, { 0x9a, 0x08, 0x45, 0x3d, 0x09, 0xbd, 0xfd, 0xc6 } }, diff --git a/mozilla/mail/app/profile/all-thunderbird.js b/mozilla/mail/app/profile/all-thunderbird.js index 59ab6670966..49504b9bc9c 100644 --- a/mozilla/mail/app/profile/all-thunderbird.js +++ b/mozilla/mail/app/profile/all-thunderbird.js @@ -35,10 +35,7 @@ * * ***** END LICENSE BLOCK ***** */ -pref("general.useragent.vendor", "Thunderbird"); -pref("general.useragent.vendorSub", -#expand __APP_VERSION__ -); +#expand pref("general.useragent.extra.thunderbird", "Thunderbird/__APP_VERSION__"); #expand pref("general.useragent.locale", "__AB_CD__"); pref("general.skins.selectedSkin", "classic/1.0"); diff --git a/mozilla/netwerk/protocol/http/src/nsHttpHandler.cpp b/mozilla/netwerk/protocol/http/src/nsHttpHandler.cpp index 0285d20b903..df3fa26c10c 100644 --- a/mozilla/netwerk/protocol/http/src/nsHttpHandler.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHttpHandler.cpp @@ -70,6 +70,7 @@ #include "nsAutoLock.h" #include "prprf.h" #include "nsReadableUtils.h" +#include "nsQuickSort.h" #if defined(XP_UNIX) || defined(XP_BEOS) #include @@ -239,6 +240,7 @@ nsHttpHandler::Init() LOG(("> vendor = %s\n", mVendor.get())); LOG(("> vendor-sub = %s\n", mVendorSub.get())); LOG(("> vendor-comment = %s\n", mVendorComment.get())); + LOG(("> extra = %s\n", mExtraUA.get())); LOG(("> product = %s\n", mProduct.get())); LOG(("> product-sub = %s\n", mProductSub.get())); LOG(("> product-comment = %s\n", mProductComment.get())); @@ -530,6 +532,7 @@ nsHttpHandler::BuildUserAgent() mVendor.Length() + mVendorSub.Length() + mVendorComment.Length() + + mExtraUA.Length() + 22); // Application portion @@ -584,6 +587,9 @@ nsHttpHandler::BuildUserAgent() mUserAgent += ')'; } } + + if (!mExtraUA.IsEmpty()) + mUserAgent += mExtraUA; } void @@ -696,6 +702,12 @@ nsHttpHandler::InitUserAgentComponents() mUserAgentIsDirty = PR_TRUE; } +static int StringCompare(const void* s1, const void* s2, void*) +{ + return nsCRT::strcmp(*NS_STATIC_CAST(const char *const *, s1), + *NS_STATIC_CAST(const char *const *, s2)); +} + void nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref) { @@ -705,6 +717,8 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref) LOG(("nsHttpHandler::PrefsChanged [pref=%s]\n", pref)); #define PREF_CHANGED(p) ((pref == nsnull) || !PL_strcmp(pref, p)) +#define MULTI_PREF_CHANGED(p) \ + ((pref == nsnull) || !PL_strncmp(pref, p, sizeof(p) - 1)) // // UA components @@ -743,6 +757,36 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref) mUserAgentIsDirty = PR_TRUE; } + if (MULTI_PREF_CHANGED(UA_PREF("extra."))) { + mExtraUA.Truncate(); + + // Unfortunately, we can't do this using the pref branch. + nsCOMPtr service = + do_GetService(NS_PREFSERVICE_CONTRACTID); + nsCOMPtr branch; + service->GetBranch(UA_PREF("extra."), getter_AddRefs(branch)); + if (branch) { + PRUint32 extraCount; + char **extraItems; + rv = branch->GetChildList("", &extraCount, &extraItems); + if (NS_SUCCEEDED(rv) && extraItems) { + NS_QuickSort(extraItems, extraCount, sizeof(extraItems[0]), + StringCompare, nsnull); + for (char **item = extraItems, + **item_end = extraItems + extraCount; + item < item_end; ++item) { + nsXPIDLCString valStr; + branch->GetCharPref(*item, getter_Copies(valStr)); + if (!valStr.IsEmpty()) + mExtraUA += NS_LITERAL_CSTRING(" ") + valStr; + } + NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(extraCount, extraItems); + } + } + + mUserAgentIsDirty = PR_TRUE; + } + // Gather product values. if (PREF_CHANGED(UA_PREF("product"))) { prefs->GetCharPref(UA_PREF_PREFIX "product", @@ -1075,6 +1119,7 @@ nsHttpHandler::PrefsChanged(nsIPrefBranch *prefs, const char *pref) } #undef PREF_CHANGED +#undef MULTI_PREF_CHANGED } /** diff --git a/mozilla/netwerk/protocol/http/src/nsHttpHandler.h b/mozilla/netwerk/protocol/http/src/nsHttpHandler.h index a4bc6e2f57f..6188567f885 100644 --- a/mozilla/netwerk/protocol/http/src/nsHttpHandler.h +++ b/mozilla/netwerk/protocol/http/src/nsHttpHandler.h @@ -285,6 +285,7 @@ private: nsXPIDLCString mProduct; nsXPIDLCString mProductSub; nsXPIDLCString mProductComment; + nsCString mExtraUA; nsCString mUserAgent; nsXPIDLCString mUserAgentOverride; diff --git a/mozilla/xpcom/base/nscore.h b/mozilla/xpcom/base/nscore.h index 7952f4cafaf..52b66a7d902 100644 --- a/mozilla/xpcom/base/nscore.h +++ b/mozilla/xpcom/base/nscore.h @@ -427,9 +427,10 @@ typedef PRUint32 nsresult; #define NS_INT32_TO_PTR(x) ((void *)((char *)0 + (x))) /* - * Use this macro to form a string literal from an identifier. + * Use NS_STRINGIFY to form a string literal from the value of a macro. */ -#define NS_STRINGIFY(x) #x +#define NS_STRINGIFY_HELPER(x_) #x_ +#define NS_STRINGIFY(x_) NS_STRINGIFY_HELPER(x_) /* * These macros allow you to give a hint to the compiler about branch diff --git a/mozilla/xulrunner/examples/simple/simple-prefs.js b/mozilla/xulrunner/examples/simple/simple-prefs.js index 0a17b5f8f17..2008142c1bb 100644 --- a/mozilla/xulrunner/examples/simple/simple-prefs.js +++ b/mozilla/xulrunner/examples/simple/simple-prefs.js @@ -1,3 +1,2 @@ pref("toolkit.defaultChromeURI", "chrome://simple/content/simple.xul"); -pref("general.useragent.vendor", "SimpleApp"); -pref("general.useragent.vendorSub", "0.1"); +pref("general.useragent.extra.simple", "SimpleApp/0.1");