Bug 965414 - Don't try to use the JS downloads implementation in the webapp runtime because we don't have one. r=paolo
authorMarco Castelluccio <mar.castelluccio@studenti.unina.it>
Sun, 27 Apr 2014 12:22:00 -0400
changeset 198984 69fa0b8c4de6d328adc181c364b87b8fd0a315eb
parent 198983 1f037080962f7b272eba794c19cd353985364291
child 198985 6aa938a57e1abc8ff5b4e213e348745613ca3230
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaolo
bugs965414
milestone31.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 965414 - Don't try to use the JS downloads implementation in the webapp runtime because we don't have one. r=paolo
toolkit/components/downloads/nsDownloadManager.cpp
--- a/toolkit/components/downloads/nsDownloadManager.cpp
+++ b/toolkit/components/downloads/nsDownloadManager.cpp
@@ -16,16 +16,17 @@
 #include "nsIParentalControlsService.h"
 #include "nsIPrefService.h"
 #include "nsIPromptService.h"
 #include "nsIResumableChannel.h"
 #include "nsIWebBrowserPersist.h"
 #include "nsIWindowMediator.h"
 #include "nsILocalFileWin.h"
 #include "nsILoadContext.h"
+#include "nsIXULAppInfo.h"
 
 #include "nsAppDirectoryServiceDefs.h"
 #include "nsArrayEnumerator.h"
 #include "nsCExternalHandlerService.h"
 #include "nsDirectoryServiceDefs.h"
 #include "nsDownloadManager.h"
 #include "nsNetUtil.h"
 #include "nsThreadUtils.h"
@@ -935,33 +936,45 @@ nsDownloadManager::Init()
     mozilla::services::GetStringBundleService();
   if (!bundleService)
     return NS_ERROR_FAILURE;
 
   rv = bundleService->CreateBundle(DOWNLOAD_MANAGER_BUNDLE,
                                    getter_AddRefs(mBundle));
   NS_ENSURE_SUCCESS(rv, rv);
 
-#if defined(MOZ_JSDOWNLOADS) && !defined(XP_WIN)
-
-  // When MOZ_JSDOWNLOADS is defined on a non-Windows platform, this component
-  // is always disabled and we can safely omit the initialization code.
-  mUseJSTransfer = true;
-
-#else
-
-#if defined(MOZ_JSDOWNLOADS) && defined(XP_WIN)
-  // When MOZ_JSDOWNLOADS is defined on Windows, this component is disabled
-  // unless we are running in Windows Metro.  The conversion of Windows Metro
-  // to use the JavaScript API for downloads is tracked in bug 906042.
-  mUseJSTransfer = !IsRunningInWindowsMetro();
-#else
+#if !defined(MOZ_JSDOWNLOADS)
   // When MOZ_JSDOWNLOADS is undefined, we still check the preference that can
   // be used to enable the JavaScript API during the migration process.
   mUseJSTransfer = Preferences::GetBool(PREF_BD_USEJSTRANSFER, false);
+#else
+
+  nsAutoCString appID;
+  nsCOMPtr<nsIXULAppInfo> info = do_GetService("@mozilla.org/xre/app-info;1");
+  if (info) {
+    rv = info->GetID(appID);
+    NS_ENSURE_SUCCESS(rv, rv);
+  }
+
+  // The webapp runtime doesn't use the new JS downloads API yet.
+  // The conversion of the webapp runtime to use the JavaScript API for
+  // downloads is tracked in bug 911636.
+  if (appID.EqualsLiteral("webapprt@mozilla.org")) {
+    mUseJSTransfer = false;
+  } else {
+#if !defined(XP_WIN)
+    mUseJSTransfer = true;
+#else
+    // When MOZ_JSDOWNLOADS is defined on Windows, this component is disabled
+    // unless we are running in Windows Metro.  The conversion of Windows Metro
+    // to use the JavaScript API for downloads is tracked in bug 906042.
+    mUseJSTransfer = !IsRunningInWindowsMetro();
+#endif
+  }
+
 #endif
 
   if (mUseJSTransfer)
     return NS_OK;
 
   // Clean up any old downloads.rdf files from before Firefox 3
   {
     nsCOMPtr<nsIFile> oldDownloadsFile;
@@ -1024,18 +1037,16 @@ nsDownloadManager::Init()
   (void)mObserverService->AddObserver(this, NS_IOSERVICE_GOING_OFFLINE_TOPIC, true);
   (void)mObserverService->AddObserver(this, NS_IOSERVICE_OFFLINE_STATUS_TOPIC, true);
   (void)mObserverService->AddObserver(this, "last-pb-context-exited", true);
   (void)mObserverService->AddObserver(this, "last-pb-context-exiting", true);
 
   if (history)
     (void)history->AddObserver(this, true);
 
-#endif // defined(MOZ_JSDOWNLOADS) && !defined(XP_WIN)
-
   return NS_OK;
 }
 
 int32_t
 nsDownloadManager::GetRetentionBehavior()
 {
   // We use 0 as the default, which is "remove when done"
   nsresult rv;