Fix bug 672662 - Provide a chrome registration flag for the platform version. r=Mossop
authorPhilipp Kewisch <mozilla@kewis.ch>
Wed, 10 Aug 2011 22:24:57 +0200
changeset 74224 e69bb10026f312104873d0ec112dc552c92257d5
parent 74223 968dee8a144a3e7802a4ba551d912e44f3d3ded0
child 74225 f2e8ee893fe4f4dc2b6870830fb1e22aa48691a3
push id2
push userbsmedberg@mozilla.com
push dateFri, 19 Aug 2011 14:38:13 +0000
reviewersMossop
bugs672662
milestone8.0a1
Fix bug 672662 - Provide a chrome registration flag for the platform version. r=Mossop
xpcom/components/ManifestParser.cpp
--- a/xpcom/components/ManifestParser.cpp
+++ b/xpcom/components/ManifestParser.cpp
@@ -15,16 +15,17 @@
  * The Original Code is Mozilla Firefox
  *
  * The Initial Developer of the Original Code is
  * the Mozilla Foundation <http://www.mozilla.org/>.
  * Portions created by the Initial Developer are Copyright (C) 2010
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
+ *   Philipp Kewisch <mozilla@kewis.ch>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
@@ -425,39 +426,45 @@ ParseManifestCommon(NSLocationType aType
                     const char* aPath, char* buf, bool aChromeOnly)
 {
   nsresult rv;
 
   NS_NAMED_LITERAL_STRING(kPlatform, "platform");
   NS_NAMED_LITERAL_STRING(kContentAccessible, "contentaccessible");
   NS_NAMED_LITERAL_STRING(kApplication, "application");
   NS_NAMED_LITERAL_STRING(kAppVersion, "appversion");
+  NS_NAMED_LITERAL_STRING(kGeckoVersion, "platformversion");
   NS_NAMED_LITERAL_STRING(kOs, "os");
   NS_NAMED_LITERAL_STRING(kOsVersion, "osversion");
   NS_NAMED_LITERAL_STRING(kABI, "abi");
 
   // Obsolete
   NS_NAMED_LITERAL_STRING(kXPCNativeWrappers, "xpcnativewrappers");
 
   nsAutoString appID;
   nsAutoString appVersion;
+  nsAutoString geckoVersion;
   nsAutoString osTarget;
   nsAutoString abi;
 
   nsCOMPtr<nsIXULAppInfo> xapp (do_GetService(XULAPPINFO_SERVICE_CONTRACTID));
   if (xapp) {
     nsCAutoString s;
     rv = xapp->GetID(s);
     if (NS_SUCCEEDED(rv))
       CopyUTF8toUTF16(s, appID);
 
     rv = xapp->GetVersion(s);
     if (NS_SUCCEEDED(rv))
       CopyUTF8toUTF16(s, appVersion);
 
+    rv = xapp->GetPlatformVersion(s);
+    if (NS_SUCCEEDED(rv))
+      CopyUTF8toUTF16(s, geckoVersion);
+
     nsCOMPtr<nsIXULRuntime> xruntime (do_QueryInterface(xapp));
     if (xruntime) {
       rv = xruntime->GetOS(s);
       if (NS_SUCCEEDED(rv)) {
         ToLowerCase(s);
         CopyUTF8toUTF16(s, osTarget);
       }
 
@@ -571,32 +578,34 @@ ParseManifestCommon(NSLocationType aType
       LogMessageWithContext(aFile, aPath, line,
                             "Not enough arguments for chrome manifest directive '%s', expected %i.",
                             token, directive->argc);
       continue;
     }
 
     bool ok = true;
     TriState stAppVersion = eUnspecified;
+    TriState stGeckoVersion = eUnspecified;
     TriState stApp = eUnspecified;
     TriState stOsVersion = eUnspecified;
     TriState stOs = eUnspecified;
     TriState stABI = eUnspecified;
     bool platform = false;
     bool contentAccessible = false;
 
     while (NULL != (token = nsCRT::strtok(whitespace, kWhitespace, &whitespace)) && ok) {
       ToLowerCase(token);
       NS_ConvertASCIItoUTF16 wtoken(token);
 
       if (CheckStringFlag(kApplication, wtoken, appID, stApp) ||
           CheckStringFlag(kOs, wtoken, osTarget, stOs) ||
           CheckStringFlag(kABI, wtoken, abi, stABI) ||
           CheckVersionFlag(kOsVersion, wtoken, osVersion, stOsVersion) ||
-          CheckVersionFlag(kAppVersion, wtoken, appVersion, stAppVersion))
+          CheckVersionFlag(kAppVersion, wtoken, appVersion, stAppVersion) ||
+          CheckVersionFlag(kGeckoVersion, wtoken, geckoVersion, stGeckoVersion))
         continue;
 
       if (directive->contentflags &&
           (CheckFlag(kPlatform, wtoken, platform) ||
            CheckFlag(kContentAccessible, wtoken, contentAccessible)))
         continue;
 
       bool xpcNativeWrappers = true; // Dummy for CheckFlag.
@@ -611,16 +620,17 @@ ParseManifestCommon(NSLocationType aType
                             "Unrecognized chrome manifest modifier '%s'.",
                             token);
       ok = false;
     }
 
     if (!ok ||
         stApp == eBad ||
         stAppVersion == eBad ||
+        stGeckoVersion == eBad ||
         stOs == eBad ||
         stOsVersion == eBad ||
         stABI == eBad)
       continue;
 
     if (directive->regfunc) {
       if (GeckoProcessType_Default != XRE_GetProcessType())
         continue;