Bug 671634 - Fennec UA changes. Useragent should be different between phones and tablets. r=me sr=bz a=gerv
authorMark Finkle <mfinkle@mozilla.com>
Tue, 31 Jan 2012 20:04:23 -0800
changeset 85846 e18c7bc2c28e
parent 85845 1410782d557d
child 85897 07edb8ba21b9
push id21973
push userdougt@mozilla.com
push date2012-02-01 05:02 +0000
treeherdermozilla-central@e18c7bc2c28e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme, bz, gerv
bugs671634
milestone13.0a1
first release with
nightly linux32
e18c7bc2c28e / 13.0a1 / 20120201031146 / files
nightly linux64
e18c7bc2c28e / 13.0a1 / 20120201031146 / files
nightly mac
e18c7bc2c28e / 13.0a1 / 20120201031146 / files
nightly win32
e18c7bc2c28e / 13.0a1 / 20120201031146 / files
nightly win64
e18c7bc2c28e / 13.0a1 / 20120201031146 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 671634 - Fennec UA changes. Useragent should be different between phones and tablets. r=me sr=bz a=gerv Please read http://groups.google.com/group/mozilla.dev.platform/msg/8133920a2ccf4d5b for the details. Also see https://wiki.mozilla.org/Fennec/User_Agent for Gerv's accepted proposal.
mobile/android/app/mobile.js
mobile/android/confvars.sh
netwerk/protocol/http/nsHttpHandler.cpp
netwerk/protocol/http/nsHttpHandler.h
xpcom/base/nsSystemInfo.cpp
--- a/mobile/android/app/mobile.js
+++ b/mobile/android/app/mobile.js
@@ -52,17 +52,16 @@
 pref("toolkit.browser.cacheRatioWidth", 2000);
 pref("toolkit.browser.cacheRatioHeight", 3000);
 
 // How long before a content view (a handle to a remote scrollable object)
 // expires.
 pref("toolkit.browser.contentViewExpire", 3000);
 
 pref("toolkit.defaultChromeURI", "chrome://browser/content/browser.xul");
-pref("general.useragent.compatMode.firefox", true);
 pref("browser.chromeURL", "chrome://browser/content/");
 
 pref("browser.tabs.warnOnClose", true);
 pref("browser.tabs.remote", true);
 
 pref("toolkit.screen.lock", false);
 
 // From libpref/src/init/all.js, extended to allow a slightly wider zoom range.
--- a/mobile/android/confvars.sh
+++ b/mobile/android/confvars.sh
@@ -34,16 +34,17 @@
 # the terms of any one of the MPL, the GPL or the LGPL.
 #
 # ***** END LICENSE BLOCK *****
 
 MOZ_APP_BASENAME=Fennec
 MOZ_APP_VENDOR=Mozilla
 
 MOZ_APP_VERSION=13.0a1
+MOZ_APP_UA_NAME=Firefox
 
 MOZ_BRANDING_DIRECTORY=mobile/android/branding/unofficial
 MOZ_OFFICIAL_BRANDING_DIRECTORY=mobile/android/branding/official
 # MOZ_APP_DISPLAYNAME is set by branding/configure.sh
 
 MOZ_SAFE_BROWSING=
 MOZ_SERVICES_SYNC=
 
--- a/netwerk/protocol/http/nsHttpHandler.cpp
+++ b/netwerk/protocol/http/nsHttpHandler.cpp
@@ -302,17 +302,21 @@ nsHttpHandler::Init()
     mSessionStartTime = NowInSeconds();
 
     rv = mAuthCache.Init();
     if (NS_FAILED(rv)) return rv;
 
     rv = InitConnectionMgr();
     if (NS_FAILED(rv)) return rv;
 
+#ifdef ANDROID
+    mProductSub.AssignLiteral(MOZ_APP_UA_VERSION);
+#else
     mProductSub.AssignLiteral(MOZ_UA_BUILDID);
+#endif
     if (mProductSub.IsEmpty() && appInfo)
         appInfo->GetPlatformBuildID(mProductSub);
     if (mProductSub.Length() > 8)
         mProductSub.SetLength(8);
 
     // Startup the http category
     // Bring alive the objects in the http-protocol-startup category
     NS_CreateServicesFromCategory(NS_HTTP_STARTUP_CATEGORY,
@@ -597,32 +601,40 @@ nsHttpHandler::BuildUserAgent()
 #endif
                            mOscpu.Length() +
                            mMisc.Length() +
                            mProduct.Length() +
                            mProductSub.Length() +
                            mAppName.Length() +
                            mAppVersion.Length() +
                            mCompatFirefox.Length() +
+                           mCompatDevice.Length() +
                            13);
 
     // Application portion
     mUserAgent.Assign(mLegacyAppName);
     mUserAgent += '/';
     mUserAgent += mLegacyAppVersion;
     mUserAgent += ' ';
 
     // Application comment
     mUserAgent += '(';
 #ifndef UA_SPARE_PLATFORM
     mUserAgent += mPlatform;
     mUserAgent.AppendLiteral("; ");
 #endif
