Bug 945829 - Metrofox hangs on startup when trying to show the profile chooser dialog. r=jimm a=lsblakk
authorBrian R. Bondy <netzen@gmail.com>
Fri, 13 Dec 2013 12:12:00 -0500
changeset 175385 cac87bf8f6ec7f67c2b3bd9a8e824043e5e91adc
parent 175384 11d0763c3ca90993c3623f9495defa4115847330
child 175386 29ce4b1f69d478c3f8ac5c22e2ca7f5482be6b93
push id445
push userffxbld
push dateMon, 10 Mar 2014 22:05:19 +0000
treeherdermozilla-release@dc38b741b04e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm, lsblakk
bugs945829
milestone28.0a2
Bug 945829 - Metrofox hangs on startup when trying to show the profile chooser dialog. r=jimm a=lsblakk
toolkit/xre/nsAppRunner.cpp
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -569,16 +569,32 @@ ProcessDDE(nsINativeAppSupport* aNative,
         NS_ProcessNextEvent(thread);
         PR_Sleep(PR_MillisecondsToInterval(1));
       }
     }
   }
 }
 #endif
 
+/**
+ * Determines if there is support for showing the profile manager
+ *
+ * @return true in all environments except for Windows Metro
+*/
+static bool
+CanShowProfileManager()
+{
+#if defined(XP_WIN)
+  return XRE_GetWindowsEnvironment() == WindowsEnvironmentType_Desktop;
+#else
+  return true;
+#endif
+}
+
+
 bool gSafeMode = false;
 
 /**
  * The nsXULAppInfo object implements nsIFactory so that it can be its own
  * singleton.
  */
 class nsXULAppInfo : public nsIXULAppInfo,
 #ifdef XP_WIN
@@ -1878,16 +1894,20 @@ ProfileLockedDialog(nsIToolkitProfile* a
 
 static const char kProfileManagerURL[] =
   "chrome://mozapps/content/profile/profileSelection.xul";
 
 static nsresult
 ShowProfileManager(nsIToolkitProfileService* aProfileSvc,
                    nsINativeAppSupport* aNative)
 {
+  if (!CanShowProfileManager()) {
+    return NS_ERROR_NOT_IMPLEMENTED;
+  }
+
   nsresult rv;
 
   nsCOMPtr<nsIFile> profD, profLD;
   PRUnichar* profileNamePtr;
   nsAutoCString profileName;
 
   {
     ScopedXPCOMStartup xpcom;
@@ -2228,17 +2248,20 @@ SelectProfile(nsIProfileLock* *aResult, 
 
   ar = CheckArg("p", false, &arg);
   if (ar == ARG_BAD) {
     ar = CheckArg("osint");
     if (ar == ARG_FOUND) {
       PR_fprintf(PR_STDERR, "Error: argument -p is invalid when argument -osint is specified\n");
       return NS_ERROR_FAILURE;
     }
-    return ShowProfileManager(aProfileSvc, aNative);
+
+    if (CanShowProfileManager()) {
+      return ShowProfileManager(aProfileSvc, aNative);
+    }
   }
   if (ar) {
     ar = CheckArg("osint");
     if (ar == ARG_FOUND) {
       PR_fprintf(PR_STDERR, "Error: argument -p is invalid when argument -osint is specified\n");
       return NS_ERROR_FAILURE;
     }
     nsCOMPtr<nsIToolkitProfile> profile;
@@ -2256,24 +2279,26 @@ SelectProfile(nsIProfileLock* *aResult, 
         if (aProfileName)
           aProfileName->Assign(nsDependentCString(arg));
         return NS_OK;
       }
 
       return ProfileLockedDialog(profile, unlocker, aNative, aResult);
     }
 
-    return ShowProfileManager(aProfileSvc, aNative);
+    if (CanShowProfileManager()) {
+      return ShowProfileManager(aProfileSvc, aNative);
+    }
   }
 
   ar = CheckArg("profilemanager", true);
   if (ar == ARG_BAD) {
     PR_fprintf(PR_STDERR, "Error: argument -profilemanager is invalid when argument -osint is specified\n");
     return NS_ERROR_FAILURE;
-  } else if (ar == ARG_FOUND) {
+  } else if (ar == ARG_FOUND && CanShowProfileManager()) {
     return ShowProfileManager(aProfileSvc, aNative);
   }
 
   if (!count) {
     gDoMigration = true;
     gDoProfileReset = false;
 
     // create a default profile
@@ -2288,18 +2313,19 @@ SelectProfile(nsIProfileLock* *aResult, 
         if (aProfileName)
           aProfileName->Assign(NS_LITERAL_CSTRING("default"));
         return NS_OK;
       }
     }
   }
 
   bool useDefault = true;
-  if (count > 1)
+  if (count > 1 && CanShowProfileManager()) {
     aProfileSvc->GetStartWithLastProfile(&useDefault);
+  }
 
   if (useDefault) {
     nsCOMPtr<nsIToolkitProfile> profile;
     // GetSelectedProfile will auto-select the only profile if there's just one
     aProfileSvc->GetSelectedProfile(getter_AddRefs(profile));
     if (profile) {
       // If we're resetting a profile, create a new one and use it to startup.
       if (gDoProfileReset) {
@@ -2344,16 +2370,20 @@ SelectProfile(nsIProfileLock* *aResult, 
         }
         PR_Sleep(kLockRetrySleepMS);
       } while (TimeStamp::Now() - start < TimeDuration::FromSeconds(kLockRetrySeconds));
 
       return ProfileLockedDialog(profile, unlocker, aNative, aResult);
     }
   }
 
+  if (!CanShowProfileManager()) {
+    return NS_ERROR_FAILURE;
+  }
+
   return ShowProfileManager(aProfileSvc, aNative);
 }
 
 /** 
  * Checks the compatibility.ini file to see if we have updated our application
  * or otherwise invalidated our caches. If the application has been updated, 
  * we return false; otherwise, we return true. We also write the status 
  * of the caches (valid/invalid) into the return param aCachesOK. The aCachesOK