Bug 750911 - Add a third 'flags' parameter to XRE_main and add support for WindowsEnvironmentType. r=bsmedberg
authorJim Mathies <jmathies@mozilla.com>
Fri, 25 May 2012 05:01:29 -0500
changeset 99332 0d1dcdf58ffb422361f7da3e5557eedd73db2700
parent 99331 1dd0c5c6d9fd066d28d8e44c4542e3f71d529bbb
child 99333 831ff2eb9a281b918276f4998b43dfec141f0b62
push id173
push userlsblakk@mozilla.com
push dateFri, 24 Aug 2012 15:39:16 +0000
treeherdermozilla-release@bcc45eb1fb41 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg
bugs750911
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 750911 - Add a third 'flags' parameter to XRE_main and add support for WindowsEnvironmentType. r=bsmedberg
b2g/app/nsBrowserApp.cpp
browser/app/nsBrowserApp.cpp
mobile/xul/app/nsBrowserApp.cpp
toolkit/library/dlldeps-xul.cpp
toolkit/xre/nsAndroidStartup.cpp
toolkit/xre/nsAppRunner.cpp
toolkit/xre/nsEmbedFunctions.cpp
webapprt/mac/webapprt.mm
webapprt/win/webapprt.cpp
xpcom/build/nsXULAppAPI.h
xulrunner/app/nsXULRunnerApp.cpp
xulrunner/stub/nsXULStub.cpp
--- a/b2g/app/nsBrowserApp.cpp
+++ b/b2g/app/nsBrowserApp.cpp
@@ -140,22 +140,22 @@ static int do_main(int argc, char* argv[
 
   if (appini) {
     nsXREAppData *appData;
     rv = XRE_CreateAppData(appini, &appData);
     if (NS_FAILED(rv)) {
       Output("Couldn't read application.ini");
       return 255;
     }
-    int result = XRE_main(argc, argv, appData);
+    int result = XRE_main(argc, argv, appData, 0);
     XRE_FreeAppData(appData);
     return result;
   }
 
-  return XRE_main(argc, argv, &sAppData);
+  return XRE_main(argc, argv, &sAppData, 0);
 }
 
 int main(int argc, char* argv[])
 {
   char exePath[MAXPATHLEN];
 
   nsresult rv = mozilla::BinaryPath::Get(argv[0], exePath);
   if (NS_FAILED(rv)) {
--- a/browser/app/nsBrowserApp.cpp
+++ b/browser/app/nsBrowserApp.cpp
@@ -144,22 +144,22 @@ static int do_main(int argc, char* argv[
 
   if (appini) {
     nsXREAppData *appData;
     rv = XRE_CreateAppData(appini, &appData);
     if (NS_FAILED(rv)) {
       Output("Couldn't read application.ini");
       return 255;
     }
-    int result = XRE_main(argc, argv, appData);
+    int result = XRE_main(argc, argv, appData, 0);
     XRE_FreeAppData(appData);
     return result;
   }
 
-  return XRE_main(argc, argv, &sAppData);
+  return XRE_main(argc, argv, &sAppData, 0);
 }
 
 int main(int argc, char* argv[])
 {
   char exePath[MAXPATHLEN];
 
 #ifdef XP_MACOSX
   TriggerQuirks();
--- a/mobile/xul/app/nsBrowserApp.cpp
+++ b/mobile/xul/app/nsBrowserApp.cpp
@@ -147,22 +147,22 @@ static int do_main(int argc, char* argv[
 
   if (appini) {
     nsXREAppData *appData;
     rv = XRE_CreateAppData(appini, &appData);
     if (NS_FAILED(rv)) {
       Output("Couldn't read application.ini");
       return 255;
     }
-    int result = XRE_main(argc, argv, appData);
+    int result = XRE_main(argc, argv, appData, 0);
     XRE_FreeAppData(appData);
     return result;
   }
 
-  return XRE_main(argc, argv, &sAppData);
+  return XRE_main(argc, argv, &sAppData, 0);
 }
 
 #if MOZ_PLATFORM_MAEMO == 6
 static bool
 GeckoPreLoader(const char* execPath)
 {
   nsresult rv = XPCOMGlueStartup(execPath);
   if (NS_FAILED(rv)) {
--- a/toolkit/library/dlldeps-xul.cpp
+++ b/toolkit/library/dlldeps-xul.cpp
@@ -1,17 +1,17 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "nsXULAppAPI.h"
 
 void xxxNeverCalledXUL()
 {
-  XRE_main(0, nsnull, nsnull);
+  XRE_main(0, nsnull, nsnull, nsnull);
   XRE_GetFileFromPath(nsnull, nsnull);
   XRE_LockProfileDirectory(nsnull, nsnull);
   XRE_InitEmbedding2(nsnull, nsnull, nsnull);
   XRE_NotifyProfile();
   XRE_TermEmbedding();
   XRE_CreateAppData(nsnull, nsnull);
   XRE_ParseAppData(nsnull, nsnull);
   XRE_FreeAppData(nsnull);
--- a/toolkit/xre/nsAndroidStartup.cpp
+++ b/toolkit/xre/nsAndroidStartup.cpp
@@ -65,17 +65,17 @@ GeckoStart(void *data, const nsXREAppDat
     nsTArray<char *> targs;
     char *arg = strtok(static_cast<char *>(data), " ");
     while (arg) {
         targs.AppendElement(arg);
         arg = strtok(NULL, " ");
     }
     targs.AppendElement(static_cast<char *>(nsnull));
 
-    int result = XRE_main(targs.Length() - 1, targs.Elements(), appData);
+    int result = XRE_main(targs.Length() - 1, targs.Elements(), appData, 0);
 
     if (result)
         LOG("XRE_main returned %d", result);
 
     mozilla::AndroidBridge::Bridge()->NotifyXreExit();
 
     free(targs[0]);
     nsMemory::Free(data);
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -3907,17 +3907,17 @@ XREMain::XRE_main(int argc, char* argv[]
 #endif
 
   XRE_DeinitCommandLine();
 
   return NS_FAILED(rv) ? 1 : 0;
 }
 
 int
-XRE_main(int argc, char* argv[], const nsXREAppData* aAppData)
+XRE_main(int argc, char* argv[], const nsXREAppData* aAppData, PRUint32 aFlags)
 {
   XREMain main;
   return main.XRE_main(argc, argv, aAppData);
 }
 
 nsresult
 XRE_InitCommandLine(int aArgc, char* aArgv[])
 {
--- a/toolkit/xre/nsEmbedFunctions.cpp
+++ b/toolkit/xre/nsEmbedFunctions.cpp
@@ -741,8 +741,26 @@ XRE_ShutdownTestShell()
 
 #ifdef MOZ_X11
 void
 XRE_InstallX11ErrorHandler()
 {
   InstallX11ErrorHandler();
 }
 #endif
+
+#ifdef XP_WIN
+static WindowsEnvironmentType
+sWindowsEnvironmentType = WindowsEnvironmentType_Desktop;
+
+void
+SetWindowsEnvironment(WindowsEnvironmentType aEnvID)
+{
+  sWindowsEnvironmentType = aEnvID;
+}
+
+WindowsEnvironmentType
+XRE_GetWindowsEnvironment()
+{
+  return sWindowsEnvironmentType;
+}
+#endif // XP_WIN
+
--- a/webapprt/mac/webapprt.mm
+++ b/webapprt/mac/webapprt.mm
@@ -266,17 +266,17 @@ main(int argc, char **argv)
           @throw MakeException(@"Error", @"Unable to open application XRE directory.");
         }
 
         xreDir.forget(&webShellAppData->xreDirectory);
         NS_IF_RELEASE(webShellAppData->directory);
         directory.forget(&webShellAppData->directory);
 
         // There is only XUL.
-        result = XRE_main(argc, argv, webShellAppData);
+        result = XRE_main(argc, argv, webShellAppData, 0);
 
         XRE_FreeAppData(webShellAppData);
       }
       NS_LogTerm();
 
       return result;
     }
 
--- a/webapprt/win/webapprt.cpp
+++ b/webapprt/win/webapprt.cpp
@@ -297,17 +297,17 @@ namespace {
       rv = XRE_GetFileFromPath(greDir, getter_AddRefs(xreDir));
       NS_ENSURE_SUCCESS(rv, false);
 
       xreDir.forget(&webShellAppData->xreDirectory);
       NS_IF_RELEASE(webShellAppData->directory);
       directory.forget(&webShellAppData->directory);
 
       // There is only XUL.
-      XRE_main(*pargc, *pargv, webShellAppData);
+      XRE_main(*pargc, *pargv, webShellAppData, 0);
     }
 
     return true;
   }
 
   bool
   AttemptLoadFromDir(char* firefoxDir)
   {
--- a/xpcom/build/nsXULAppAPI.h
+++ b/xpcom/build/nsXULAppAPI.h
@@ -120,33 +120,43 @@
  * Windows: Documents and Settings\<User>\Local Settings\Application Data\
  *          <Vendor>\<Application>\<relative path to app dir from Program Files>
  * If appDir is not under the Program Files, directory service will fail.
  * Callers should fallback to appDir.
  */
 #define XRE_UPDATE_ROOT_DIR "UpdRootD"
 
 /**
+ * Platform flag values for XRE_main.
+ *
+ * XRE_MAIN_FLAG_USE_METRO - On Windows, use the winrt backend. Defaults
+ * to win32 backend.
+ */
+#define XRE_MAIN_FLAG_USE_METRO 0x01
+
+/**
  * Begin an XUL application. Does not return until the user exits the
  * application.
  *
  * @param argc/argv Command-line parameters to pass to the application. On
  *                  Windows, these should be in UTF8. On unix-like platforms
  *                  these are in the "native" character set.
  *
  * @param aAppData  Information about the application to be run.
  *
+ * @param aFlags    Platform specific flags.
+ *
  * @return         A native result code suitable for returning from main().
  *
  * @note           If the binary is linked against the standalone XPCOM glue,
  *                 XPCOMGlueStartup() should be called before this method.
- *
  */
 XRE_API(int,
-        XRE_main, (int argc, char* argv[], const nsXREAppData* sAppData))
+        XRE_main, (int argc, char* argv[], const nsXREAppData* aAppData,
+                   PRUint32 aFlags))
 
 /**
  * Given a path relative to the current working directory (or an absolute
  * path), return an appropriate nsILocalFile object.
  *
  * @note Pass UTF8 strings on Windows... native charset on other platforms.
  */
 XRE_API(nsresult,
@@ -424,13 +434,30 @@ XRE_API(void,
 #define XRE_HAS_DLL_BLOCKLIST
 XRE_API(void,
         XRE_SetupDllBlocklist, ())
 #endif
 
 XRE_API(void,
         XRE_TelemetryAccumulate, (int aID, PRUint32 aSample))
 
-
 XRE_API(void,
         XRE_InitOmnijar, (nsILocalFile* greOmni,
                           nsILocalFile* appOmni))
+
+#ifdef XP_WIN
+/**
+ * Valid environment types for XRE_GetWindowsEnvironment.
+ */
+enum WindowsEnvironmentType {
+  WindowsEnvironmentType_Desktop = 0,
+  WindowsEnvironmentType_Metro = 1
+};
+
+/**
+ * Retrieve the Windows desktop environment libXUL is running
+ * under. Valid after a call to XRE_main.
+ */
+XRE_API(WindowsEnvironmentType,
+        XRE_GetWindowsEnvironment, ())
+#endif // XP_WIN
+
 #endif // _nsXULAppAPI_h__
--- a/xulrunner/app/nsXULRunnerApp.cpp
+++ b/xulrunner/app/nsXULRunnerApp.cpp
@@ -342,10 +342,10 @@ int main(int argc, char* argv[])
   }
 
   AutoAppData appData(appDataLF);
   if (!appData) {
     Output(true, "Error: couldn't parse application.ini.\n");
     return 2;
   }
 
-  return XRE_main(argc, argv, appData);
+  return XRE_main(argc, argv, appData, 0);
 }
--- a/xulrunner/stub/nsXULStub.cpp
+++ b/xulrunner/stub/nsXULStub.cpp
@@ -475,17 +475,17 @@ main(int argc, char **argv)
       NS_NewLocalFile(NS_ConvertUTF8toUTF16(greDir), false,
                       &appData->xreDirectory);
 #else
       NS_NewNativeLocalFile(nsDependentCString(greDir), false,
                             &appData->xreDirectory);
 #endif
     }
 
-    retval = XRE_main(argc, argv, appData);
+    retval = XRE_main(argc, argv, appData, 0);
   }
 
   NS_LogTerm();
 
   XPCOMGlueShutdown();
 
   return retval;
 }