+#ifdef ANDROID
+    if (!mCompatDevice.IsEmpty()) {
+        mUserAgent += mCompatDevice;
+        mUserAgent.AppendLiteral("; ");
+    }
+#else
     mUserAgent += mOscpu;
     mUserAgent.AppendLiteral("; ");
+#endif
     mUserAgent += mMisc;
     mUserAgent += ')';
 
     // Product portion
     mUserAgent += ' ';
     mUserAgent += mProduct;
     mUserAgent += '/';
     mUserAgent += mProductSub;
@@ -645,18 +657,17 @@ typedef BOOL (WINAPI *IsWow64ProcessP) (
 
 #define WNT_BASE "Windows NT %ld.%ld"
 #define W64_PREFIX "; Win64"
 #endif
 
 void
 nsHttpHandler::InitUserAgentComponents()
 {
-
-      // Gather platform.
+    // Gather platform.
     mPlatform.AssignLiteral(
 #if defined(ANDROID)
     "Android"
 #elif defined(XP_OS2)
     "OS/2"
 #elif defined(XP_WIN)
     "Windows"
 #elif defined(XP_MACOSX)
@@ -665,16 +676,28 @@ nsHttpHandler::InitUserAgentComponents()
     "Maemo"
 #elif defined(MOZ_X11)
     "X11"
 #else
     "?"
 #endif
     );
 
+#if defined(ANDROID)
+    nsCOMPtr<nsIPropertyBag2> infoService = do_GetService("@mozilla.org/system-info;1");
+    NS_ASSERTION(infoService, "Could not find a system info service");
+
+    bool isTablet;
+    infoService->GetPropertyAsBool(NS_LITERAL_STRING("tablet"), &isTablet);
+    if (isTablet)
+        mCompatDevice.AssignLiteral("Tablet");
+    else
+        mCompatDevice.AssignLiteral("Mobile");
+#endif
+
     // Gather OS/CPU.
 #if defined(XP_OS2)
     ULONG os2ver = 0;
     DosQuerySysInfo(QSV_VERSION_MINOR, QSV_VERSION_MINOR,
                     &os2ver, sizeof(os2ver));
     if (os2ver == 11)
         mOscpu.AssignLiteral("2.11");
     else if (os2ver == 30)
--- a/netwerk/protocol/http/nsHttpHandler.h
+++ b/netwerk/protocol/http/nsHttpHandler.h
@@ -316,16 +316,17 @@ private:
     nsCString      mPlatform;
     nsCString      mOscpu;
     nsCString      mMisc;
     nsCString      mProduct;
     nsXPIDLCString mProductSub;
     nsXPIDLCString mAppName;
     nsXPIDLCString mAppVersion;
     nsCString      mCompatFirefox;
+    nsXPIDLCString mCompatDevice;
 
     nsCString      mUserAgent;
     nsXPIDLCString mUserAgentOverride;
     bool           mUserAgentIsDirty; // true if mUserAgent should be rebuilt
 
     bool           mUseCache;
 
     bool           mPromptTempRedirect;
--- a/xpcom/base/nsSystemInfo.cpp
+++ b/xpcom/base/nsSystemInfo.cpp
@@ -196,17 +196,17 @@ nsSystemInfo::Init()
             if (version) {
                 str.Append(NS_LITERAL_STRING(" ("));
                 str.AppendInt(version);
                 str.Append(NS_LITERAL_STRING(")"));
             }
             SetPropertyAsAString(NS_LITERAL_STRING("shellVersion"), str);
         }
         bool isTablet = mozilla::AndroidBridge::Bridge()->IsTablet();
-        SetPropertyAsBool(NS_LITERAL_STRING("isTablet"), isTablet);
+        SetPropertyAsBool(NS_LITERAL_STRING("tablet"), isTablet);
     }
 #endif
     return NS_OK;
 }
 
 void
 nsSystemInfo::SetInt32Property(const nsAString &aPropertyName,
                                const PRInt32 aValue)