bug 381157 - Make SeaMonkey download manager use toolkit backend, r+sr=Neil, main parts of the patch by Callek, fixes for review comments by mcsmurf
authorJustin Wood <bugspam.Callek@gmail.com>
Fri, 29 May 2009 12:06:45 +0200
changeset 2728 178d054e316394f7c009003b51f649c3e566179e
parent 2727 98a7de404c08fb375c20bcee33c9dea633a05a50
child 2729 aea638bfac91c35895a55b945253daecb0c0dc3d
push idunknown
push userunknown
push dateunknown
bugs381157
bug 381157 - Make SeaMonkey download manager use toolkit backend, r+sr=Neil, main parts of the patch by Callek, fixes for review comments by mcsmurf
suite/app-config.mk
suite/browser/browser-prefs.js
suite/browser/navigator.js
suite/browser/viewsource.js
suite/common/contentAreaUtils.js
suite/common/downloads/progressDialog.xul
suite/common/jar.mn
suite/common/nsContextMenu.js
suite/common/pref/pref-applications-edit.xul
suite/common/pref/pref-security.js
suite/common/public/Makefile.in
suite/common/public/nsISuiteDownloadManagerUI.idl
suite/common/src/Makefile.in
suite/common/src/nsSuiteDownloadManagerUI.js
suite/common/src/nsSuiteGlue.js
suite/common/tasksOverlay.js
suite/installer/removed-files.in
suite/installer/unix/packages
suite/installer/windows/packages
suite/locales/en-US/chrome/common/downloads/progressDialog.dtd
suite/locales/jar.mn
suite/modules/Sanitizer.jsm
suite/modules/test/browser_sanitizer.js
suite/profile/migration/src/nsNetscapeProfileMigratorBase.cpp
suite/profile/migration/src/nsNetscapeProfileMigratorBase.h
suite/profile/migration/src/nsSeamonkeyProfileMigrator.cpp
--- a/suite/app-config.mk
+++ b/suite/app-config.mk
@@ -41,11 +41,9 @@ DEFINES += -DMOZ_SUITE=1
 # Make the whole tree rebuild if app-config.mk changes
 # Use MOZ_BUILD_APP to make life easy
 ifeq (,$(wildcard $(topsrcdir)/$(MOZ_BUILD_APP)/app-config.mk))
 #Fail if normal means of finding app-config.mk does not work
 $(error Somehow we got included but we can't find ourselves...)
 else
 GLOBAL_DEPS += $(topsrcdir)/$(MOZ_BUILD_APP)/app-config.mk
 endif
-# don't use the toolkit download manager (yet)
-SUITE_USING_XPFE_DM = 1
-DEFINES += -DSUITE_USING_XPFE_DM=1
+
--- a/suite/browser/browser-prefs.js
+++ b/suite/browser/browser-prefs.js
@@ -75,24 +75,36 @@ pref("browser.chrome.favicons", false);
 pref("browser.chrome.image_icons.max_size", 1024);
 
 // 0 = never, 1 = when in cache, 2 = always
 pref("browser.chrome.load_toolbar_icons", 0);
 
 pref("browser.toolbars.showbutton.go",      false);
 pref("browser.toolbars.showbutton.search",  true);
 
+//XXXCallek sound is not implemented in new DLMGR yet
 pref("browser.download.progressDnldDialog.keepAlive", true); // keep the dnload progress dialog up after dnload is complete
 pref("browser.download.progressDnldDialog.enable_launch_reveal_buttons", true);
 pref("browser.download.progressDnlgDialog.dontAskForLaunch", false);
 pref("browser.download.finished_download_sound", false);
-pref("browser.download.finished_download_alert", false);
 pref("browser.download.finished_sound_url", "");
-pref("browser.download.autoDownload", false);
-pref("browser.download.lastLocation", true);
+pref("browser.download.useDownloadDir", false);
+pref("browser.download.folderList", 2);
+
+pref("browser.download.manager.showAlertOnComplete", true);
+pref("browser.download.manager.showAlertInterval", 2000);
+pref("browser.download.manager.retention", 2);
+pref("browser.download.manager.quitBehavior", 0);
+pref("browser.download.manager.addToRecentDocs", true);
+pref("browser.download.manager.scanWhenDone", true);
+pref("browser.download.manager.resumeOnWakeDelay", 10000);
+pref("browser.download.manager.flashCount", 2);
+pref("browser.download.manager.showWhenStarting", true);
+pref("browser.download.manager.focusWhenStarting", false);
+pref("browser.download.manager.closeWhenDone", false);
 
 // various default search settings
 pref("browser.search.defaulturl", "chrome://navigator-region/locale/region.properties");
 pref("browser.search.opensidebarsearchpanel", true);
 pref("browser.search.opentabforcontextsearch", false);
 pref("browser.search.last_search_category", "NC:SearchCategory?category=urn:search:category:1");
 pref("browser.search.mode", 0);
 // basic search popup constraint: minimum sherlock plugin version displayed
@@ -469,32 +481,31 @@ pref("browser.throbber.url","chrome://na
 // pref to control the alert notification 
 pref("alerts.slideIncrement", 1);
 pref("alerts.slideIncrementTime", 10);
 pref("alerts.totalOpenTime", 4000);
 
 // 0 opens the download manager
 // 1 opens a progress dialog
 // 2 and other values, no download manager, no progress dialog. 
-pref("browser.downloadmanager.behavior", 0);
+pref("browser.download.manager.behavior", 0);
 
 pref("privacy.popups.sound_enabled",              false);
 pref("privacy.popups.sound_type",                 1);
 pref("privacy.popups.sound_url",                  "");
 pref("privacy.popups.statusbar_icon_enabled",     true);
 pref("privacy.popups.prefill_whitelist",          false);
 pref("privacy.popups.remove_blacklist",           true);
 pref("privacy.popups.showBrowserMessage",         true);
 
 // sanitize (clear private data) options
-// XXX: turn on sanitize for downloads once we support toolkit' download manager
 pref("privacy.item.history",     true);
 pref("privacy.item.formdata",    true);
 pref("privacy.item.passwords",   false);
-pref("privacy.item.downloads",   false);
+pref("privacy.item.downloads",   true);
 pref("privacy.item.cookies",     false);
 pref("privacy.item.cache",       true);
 pref("privacy.item.sessions",    true);
 pref("privacy.item.offlineApps", false);
 
 pref("privacy.sanitize.sanitizeOnShutdown", false);
 pref("privacy.sanitize.promptOnSanitize", true);
 
@@ -522,17 +533,17 @@ pref("pfs.datasource.url", "https://pfs.
 pref("plugins.hide_infobar_for_missing_plugin", false);
 
 #ifdef XP_MACOSX
 // determines the behavior upon starting a download.
 //  0 - open the download manager
 //  1 - open a progress dialog
 //  2 - do nothing
 
-pref("browser.downloadmanager.behavior", 1);
+pref("browser.download.manager.behavior", 1);
 
 // Turn on click-and-hold contextual menus
 pref("ui.click_hold_context_menus", true);
 
 // Use a sheet instead of a popup window for the customize toolbar UI
 pref("toolbar.customization.usesheet", true);
 #endif
 
--- a/suite/browser/navigator.js
+++ b/suite/browser/navigator.js
@@ -222,17 +222,17 @@ function pageShowEventHandlers(event)
  * and if so, toggle the display of the 'save frame as' menu item.
  **/
 function getContentAreaFrameCount()
 {
   var saveFrameItem = document.getElementById("saveframe");
   if (!content || !content.frames.length || !isContentFrame(document.commandDispatcher.focusedWindow))
     saveFrameItem.setAttribute("hidden", "true");
   else {
-    var autoDownload = pref.getBoolPref("browser.download.autoDownload");
+    var autoDownload = pref.getBoolPref("browser.download.useDownloadDir");
     goSetMenuValue("saveframe", autoDownload ? "valueSave" : "valueSaveAs");
     saveFrameItem.removeAttribute("hidden");
   }
 }
 
 // When a content area frame is focused, update the focused frame URL
 function contentAreaFrameFocus()
 {
@@ -2487,17 +2487,17 @@ function SwitchDocumentDirection(aWindow
   aWindow.document.dir = (aWindow.document.dir == "ltr" ? "rtl" : "ltr");
 
   for (var run = 0; run < aWindow.frames.length; run++)
     SwitchDocumentDirection(aWindow.frames[run]);
 }
 
 function updateSavePageItems()
 {
-  var autoDownload = pref.getBoolPref("browser.download.autoDownload");
+  var autoDownload = pref.getBoolPref("browser.download.useDownloadDir");
   goSetMenuValue("savepage", autoDownload ? "valueSave" : "valueSaveAs");
 }
 
 function convertFromUnicode(charset, str)
 {
   try {
     var unicodeConverter = Components
        .classes["@mozilla.org/intl/scriptableunicodeconverter"]
--- a/suite/browser/viewsource.js
+++ b/suite/browser/viewsource.js
@@ -648,17 +648,17 @@ function BrowserSetForcedCharacterSet(aC
                             Components.interfaces.nsIDocCharset);
   docCharset.charset = aCharset;
   var PageLoader = getBrowser().webNavigation.QueryInterface(pageLoaderIface);
   PageLoader.loadPage(PageLoader.currentDescriptor, pageLoaderIface.DISPLAY_NORMAL);
 }
 
 function updateSavePageItems()
 {
-  var autoDownload = gPrefs.getBoolPref("browser.download.autoDownload");
+  var autoDownload = gPrefs.getBoolPref("browser.download.useDownloadDir");
   goSetMenuValue("savepage", autoDownload ? "valueSave" : "valueSaveAs");
 }
 
 function UpdateBackForwardCommands(aWebNavigation) {
   var backBroadcaster = document.getElementById("Browser:Back");
   var forwardBroadcaster = document.getElementById("Browser:Forward");
 
   var backDisabled = backBroadcaster.hasAttribute("disabled");
--- a/suite/common/contentAreaUtils.js
+++ b/suite/common/contentAreaUtils.js
@@ -16,16 +16,17 @@
  *
  * The Initial Developer of the Original Code is
  * Netscape Communications Corporation.
  * Portions created by the Initial Developer are Copyright (C) 1998
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Ben Goodger <ben@netscape.com> (Save File)
+ *   Justin Wood <Callek@gmail.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either of 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
@@ -318,17 +319,17 @@ const kSaveAsType_Text     = 2; // Save 
  * @param aContentType The caller-provided content-type to use
  * @param aShouldBypassCache If true, the document will always be refetched
  *        from the server
  * @param aFilePickerTitleKey Alternate title for the file picker
  * @param aChosenData If non-null this contains an instance of object AutoChosen
  *        (see below) which holds pre-determined data so that the user does not
  *        need to be prompted for a target filename.
  * @param aReferrer the referrer URI object (not URL string) to use, or null
-          if no referrer should be sent.
+ *        if no referrer should be sent.
  */
 function internalSave(aURL, aDocument, aDefaultFileName, aContentDisposition,
                       aContentType, aShouldBypassCache, aFilePickerTitleKey,
                       aChosenData, aReferrer)
 {
   // Note: aDocument == null when this code is used by save-link-as...
   var saveMode = GetSaveModeForContentType(aContentType);
   var isDocument = aDocument != null && saveMode != SAVEMODE_FILEONLY;
@@ -354,17 +355,17 @@ function internalSave(aURL, aDocument, a
       fileInfo: fileInfo,
       contentType: aContentType,
       saveMode: saveMode,
       saveAsType: saveAsType,
       file: file,
       fileURL: fileURL
     };
 
-    if (!poseFilePicker(fpParams))
+    if (!getTargetFile(fpParams))
       // If the method returned false this is because the user cancelled from
       // the save file picker dialog.
       return;
 
     saveAsType = fpParams.saveAsType;
     saveMode = fpParams.saveMode;
     file = fpParams.file;
     fileURL = fpParams.fileURL;
@@ -529,96 +530,117 @@ function initFileInfo(aFI, aURL, aURLCha
 /** 
  * Given the Filepicker Parameters (aFpP), show the file picker dialog,
  * prompting the user to confirm (or change) the fileName.
  * @param aFpP a structure (see definition in internalSave(...) method)
  *        containing all the data used within this method.
  * @return true if the user confirmed a filename in the picker; false if they
  *         dismissed the picker.
  */
-function poseFilePicker(aFpP)
+function getTargetFile(aFpP)
 {
+  var prefs = getPrefsBrowserDownload("browser.download.");
+  var useDownloadDir = prefs.getBoolPref("useDownloadDir");
   const nsILocalFile = Components.interfaces.nsILocalFile;
-  const kDownloadDirPref = "dir";
-
-  var branch = getPrefsBrowserDownload("browser.download.");
-  var dir = null;
 
-  // Try and pull in download directory pref
-  try {
-    dir = branch.getComplexValue(kDownloadDirPref, nsILocalFile);
-  } catch (e) {
-  }
+  // Default to the user's default downloads directory configured
+  // through download prefs.
+  var dlMgr = Components.classes["@mozilla.org/download-manager;1"]
+                        .getService(Components.interfaces.nsIDownloadManager);
+  var dir = dlMgr.userDownloadsDirectory;
+  var dirExists = dir && dir.exists();
 
-  var autoDownload = branch.getBoolPref("autoDownload");
-  if (autoDownload && dir && dir.exists()) {
-    dir.append(getNormalizedLeafName(aFpP.fileInfo.fileName, aFpP.fileInfo.fileExt));
+  if (useDownloadDir && dirExists) {
+    dir.append(getNormalizedLeafName(aFpP.fileInfo.fileName,
+                                     aFpP.fileInfo.fileExt));
     aFpP.file = uniqueFile(dir);
     return true;
   }
+  // Must Prompt
 
-  // Show the file picker that allows the user to confirm the target filename:
+  // Default to lastDir if we must prompt, and lastDir
+  // is configured and valid. Otherwise, keep the default of
+  // the user's default downloads directory.
+  if (!useDownloadDir) try {
+    var lastDir = prefs.getComplexValue("lastDir", nsILocalFile);
+    if (lastDir.exists()) {
+      dir = lastDir;
+      dirExists = true;
+    }
+  } catch(e) {}
+
+  if (!dirExists) {
+    // Default to desktop.
+    var fileLocator = Components.classes["@mozilla.org/file/directory_service;1"]
+                                .getService(Components.interfaces.nsIProperties);
+    dir = fileLocator.get("Desk", nsILocalFile);
+  }
+
   var fp = makeFilePicker();
   var titleKey = aFpP.fpTitleKey || "SaveLinkTitle";
   var bundle = getStringBundle();
   fp.init(window, bundle.GetStringFromName(titleKey),
           Components.interfaces.nsIFilePicker.modeSave);
 
-  try {
-    if (dir.exists())
-      fp.displayDirectory = dir;
-  } catch (e) {
-  }
-
+  fp.displayDirectory = dir;
   fp.defaultExtension = aFpP.fileInfo.fileExt;
   fp.defaultString = getNormalizedLeafName(aFpP.fileInfo.fileName,
                                            aFpP.fileInfo.fileExt);
   appendFiltersForContentType(fp, aFpP.contentType, aFpP.fileInfo.fileExt,
                               aFpP.saveMode);
 
   if (aFpP.isDocument) {
     try {
-      fp.filterIndex = branch.getIntPref("save_converter_index");
+      fp.filterIndex = prefs.getIntPref("save_converter_index");
     }
     catch (e) {
     }
   }
 
   if (fp.show() == Components.interfaces.nsIFilePicker.returnCancel || !fp.file)
     return false;
 
-  if (aFpP.isDocument) 
-    branch.setIntPref("save_converter_index", fp.filterIndex);
+  if (aFpP.isDocument)
+    prefs.setIntPref("save_converter_index", fp.filterIndex);
 
-  // Now that the user has had a chance to change the directory and/or filename,
-  // re-read those values...
-  if (branch.getBoolPref("lastLocation") || autoDownload) {
-    var directory = fp.file.parent.QueryInterface(nsILocalFile);
-    branch.setComplexValue(kDownloadDirPref, nsILocalFile, directory);
-  }
+  var directory = fp.file.parent.QueryInterface(nsILocalFile);
+  prefs.setComplexValue("lastDir", nsILocalFile, directory);
+
   fp.file.leafName = validateFileName(fp.file.leafName);
-
+  
   aFpP.saveAsType = fp.filterIndex;
   aFpP.file = fp.file;
   aFpP.fileURL = fp.fileURL;
   return true;
 }
 
 // Since we're automatically downloading, we don't get the file picker's
 // logic to check for existing files, so we need to do that here.
 //
-// Note - this code is identical to that in nsHelperAppDlg.js.
+// Note - this code is identical to that in
+//   mozilla/toolkit/mozapps/downloads/src/nsHelperAppDlg.js.in
 // If you are updating this code, update that code too! We can't share code
 // here since that code is called in a js component.
-
 function uniqueFile(aLocalFile)
 {
+  var collisionCount = 0;
   while (aLocalFile.exists()) {
-    parts = /(-\d+)?(\.[^.]+)?$/.test(aLocalFile.leafName);
-    aLocalFile.leafName = RegExp.leftContext + (RegExp.$1 - 1) + RegExp.$2;
+    collisionCount++;
+    if (collisionCount == 1) {
+      // Append "(2)" before the last dot in (or at the end of) the filename
+      // special case .ext.gz etc files so we don't wind up with .tar(2).gz
+      if (aLocalFile.leafName.match(/\.[^\.]{1,3}\.(gz|bz2|Z)$/i))
+        aLocalFile.leafName = aLocalFile.leafName.replace(/\.[^\.]{1,3}\.(gz|bz2|Z)$/i, "(2)$&");
+      else
+        aLocalFile.leafName = aLocalFile.leafName.replace(/(\.[^\.]*)?$/, "(2)$&");
+    }
+    else {
+      // replace the last (n) in the filename with (n+1)
+      aLocalFile.leafName = aLocalFile.leafName.replace(/^(.*\()\d+\)/, "$1" + (collisionCount + 1) + ")");
+    }
   }
   return aLocalFile;
 }
 
 // We have no DOM, and can only save the URL as is.
 const SAVEMODE_FILEONLY      = 0x00;
 // We have a DOM and can save as complete.
 const SAVEMODE_COMPLETE_DOM  = 0x01;
new file mode 100644
--- /dev/null
+++ b/suite/common/downloads/progressDialog.xul
@@ -0,0 +1,52 @@
+<?xml version="1.0"?>
+<!-- ***** BEGIN LICENSE BLOCK *****
+   - Version: MPL 1.1/GPL 2.0/LGPL 2.1
+   -
+   - The contents of this file are subject to the Mozilla Public License Version
+   - 1.1 (the "License"); you may not use this file except in compliance with
+   - the License. You may obtain a copy of the License at
+   - http://www.mozilla.org/MPL/
+   -
+   - Software distributed under the License is distributed on an "AS IS" basis,
+   - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+   - for the specific language governing rights and limitations under the
+   - License.
+   -
+   - The Original Code is the SeaMonkey internet suite code.
+   -
+   - The Initial Developer of the Original Code is
+   - the SeaMonkey project at mozilla.org.
+   - Portions created by the Initial Developer are Copyright (C) 2008
+   - the Initial Developer. All Rights Reserved.
+   -
+   - Contributor(s):
+   -   Justin Wood <Callek@gmail.com>
+   -
+   - 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
+   - decision by deleting the provisions above and replace them with the notice
+   - and other provisions required by the LGPL or the GPL. If you do not delete
+   - the provisions above, a recipient may use your version of this file under
+   - the terms of any one of the MPL, the GPL or the LGPL.
+   -
+   - ***** END LICENSE BLOCK ***** -->
+
+<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
+
+<!DOCTYPE window SYSTEM "chrome://communicator/locale/downloads/progressDialog.dtd">
+
+<dialog xmlns:html="http://www.w3.org/1999/xhtml"
+        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+        buttons="accept,cancel"
+        buttonlabelcancel="&cancelLabel;"
+        buttonlabelaccept="&acceptLabel;"
+        ondialogaccept='Components.classes["@mozilla.org/download-manager-ui;1"].getService(Components.interfaces.nsISuiteDownloadManagerUI).showManager();'
+        title="&progressTitle;"
+        width="40em;">
+  <description>&tempDescription;</description>
+</dialog>
--- a/suite/common/jar.mn
+++ b/suite/common/jar.mn
@@ -119,16 +119,17 @@ comm.jar:
    content/communicator/bookmarks/bookmarksTree.xml                 (bookmarks/bookmarksTree.xml)
    content/communicator/bookmarks/findBookmark.js                   (bookmarks/findBookmark.js)
    content/communicator/bookmarks/findBookmark.xul                  (bookmarks/findBookmark.xul)
    content/communicator/bookmarks/sortFolder.js                     (bookmarks/sortFolder.js)
    content/communicator/bookmarks/sortFolder.xul                    (bookmarks/sortFolder.xul)
    content/communicator/directory/directory.html                    (directory/directory.html)
    content/communicator/directory/directory.js                      (directory/directory.js)
    content/communicator/directory/directory.xul                     (directory/directory.xul)
+   content/communicator/downloads/progressDialog.xul                (downloads/progressDialog.xul)
    content/communicator/feeds/subscribe.xhtml                       (feeds/subscribe.xhtml)
    content/communicator/feeds/subscribe.js                          (feeds/subscribe.js)
    content/communicator/history/controller.js                       (history/controller.js)
    content/communicator/history/history.js                          (history/history.js)
    content/communicator/history/history.xul                         (history/history.xul)
    content/communicator/history/history-panel.xul                   (history/history-panel.xul)
    content/communicator/history/places.css                          (history/places.css)
    content/communicator/history/placesOverlay.xul                   (history/placesOverlay.xul)
@@ -151,18 +152,16 @@ comm.jar:
    content/communicator/pref/pref-advanced.js                       (pref/pref-advanced.js)
    content/communicator/pref/pref-advanced.xul                      (pref/pref-advanced.xul)
    content/communicator/pref/pref-appearance.js                     (pref/pref-appearance.js)
    content/communicator/pref/pref-appearance.xul                    (pref/pref-appearance.xul)
    content/communicator/pref/pref-applications.xul                  (pref/pref-applications.xul)
 *  content/communicator/pref/pref-applications.js                   (pref/pref-applications.js)
 *  content/communicator/pref/pref-applicationManager.js             (pref/pref-applicationManager.js)
    content/communicator/pref/pref-applicationManager.xul            (pref/pref-applicationManager.xul)
-# XXX: remove line below once we have a helper app dialog that doesn't need it (comes with toolkit download manager)
-   content/communicator/pref/pref-applications-edit.xul             (pref/pref-applications-edit.xul)
    content/communicator/pref/overrideHandler.js                     (pref/overrideHandler.js)
    content/communicator/pref/pref-cache.js                          (pref/pref-cache.js)
    content/communicator/pref/pref-cache.xul                         (pref/pref-cache.xul)
    content/communicator/pref/pref-colors.js                         (pref/pref-colors.js)
    content/communicator/pref/pref-colors.xul                        (pref/pref-colors.xul)
    content/communicator/pref/pref-content.xul                       (pref/pref-content.xul)
    content/communicator/pref/pref-cookies.js                        (pref/pref-cookies.js)
    content/communicator/pref/pref-cookies.xul                       (pref/pref-cookies.xul)
--- a/suite/common/nsContextMenu.js
+++ b/suite/common/nsContextMenu.js
@@ -351,17 +351,17 @@ nsContextMenu.prototype = {
         this.bgImageURL = "";
         this.possibleSpellChecking = false;
 
         // Remember the node that was clicked.
         this.target = node;
 
         this.autoDownload = Components.classes["@mozilla.org/preferences-service;1"]
                                       .getService(Components.interfaces.nsIPrefBranch)
-                                      .getBoolPref("browser.download.autoDownload");
+                                      .getBoolPref("browser.download.useDownloadDir");
 
         // Clear any old spellchecking items from the menu, this used to
         // be in the menu hiding code but wasn't getting called in all
         // situations. Here, we can ensure it gets cleaned up any time the
         // menu is shown. Note: must be before uninit because that clears the
         // internal vars
         InlineSpellCheckerUI.clearSuggestionsFromMenu();
         InlineSpellCheckerUI.clearDictionaryListFromMenu();
deleted file mode 100644
--- a/suite/common/pref/pref-applications-edit.xul
+++ /dev/null
@@ -1,478 +0,0 @@
-<?xml version="1.0"?>
-<!-- ***** BEGIN LICENSE BLOCK *****
- Version: MPL 1.1/GPL 2.0/LGPL 2.1
-
- The contents of this file are subject to the Mozilla Public License Version
- 1.1 (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
- http://www.mozilla.org/MPL/
-
- Software distributed under the License is distributed on an "AS IS" basis,
- WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- for the specific language governing rights and limitations under the
- License.
-
- The Original Code is Mozilla Communicator client code, released
- March 31, 1998.
-
- The Initial Developer of the Original Code is
- Netscape Communications Corporation.
- Portions created by the Initial Developer are Copyright (C) 1998-1999
- the Initial Developer. All Rights Reserved.
-
- Contributor(s):
-   Ben Goodger <ben@netscape.com>, original implementor
-
- Alternatively, the contents of this file may be used under the terms of
- either of 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
- decision by deleting the provisions above and replace them with the notice
- and other provisions required by the GPL or the LGPL. If you do not delete
- the provisions above, a recipient may use your version of this file under
- the terms of any one of the MPL, the GPL or the LGPL.
-
- ***** END LICENSE BLOCK ***** -->
-
-<?xml-stylesheet href="chrome://communicator/skin/"?>
-<?xml-stylesheet href="chrome://communicator/skin/prefpanels.css" type="text/css"?>
-
-<!DOCTYPE dialog SYSTEM "chrome://communicator/locale/pref/pref-applications-edit.dtd">
-
-<dialog id="pickAppHandler"
-        style="width: 30em;"
-        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
-        title="&editType.label;"
-        newtitle="&newType.label;"
-        onload="Startup();"
-        ondialogaccept="return onAccept();">
-
-    <stringbundle id="bundle_prefApplications"
-                  src="chrome://communicator/locale/pref/pref-applications.properties"/>
-    <stringbundle id="bundle_Brand" src="chrome://branding/locale/brand.properties"/>
-
-<script type="application/x-javascript" src="chrome://global/content/dialogOverlay.js"/>
-<script type="application/x-javascript" src="chrome://communicator/content/pref/overrideHandler.js"/>
-  <script type="application/x-javascript">
-  <![CDATA[
-    var gExtension        = null;
-    var gMIMEField        = null;
-    var gHandlerGroup     = null;
-    var gAppPath          = null;
-    var gAskBeforeOpen    = null;
-    var gDescription      = null;
-    var gPrefApplicationsBundle = null;
-
-    var gOldMIME          = null;
-    var gOldDesc          = null;
-    var gOldExtensions   = null;
-
-    const nsIMIMEInfo = Components.interfaces.nsIMIMEInfo;
-    
-    function Startup()
-    {     
-      gDescription      = document.getElementById("description");
-      gExtension        = document.getElementById("extension");
-      gMIMEField        = document.getElementById("mimeType");
-      gHandlerGroup     = document.getElementById("handler");
-      gAppPath          = document.getElementById("appPath");
-      gAskBeforeOpen    = document.getElementById("askBeforeOpen");
-        
-      gPrefApplicationsBundle = document.getElementById("bundle_prefApplications");
-
-      // Set values for radio items to nsIMIMEInfo constants
-      var rSaveToDisk         = document.getElementById("saveToDisk");
-      var rUseHelperApp       = document.getElementById("useHelperApp");
-      var rUseSystemDefault   = document.getElementById("useSystemDefault");
-      rSaveToDisk.value       = nsIMIMEInfo.saveToDisk;
-      rUseHelperApp.value     = nsIMIMEInfo.useHelperApp;
-      rUseSystemDefault.value = nsIMIMEInfo.useSystemDefault;
-      
-      var handlerInfo = window.arguments[0];
-
-      // Test to see if this dialog is being called from the helper app dialog.
-      if ( !( "URI" in handlerInfo ) ) {
-        // Arg is an nsHelperAppDlg object in this case.
-        window.gHelperAppDlg = window.arguments[0];
-        var info = window.arguments[0].mLauncher.MIMEInfo;
-        
-        // Update entry (without dialog showing).
-        try {
-          updateEntry(info);
-        } catch(e) { dump("updateEntry failed: " + e + "\n"); }
-        
-        // Close the dialog.
-        window.close();
-        
-        // Done.
-        return;
-      }
-      
-      // Default to true in case the preference cannot be retrieved
-      var forceAlwaysAsk = true;
-      try {
-        var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
-        var prefBranch = prefService.getBranch("browser.helperApps.alwaysAsk.");
-        forceAlwaysAsk = prefBranch.getBoolPref("force");
-      } catch(e) {
-        dump("forceAlwaysAsk defaulting to true since preference couldn't be opened\n");
-      }
-        
-      if ( !handlerInfo.URI )
-      {
-        // Opening for "New Type".
-        document.title = document.documentElement.getAttribute("newtitle");
-        
-        // Initialize some stuff to blank for new types.
-        gOldMIME = gOldDesc = gOldExtensions = "";
-        
-        // Make default "use system default."
-        gHandlerGroup.value = nsIMIMEInfo.useSystemDefault;
-        
-        // Always ask box default depends on pref.
-        gAskBeforeOpen.checked = forceAlwaysAsk;
-        gAskBeforeOpen.disabled = forceAlwaysAsk;
-        
-        // Put focus on mime type field.
-        gMIMEField.focus();
-        
-        // Size/position the dialog.
-        sizeToContent();
-        window.moveToAlertPosition();
-        
-        // Avoid the normal "edit" case code.
-        return;
-      }
-
-      gExtension.setAttribute("value", handlerInfo.extensions);
-      gMIMEField.value = handlerInfo.mimeType;
-      gOldMIME = handlerInfo.mimeType;
-      gOldDesc = handlerInfo.description;
-      gOldExtensions = handlerInfo.extensions;
-      
-      // figure out how this type is handled
-      var data = nsIMIMEInfo.saveToDisk;
-      if (handlerInfo.saveToDisk == "true")
-        data = nsIMIMEInfo.saveToDisk;
-      else if (handlerInfo.useSystemDefault == "true")
-        data = nsIMIMEInfo.useSystemDefault;
-      else 
-        data = nsIMIMEInfo.useHelperApp;
-        
-      gHandlerGroup.value = data;
-      doEnabling();
-      
-      var appPath = handlerInfo.appPath;
-      if (appPath != undefined)
-        gAppPath.value = appPath;
-
-      if (forceAlwaysAsk)
-      {
-        gAskBeforeOpen.checked = true;
-        gAskBeforeOpen.disabled = true;
-      }
-      else
-      {
-        gAskBeforeOpen.checked = handlerInfo.alwaysAsk == "true" ? true : false;
-      }
-      
-      gDescription.setAttribute("value", handlerInfo.description);
-      var ext;
-      var posOfFirstSpace = handlerInfo.extensions.indexOf(" ");
-      if (posOfFirstSpace > -1)
-        ext = handlerInfo.extensions.substr(0, posOfFirstSpace);
-      else
-        ext = handlerInfo.extensions;
-      var imageString = "moz-icon://" + "dummy." + ext.toLowerCase() + "?size=32&contentType=" + handlerInfo.mimeType;
-      document.getElementById("contentTypeImage").setAttribute("src", imageString);
-      
-      // If opened from helper app dialog, then focus goes to radio buttons.
-      if ( "gHelperAppDlg" in window )
-        gHandlerGroup.focus();
-      else
-        gMIMEField.focus();
-
-      sizeToContent();
-      moveToAlertPosition();
-    }
-    
-    function doEnabling()
-    {
-    }
-    
-    function chooseApp()
-    {
-      var filePicker = Components.classes["@mozilla.org/filepicker;1"].createInstance();
-      if (filePicker)
-        filePicker = filePicker.QueryInterface(Components.interfaces.nsIFilePicker);
-      if (filePicker) {
-        const FP = Components.interfaces.nsIFilePicker
-        var windowTitle = gPrefApplicationsBundle.getString("chooseHandler");
-        var programsFilter = gPrefApplicationsBundle.getString("programsFilter");
-        filePicker.init(window, windowTitle, FP.modeOpen);
-        if (navigator.platform == "Win32")
-          filePicker.appendFilter(programsFilter, "*.exe; *.com");
-        else
-          filePicker.appendFilters(FP.filterAll);
-        if ( filePicker.show() == FP.returnOK ) {
-          var file = filePicker.file.QueryInterface(Components.interfaces.nsILocalFile);
-          gAppPath.value = file.path;
-          gAppPath.select();
-          selectAppRadio();
-        }
-      }
-    }
-    
-    function selectAppRadio()
-    {
-      if (gHandlerGroup.value != nsIMIMEInfo.useHelperApp) 
-        gHandlerGroup.value = nsIMIMEInfo.useHelperApp;
-      doEnabling();
-    }
-
-    var gDS = null;
-    function getDS()
-    {
-      const mimeTypes = "UMimTyp";
-      var fileLocator = Components.classes["@mozilla.org/file/directory_service;1"].getService();
-      if (fileLocator)
-        fileLocator = fileLocator.QueryInterface(Components.interfaces.nsIProperties);
-      var file = fileLocator.get(mimeTypes, Components.interfaces.nsIFile);
-      var ioService = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
-      var fileHandler = ioService.getProtocolHandler("file").QueryInterface(Components.interfaces.nsIFileProtocolHandler);
-      gDS = gRDF.GetDataSource(fileHandler.getURLSpecFromFile(file));
-    }
-
-    function updateEntry(info)
-    {
-      // Initialize data source.
-      getDS();
-      
-      // Get mime type from which we can construct a HandlerInfo...
-      var mimeType = info.MIMEType.toLowerCase();
-      
-      // Create HandlerOverride and populate it.
-      var entry = new HandlerOverride(MIME_URI(mimeType));
-      entry.mUpdateMode = mimeHandlerExists(mimeType);
-      entry.mimeType    = mimeType;
-      entry.isEditable  = true;
-      entry.alwaysAsk   = info.alwaysAskBeforeHandling;
-      
-      // If not updating (i.e., a newly encountered mime type),
-      // then update extension list and description.
-      if (!entry.mUpdateMode) {
-        var extEnumerator = info.getFileExtensions();
-        while (extEnumerator.hasMore()) {
-            entry.addExtension(extEnumerator.getNext());
-        }
-        entry.description = info.description;
-        entry.appDisplayName = "";
-      }
-      
-      if (info.preferredAction == nsIMIMEInfo.saveToDisk) {
-        entry.saveToDisk = true;
-        if (!entry.mUpdateMode) {
-          // Creating a new entry, set path.
-          entry.appPath = "";
-        }
-      } else if (info.preferredAction == nsIMIMEInfo.useSystemDefault ||
-                 info.preferredApplicationHandler == null) {
-        entry.useSystemDefault = true;
-        if (!entry.mUpdateMode) {
-          // Creating a new entry, set path.
-          entry.appPath = "";
-        }
-      } else {
-        entry.saveToDisk       = false;
-        entry.useSystemDefault = false;
-        entry.handleInternal   = false;
-        entry.appPath = info.preferredApplicationHandler.executable.path;
-        entry.appDisplayName = info.preferredApplicationHandler.name;
-      }
-      
-      // Do RDF magic.
-      entry.buildLinks();
-      
-      // flush the ds to disk.
-      var remoteDS = gDS.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
-      if (remoteDS)
-        remoteDS.Flush();
-    }
-
-    function onAccept()
-    {
-      // Validate input.
-      if ( !checkInput() ) {
-        return false;
-      }
-      getDS();
-      gMIMEField.value = gMIMEField.value.toLowerCase();
-      // Get the promptservice, we will need it
-      var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
-      // Check if Mozilla can handle this type internally, in which case
-      // an entry would have no effect
-      try {
-        var webNavigationInfo =
-	    Components.classes["@mozilla.org/webnavigation-info;1"]
-              .getService(Components.interfaces.nsIWebNavigationInfo);
-        if (webNavigationInfo.isTypeSupported(gMIMEField.value, null)) {
-          var brandBundle = document.getElementById("bundle_Brand");
-          var text = gPrefApplicationsBundle.getString("canHandleInternally");
-          text = text.replace(/%brand%/g, brandBundle.getString("brandShortName"));
-          if (promptService.confirmEx(
-              window,
-              gPrefApplicationsBundle.getString("canHandleInternallyTitle"),
-              text,
-               (Components.interfaces.nsIPromptService.BUTTON_POS_1 *
-                Components.interfaces.nsIPromptService.BUTTON_TITLE_IS_STRING) |
-               (Components.interfaces.nsIPromptService.BUTTON_POS_0 *
-                Components.interfaces.nsIPromptService.BUTTON_TITLE_CANCEL),
-              null,
-              gPrefApplicationsBundle.getString("canHandleInternallyContinue"),
-              null,
-              null,
-              {}
-              ) == 0)
-          return false;
-        }
-      }
-      catch (ex) {}
-      // figure out if this mime type already exists. 
-      if (gMIMEField.value != gOldMIME) {
-        var exists = mimeHandlerExists(gMIMEField.value);
-        if (exists) {
-          var titleMsg = gPrefApplicationsBundle.getString("handlerExistsTitle");
-          var dialogMsg = gPrefApplicationsBundle.getString("handlerExists");
-          dialogMsg = dialogMsg.replace(/%mime%/g, gMIMEField.value);
-          var replaceMsg = gPrefApplicationsBundle.getString("handlerExistsReplace");
-          var flags = ((promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0) +
-                       (promptService.BUTTON_TITLE_CANCEL * promptService.BUTTON_POS_1) +
-                       promptService.BUTTON_POS_1_DEFAULT);
-          var btn = promptService.confirmEx(window, titleMsg, dialogMsg, flags, replaceMsg, null, null, null, {value: 0});
-          if (btn == 1)
-            return true;
-          
-          // delete mimetype we're overwriting
-          if (gMIMEField.value)
-            removeOverride(gMIMEField.value);
-        }
-      }
-      
-      if (gOldMIME && gOldMIME != gMIMEField.value)
-        removeOverride(gOldMIME); // delete old handler
-
-      // now save the information
-      var handlerInfo = new HandlerOverride(MIME_URI(gMIMEField.value));
-      handlerInfo.mUpdateMode = (gOldMIME == gMIMEField.value);
-      handlerInfo.mimeType = gMIMEField.value;
-    
-      // set description, editable, and extensions
-      handlerInfo.isEditable = true;
-      handlerInfo.description = gDescription.value;
-      handlerInfo.clearExtensions();
-      var extensions = gExtension.value.toLowerCase().split(" ");
-      for (var i = 0; i < extensions.length; i++) {
-        var currExtension = extensions[i];
-        handlerInfo.addExtension(currExtension);
-      }
-    
-      // other info we need to set (not reflected in UI)
-      if (gHandlerGroup.value == nsIMIMEInfo.useHelperApp) {
-        handlerInfo.appPath = gAppPath.value;
-        handlerInfo.setHandlerProcedure("saveToDisk", "false");
-        handlerInfo.setHandlerProcedure("useSystemDefault", "false");
-        handlerInfo.setHandlerProcedure("handleInternal", "false");
-      }
-      else if (gHandlerGroup.value == nsIMIMEInfo.saveToDisk)
-        handlerInfo.saveToDisk = true;
-      else if (gHandlerGroup.value == nsIMIMEInfo.useSystemDefault)
-        handlerInfo.useSystemDefault = true;
-      else
-        handlerInfo.handleInternal = true;
-    
-      handlerInfo.alwaysAsk = gAskBeforeOpen.checked;
-    
-      // need to make the following dynamic to track changes. otherwise the 
-      // app pretty name remains the same.
-      // better still, find a way to XP dynamically discover the pretty name of the app
-      // from the OS. 
-      var file = Components.classes["@mozilla.org/file/local;1"].createInstance();
-      if (file)
-        file = file.QueryInterface(Components.interfaces.nsILocalFile);
-      if (file) {
-        try {
-          file.initWithPath(gAppPath.value);
-          handlerInfo.appDisplayName = file.leafName;
-        }
-        catch(e) {
-          handlerInfo.appDisplayName = gAppPath.value;    
-        }
-      }
-
-      // do the rest of the work (ugly yes, but it works)
-      handlerInfo.buildLinks();
-      
-      // flush the ds to disk.   
-      var remoteDS = gDS.QueryInterface(Components.interfaces.nsIRDFRemoteDataSource);
-      if (remoteDS)
-        remoteDS.Flush();
-      
-      window.opener.gUpdateTypeRV = true;
-      return true;
-    }
-  ]]>
-  </script>
-  <vbox>
-  <hbox align="center">
-    <image id="contentTypeImage"/>
-    <grid flex="1">
-      <columns>
-        <column/>
-        <column flex="1"/>
-      </columns>
-      <rows>
-        <row align="center">
-          <label value="&mimetype.label;" accesskey="&mimetype.accesskey;" control="mimeType"/>
-          <textbox id="mimeType"/>
-        </row>
-        <row align="center">
-          <label value="&description.label;" accesskey="&description.accesskey;" control="description"/>
-          <textbox id="description" crop="right" flex="1"/>
-        </row>
-        <row align="center">
-          <label value="&extension.label;" accesskey="&extension.accesskey;" control="extension"/>
-          <textbox id="extension"/>
-        </row>
-      </rows>
-    </grid>
-  </hbox>
-  
-  <separator class="thin"/>
-
-  <groupbox>
-    <caption label="&handling.label;"/>
-    <radiogroup id="handler">
-      <radio id="useSystemDefault" label="&useDefault.label;" accesskey="&useDefault.accesskey;" oncommand="doEnabling();"/>
-      <hbox align="center">
-        <radio id="useHelperApp" label="&application.label;" accesskey="&application.accesskey;" oncommand="doEnabling();"/>
-        <textbox id="appPath" flex="1" onchange="selectAppRadio();"/>
-        <button label="&browse.label;" accesskey="&browse.accesskey;"
-                oncommand="chooseApp();"/>
-      </hbox>
-      <radio id="saveToDisk" label="&saveToDisk.label;" accesskey="&saveToDisk.accesskey;" oncommand="doEnabling();"/>
-    </radiogroup>
-    
-  </groupbox>              
-
-  <separator class="thin"/>
-
-  <hbox align="center">
-    <checkbox id="askBeforeOpen" label="&askBeforeOpen.label;" accesskey="&askBeforeOpen.accesskey;"/>         
-  </hbox>  
-  </vbox>
-
-</dialog>
-        
--- a/suite/common/pref/pref-security.js
+++ b/suite/common/pref/pref-security.js
@@ -35,17 +35,16 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 function Startup()
 {
   updateClearNowButtonLabel();
-  document.getElementById("privacy.item.downloads").disabled = true; // XXX: as long as we aren't using toolkit's download manager
 }
 
 /**
  * Sets the label of the "Clear Now..." button according to the
  * privacy.sanitize.promptOnSanitize preference. Read valueFromPreferences to
  * only change the button when the underlying pref changes, since in the case
  * of instantApply=false, the call to clearPrivateDataNow would result in the
  * dialog appearing when the user just unchecked the "Ask me" checkbox.
--- a/suite/common/public/Makefile.in
+++ b/suite/common/public/Makefile.in
@@ -44,12 +44,13 @@ include $(DEPTH)/config/autoconf.mk
 
 MODULE		= suitecommon
 XPIDL_MODULE	= suitecommon
 
 XPIDLSRCS = \
 	nsISuiteGlue.idl \
 	nsISessionStartup.idl \
 	nsISessionStore.idl \
+	nsISuiteDownloadManagerUI.idl \
 	$(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
new file mode 100644
--- /dev/null
+++ b/suite/common/public/nsISuiteDownloadManagerUI.idl
@@ -0,0 +1,50 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is the SeaMonkey internet suite code.
+ *
+ * The Initial Developer of the Original Code is
+ * the SeaMonkey project at mozilla.org.
+ * Portions created by the Initial Developer are Copyright (C) 2008
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Justin Wood <Callek@gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of 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
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+#include "nsISupports.idl"
+#include "nsIDownloadManagerUI.idl"
+
+[scriptable, uuid(b2180611-e56e-4831-9770-15a53aacb36a)]
+interface nsISuiteDownloadManagerUI : nsIDownloadManagerUI
+{
+  void showManager([optional] in nsIInterfaceRequestor aWindowContext,
+                    [optional] in unsigned long aID,
+                    [optional] in short aReason);
+  void showProgress([optional] in nsIInterfaceRequestor aWindowContext,
+                     [optional] in unsigned long aID,
+                     [optional] in short aReason);
+};
--- a/suite/common/src/Makefile.in
+++ b/suite/common/src/Makefile.in
@@ -43,16 +43,17 @@ VPATH		= @srcdir@
 include $(DEPTH)/config/autoconf.mk
 
 MODULE		= suitecommon
 
 EXTRA_COMPONENTS = \
 	nsAboutCertError.js \
 	nsAboutSessionRestore.js \
 	nsSessionStartup.js \
+	nsSuiteDownloadManagerUI.js \
 	nsSuiteGlue.js \
 	$(NULL)
 
 EXTRA_PP_COMPONENTS = \
 	nsSessionStore.js \
 	$(NULL)
 
 include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/suite/common/src/nsSuiteDownloadManagerUI.js
@@ -0,0 +1,208 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is the SeaMonkey internet suite code.
+ *
+ * The Initial Developer of the Original Code is
+ * the SeaMonkey project at mozilla.org.
+ * Portions created by the Initial Developer are Copyright (C) 2008
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *   Justin Wood <Callek@gmail.com>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of 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
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
+
+////////////////////////////////////////////////////////////////////////////////
+//// Constants
+
+const Cc = Components.classes;
+const Ci = Components.interfaces;
+const DOWNLOAD_MANAGER_URL = "chrome://mozapps/content/downloads/downloads.xul";
+const PREF_FLASH_COUNT = "browser.download.manager.flashCount";
+const PREF_DM_BEHAVIOR = "browser.download.manager.behavior";
+
+////////////////////////////////////////////////////////////////////////////////
+//// nsDownloadManagerUI class
+
+function nsDownloadManagerUI() {}
+
+nsDownloadManagerUI.prototype = {
+  classDescription: "Used to show the Download Manager's UI to the user",
+  classID: Components.ID("08bbb4af-7bff-4b16-8ff7-d62f3ec5aa0c"),
+  contractID: "@mozilla.org/download-manager-ui;1",
+
+  //////////////////////////////////////////////////////////////////////////////
+  //// nsIDownloadManagerUI
+
+  show: function show(aWindowContext, aID, aReason)
+  {
+    var behavior = 0;
+    if (aReason != Ci.nsIDownloadManagerUI.REASON_USER_INTERACTED) {
+      try {
+        var prefs = Cc["@mozilla.org/preferences-service;1"].
+                    getService(Ci.nsIPrefBranch);
+        behavior = prefs.getIntPref(PREF_DM_BEHAVIOR);
+      } catch (e) { }
+    }
+
+    switch (behavior) {
+      case 0:
+        this.showManager(aWindowContext, aID, aReason);
+        break;
+      case 1:
+        this.showProgress(aWindowContext, aID, aReason);
+    }
+
+    return; // No UI for behavior >= 2
+  },
+
+  get visible() {
+    return this.recentWindow != null;
+  },
+
+  getAttention: function getAttention()
+  {
+    if (!this.visible)
+      throw Cr.NS_ERROR_UNEXPECTED;
+
+    var prefs = Cc["@mozilla.org/preferences-service;1"].
+                getService(Ci.nsIPrefBranch);
+    // This preference may not be set, so defaulting to two.
+    var flashCount = 2;
+    try {
+      flashCount = prefs.getIntPref(PREF_FLASH_COUNT);
+    } catch (e) { }
+
+    this.recentWindow.getAttentionWithCycleCount(flashCount);
+  },
+
+  //////////////////////////////////////////////////////////////////////////////
+  //// nsDownloadManagerUI
+
+  get recentWindow() {
+    var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
+             getService(Ci.nsIWindowMediator);
+    return wm.getMostRecentWindow("Download:Manager");
+  },
+
+  //////////////////////////////////////////////////////////////////////////////
+  //// nsISuiteDownloadManagerUI
+  showManager: function showManager(aWindowContext, aID, aReason)
+  {
+    // First we see if it is already visible
+    let window = this.recentWindow;
+    if (window) {
+      window.focus();
+
+      // If we are being asked to show again, with a user interaction reason,
+      // set the appropriate variable.
+      if (aReason == Ci.nsIDownloadManagerUI.REASON_USER_INTERACTED)
+        window.gUserInteracted = true;
+      return;
+    }
+
+    let parent = null;
+    // We try to get a window to use as the parent here.  If we don't have one,
+    // the download manager will close immediately after opening if the pref
+    // browser.download.manager.closeWhenDone is set to true.
+    try {
+      if (aWindowContext)
+        parent = aWindowContext.getInterface(Ci.nsIDOMWindow);
+    } catch (e) { /* it's OK to not have a parent window */ }
+
+    // We pass the download manager and the nsIDownload we want selected (if any)
+    var params = Cc["@mozilla.org/array;1"].
+                 createInstance(Ci.nsIMutableArray);
+
+    // Don't fail if our passed in ID is invalid
+    var download = null;
+    try {
+      let dm = Cc["@mozilla.org/download-manager;1"].
+               getService(Ci.nsIDownloadManager);
+      download = dm.getDownload(aID);
+    } catch (ex) {}
+    params.appendElement(download, false);
+
+    // Pass in the reason as well
+    let reason = Cc["@mozilla.org/supports-PRInt16;1"].
+                 createInstance(Ci.nsISupportsPRInt16);
+    reason.data = aReason;
+    params.appendElement(reason, false);
+
+    var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
+             getService(Ci.nsIWindowWatcher);
+    ww.openWindow(parent,
+                  DOWNLOAD_MANAGER_URL,
+                  null,
+                  "all,dialog=no",
+                  params);
+  },
+
+  showProgress: function showProgress(aWindowContext, aID, aReason)
+  {
+    var params = Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);
+
+    // Don't fail if our passed in ID is invalid
+    var download = null;
+    try {
+      let dm = Cc["@mozilla.org/download-manager;1"].
+               getService(Ci.nsIDownloadManager);
+      download = dm.getDownload(aID);
+    } catch (ex) {}
+    params.appendElement(download, false);
+
+    // Pass in the reason as well
+    let reason = Cc["@mozilla.org/supports-PRInt16;1"].
+                 createInstance(Ci.nsISupportsPRInt16);
+    reason.data = aReason;
+    params.appendElement(reason, false);
+
+    var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
+             getService(Ci.nsIWindowWatcher);
+    ww.openWindow(null,
+                  "chrome://communicator/content/downloads/progressDialog.xul",
+                  null,
+                  "chrome,titlebar,centerscreen,minimizable=yes,dialog=no",
+                  params);
+  },
+  //////////////////////////////////////////////////////////////////////////////
+  //// nsISupports
+
+  QueryInterface: XPCOMUtils.generateQI([Ci.nsIDownloadManagerUI,
+                                         Ci.nsISuiteDownloadManagerUI])
+};
+
+////////////////////////////////////////////////////////////////////////////////
+//// Module
+
+let components = [nsDownloadManagerUI];
+
+function NSGetModule(compMgr, fileSpec)
+{
+  return XPCOMUtils.generateModule(components);
+}
--- a/suite/common/src/nsSuiteGlue.js
+++ b/suite/common/src/nsSuiteGlue.js
@@ -123,16 +123,18 @@ SuiteGlue.prototype = {
     osvr.removeObserver(this, "quit-application-requested");
     osvr.removeObserver(this, "quit-application-granted");
     osvr.removeObserver(this, "session-save");
  },
 
   // profile startup handler (contains profile initialization routines)
   _onProfileStartup: function()
   {
+    this._updatePrefs();
+
     Sanitizer.checkAndSanitize();
 
     const prefSvc = Components.classes["@mozilla.org/preferences-service;1"]
                               .getService(Components.interfaces.nsIPrefBranch2);
     if (prefSvc.prefHasUserValue("privacy.sanitize.didShutdownSanitize")) {
       prefSvc.clearUserPref("privacy.sanitize.didShutdownSanitize");
       // We need to persist this preference change, since we want to
       // check it at next app start even if the browser exits abruptly
@@ -257,16 +259,49 @@ SuiteGlue.prototype = {
             prefBranch.setIntPref("browser.startup.page", 3);
           }
         }
         break;
       }
     }
   },
 
+  _updatePrefs: function()
+  {
+    // Get the preferences service
+    var prefs = Components.classes["@mozilla.org/preferences-service;1"]
+                          .getService(Components.interfaces.nsIPrefService)
+                          .getBranch(null);
+    const PREF_INVALID = Components.interfaces.nsIPrefBranch.PREF_INVALID;
+    if (prefs.getPrefType("browser.download.dir") == PREF_INVALID ||
+        prefs.getPrefType("browser.download.lastDir") != PREF_INVALID)
+      return; //Do nothing if .dir does not exist, or if it exists and lastDir does not
+
+    try {
+      prefs.setComplexValue("browser.download.lastDir",
+                            Components.interfaces.nsILocalFile,
+                            prefs.getComplexValue("browser.download.dir",
+                                                  Components.interfaces.nsILocalFile));
+    } catch (ex) {
+      // Ensure that even if we don't end up migrating to a lastDir that we
+      // don't attempt another update. This will throw when QI'ed to
+      // nsILocalFile, but it does fallback gracefully.
+      prefs.setCharPref("browser.download.lastDir", "");
+    }
+
+    try {
+      prefs.setBoolPref("browser.download.useDownloadDir",
+                        prefs.getBoolPref("browser.download.autoDownload");
+    } catch (ex) {}
+
+    try {
+      prefs.setIntPref("browser.download.manager.behavior",
+                       prefs.getIntPref("browser.downloadmanager.behavior"));
+    } catch (ex) {}
+  },
 
   // ------------------------------
   // public nsISuiteGlue members
   // ------------------------------
 
   sanitize: function(aParentWindow)
   {
     // call the Sanitizer object's sanitize, which might return errors
--- a/suite/common/tasksOverlay.js
+++ b/suite/common/tasksOverlay.js
@@ -16,16 +16,17 @@
  *
  * The Initial Developer of the Original Code is
  * Netscape Communications Corporation.
  * Portions created by the Initial Developer are Copyright (C) 1998
  * the Initial Developer. All Rights Reserved.
  *
  * Contributor(s):
  *   Peter Annema <disttsc@bart.nl>
+ *   Justin Wood <Callek@gmail.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either of 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
@@ -63,28 +64,24 @@ function ExpirePassword()
   // Expires the master password
   Components.classes["@mozilla.org/security/sdr;1"]
             .getService(Components.interfaces.nsISecretDecoderRing)
             .logoutAndTeardown();
 }
 
 function toDownloadManager()
 {
-  var dlmgr = Components.classes['@mozilla.org/download-manager;1'].getService();
-  dlmgr = dlmgr.QueryInterface(Components.interfaces.nsIDownloadManager);
-
-  var windowMediator = Components.classes['@mozilla.org/appshell/window-mediator;1'].getService();
-  windowMediator = windowMediator.QueryInterface(nsIWindowMediator);
-
-  var dlmgrWindow = windowMediator.getMostRecentWindow("Download:Manager");
-  if (dlmgrWindow) {
-    dlmgrWindow.focus();
-  }
-  else {
-    dlmgr.open(window, null);
+  //Ported extensions may only implement the Basic toolkit Interface
+  //and not our progress dialogs.
+  var dlUI = Components.classes["@mozilla.org/download-manager-ui;1"]
+                       .getService(Components.interfaces.nsIDownloadManagerUI);
+  if (dlUI instanceof Components.interfaces.nsISuiteDownloadManagerUI) {
+    dlUI.showManager(window);
+  } else {
+    dlUI.show(window);
   }
 }
   
 function toEM( aPane )
 {
   var theEM = Components.classes["@mozilla.org/appshell/window-mediator;1"]
                         .getService(Components.interfaces.nsIWindowMediator)
                         .getMostRecentWindow("Extension:Manager");
--- a/suite/installer/removed-files.in
+++ b/suite/installer/removed-files.in
@@ -58,16 +58,18 @@ extensions/talkback@mozilla.org/InstallD
 #ifdef XP_MACOSX
 updater.app/Contents/MacOS/updater.ini
 #endif
 components/airbag.xpt
 components/@DLL_PREFIX@bookmark@DLL_SUFFIX@
 components/bookmarks.xpt
 components/chatzilla-service.js
 components/crashreporter.xpt
+components/downloadmanager.xpt
+components/nsDownloadProgressListener.js
 components/@DLL_PREFIX@myspell@DLL_SUFFIX@
 components/nsCloseAllWindows.js
 components/nsDictionary.js
 components/nsInterfaceInfoToIDL.js
 components/nsLDAPPrefsService.js
 components/nsKillAll.js
 components/nsResetPref.js
 components/nsScriptableIO.js
--- a/suite/installer/unix/packages
+++ b/suite/installer/unix/packages
@@ -113,17 +113,17 @@ bin/components/dom_storage.xpt
 bin/components/dom_stylesheets.xpt
 bin/components/dom_svg.xpt
 bin/components/dom_threads.xpt
 bin/components/dom_traversal.xpt
 bin/components/dom_views.xpt
 bin/components/dom_xbl.xpt
 bin/components/dom_xpath.xpt
 bin/components/dom_xul.xpt
-bin/components/downloadmanager.xpt
+bin/components/downloads.xpt
 bin/components/editor.xpt
 bin/components/embed_base.xpt
 bin/components/libembedcomponents.so
 bin/components/extensions.xpt
 bin/components/exthandler.xpt
 bin/components/exthelper.xpt
 bin/components/fastfind.xpt
 bin/components/feeds.xpt
@@ -260,31 +260,31 @@ bin/components/nsAboutSessionRestore.js
 bin/components/nsAddonRepository.js
 bin/components/nsBadCertHandler.js
 bin/components/nsBlocklistService.js
 bin/components/nsBrowserContentHandler.js
 bin/components/nsComposerCmdLineHandler.js
 bin/components/nsContentDispatchChooser.js
 bin/components/nsContentPrefService.js
 bin/components/nsDefaultCLH.js
-bin/components/nsDownloadProgressListener.js
 bin/components/nsExtensionManager.js
 bin/components/nsFilePicker.js
 bin/components/nsLivemarkService.js
 bin/components/nsLoginInfo.js
 bin/components/nsLoginManager.js
 bin/components/nsLoginManagerPrompter.js
 bin/components/nsHandlerService.js
 bin/components/nsHelperAppDlg.js
 bin/components/nsPlacesDBFlush.js
 bin/components/nsProgressDialog.js
 bin/components/nsProxyAutoConfig.js
 bin/components/nsSessionStartup.js
 bin/components/nsSessionStore.js
 bin/components/nsSidebar.js
+bin/components/nsSuiteDownloadManagerUI.js
 bin/components/nsSuiteGlue.js
 bin/components/nsTaggingService.js
 bin/components/nsTypeAheadFind.js
 bin/components/nsTryToClose.js
 bin/components/nsUpdateService.js
 bin/components/nsURLFormatter.js
 bin/components/nsWebHandlerApp.js
 bin/components/pluginGlue.js
--- a/suite/installer/windows/packages
+++ b/suite/installer/windows/packages
@@ -120,17 +120,17 @@ bin\components\dom_sidebar.xpt
 bin\components\dom_storage.xpt
 bin\components\dom_stylesheets.xpt
 bin\components\dom_threads.xpt
 bin\components\dom_traversal.xpt
 bin\components\dom_views.xpt
 bin\components\dom_xbl.xpt
 bin\components\dom_xpath.xpt
 bin\components\dom_xul.xpt
-bin\components\downloadmanager.xpt
+bin\components\downloads.xpt
 bin\components\editor.xpt
 bin\components\embed_base.xpt
 bin\components\embedcomponents.dll
 bin\components\extensions.xpt
 bin\components\exthandler.xpt
 bin\components\exthelper.xpt
 bin\components\fastfind.xpt
 bin\components\feeds.xpt
@@ -277,16 +277,17 @@ bin\components\nsPlacesDBFlush.js
 #ifdef MOZILLA_1_9_1_BRANCH
 bin\components\nsPostUpdateWin.js
 #endif
 bin\components\nsProxyAutoConfig.js
 bin\components\nsSessionStartup.js
 bin\components\nsSessionStore.js
 bin\components\nsSetDefault.js
 bin\components\nsSidebar.js
+bin\components\nsSuiteDownloadManagerUI.js
 bin\components\nsSuiteGlue.js
 bin\components\nsTaggingService.js
 bin\components\nsTypeAheadFind.js
 bin\components\nsTryToClose.js
 bin\components\nsUpdateService.js
 bin\components\nsURLFormatter.js
 bin\components\nsWebHandlerApp.js
 bin\components\pluginGlue.js
@@ -429,17 +430,16 @@ bin\res\fonts\mathfontMath4.properties
 bin\res\fonts\mathfontMTExtra.properties
 bin\res\fonts\mathfontPUA.properties
 bin\res\fonts\mathfontSymbol.properties
 
 
 ; download progress
 bin\components\nsProgressDialog.js
 bin\components\nsHelperAppDlg.js
-bin\components\nsDownloadProgressListener.js
 
 ; spellcheck
 bin\components\spellchk.dll
 bin\components\spellchecker.xpt
 
 ; svg
 bin\gksvggdiplus.dll
 bin\res\svg.css
new file mode 100644
--- /dev/null
+++ b/suite/locales/en-US/chrome/common/downloads/progressDialog.dtd
@@ -0,0 +1,41 @@
+<!-- ***** BEGIN LICENSE BLOCK *****
+   - Version: MPL 1.1/GPL 2.0/LGPL 2.1
+   -
+   - The contents of this file are subject to the Mozilla Public License Version
+   - 1.1 (the "License"); you may not use this file except in compliance with
+   - the License. You may obtain a copy of the License at
+   - http://www.mozilla.org/MPL/
+   -
+   - Software distributed under the License is distributed on an "AS IS" basis,
+   - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+   - for the specific language governing rights and limitations under the
+   - License.
+   -
+   - The Original Code is the SeaMonkey internet suite code.
+   -
+   - The Initial Developer of the Original Code is
+   - the SeaMonkey project at mozilla.org.
+   - Portions created by the Initial Developer are Copyright (C) 2008
+   - the Initial Developer. All Rights Reserved.
+   -
+   - Contributor(s):
+   -   Justin Wood <Callek@gmail.com>
+   -
+   - 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
+   - decision by deleting the provisions above and replace them with the notice
+   - and other provisions required by the LGPL or the GPL. If you do not delete
+   - the provisions above, a recipient may use your version of this file under
+   - the terms of any one of the MPL, the GPL or the LGPL.
+   -
+   - ***** END LICENSE BLOCK ***** -->
+
+<!ENTITY cancelLabel          "Close">
+<!ENTITY acceptLabel          "Open Download Manager">
+<!ENTITY progressTitle        "Download in Progress…">
+<!ENTITY tempDescription      "We're sorry, but progress dialogs in downloads are currently not implemented. Your download has started.">
--- a/suite/locales/jar.mn
+++ b/suite/locales/jar.mn
@@ -42,16 +42,17 @@
   locale/@AB_CD@/communicator/aboutSessionRestore.dtd                       (%chrome/common/aboutSessionRestore.dtd)
   locale/@AB_CD@/communicator/bookmarks/addBookmark.dtd                     (%chrome/common/bookmarks/addBookmark.dtd)
   locale/@AB_CD@/communicator/bookmarks/bm-props.dtd                        (%chrome/common/bookmarks/bm-props.dtd)
   locale/@AB_CD@/communicator/bookmarks/bookmarks.dtd                       (%chrome/common/bookmarks/bookmarks.dtd)
   locale/@AB_CD@/communicator/bookmarks/bookmarks.properties                (%chrome/common/bookmarks/bookmarks.properties)
   locale/@AB_CD@/communicator/bookmarks/findBookmark.dtd                    (%chrome/common/bookmarks/findBookmark.dtd)
   locale/@AB_CD@/communicator/bookmarks/sortFolder.dtd                      (%chrome/common/bookmarks/sortFolder.dtd)
   locale/@AB_CD@/communicator/directory/directory.dtd                       (%chrome/common/directory/directory.dtd)
+  locale/@AB_CD@/communicator/downloads/progressDialog.dtd                  (%chrome/common/downloads/progressDialog.dtd)
   locale/@AB_CD@/communicator/help/cert_dialog_help.xhtml                   (%chrome/common/help/cert_dialog_help.xhtml)
   locale/@AB_CD@/communicator/help/certs_help.xhtml                         (%chrome/common/help/certs_help.xhtml)
   locale/@AB_CD@/communicator/help/certs_prefs_help.xhtml                   (%chrome/common/help/certs_prefs_help.xhtml)
   locale/@AB_CD@/communicator/help/composer_help.xhtml                      (%chrome/common/help/composer_help.xhtml)
   locale/@AB_CD@/communicator/help/cs_nav_prefs_advanced.xhtml              (%chrome/common/help/cs_nav_prefs_advanced.xhtml)
   locale/@AB_CD@/communicator/help/cs_nav_prefs_appearance.xhtml            (%chrome/common/help/cs_nav_prefs_appearance.xhtml)
   locale/@AB_CD@/communicator/help/cs_nav_prefs_navigator.xhtml             (%chrome/common/help/cs_nav_prefs_navigator.xhtml)
   locale/@AB_CD@/communicator/help/cs_priv_prefs_popup.xhtml                (%chrome/common/help/cs_priv_prefs_popup.xhtml)
@@ -132,18 +133,16 @@
   locale/@AB_CD@/communicator/pref/prefutilities.properties                 (%chrome/common/pref/prefutilities.properties)
   locale/@AB_CD@/communicator/pref/preferences.dtd                          (%chrome/common/pref/preferences.dtd)
   locale/@AB_CD@/communicator/pref/pref-advanced.dtd                        (%chrome/common/pref/pref-advanced.dtd)
   locale/@AB_CD@/communicator/pref/pref-appearance.dtd                      (%chrome/common/pref/pref-appearance.dtd)
   locale/@AB_CD@/communicator/pref/pref-applications.dtd                    (%chrome/common/pref/pref-applications.dtd)
   locale/@AB_CD@/communicator/pref/pref-applications.properties             (%chrome/common/pref/pref-applications.properties)
   locale/@AB_CD@/communicator/pref/pref-applicationManager.dtd              (%chrome/common/pref/pref-applicationManager.dtd)
   locale/@AB_CD@/communicator/pref/pref-applicationManager.properties       (%chrome/common/pref/pref-applicationManager.properties)
-# XXX: remove line below once we have a helper app dialog that doesn't need it (comes with toolkit download manager)
-  locale/@AB_CD@/communicator/pref/pref-applications-edit.dtd               (%chrome/common/pref/pref-applications-edit.dtd)
   locale/@AB_CD@/communicator/pref/pref-cache.dtd                           (%chrome/common/pref/pref-cache.dtd)
   locale/@AB_CD@/communicator/pref/pref-colors.dtd                          (%chrome/common/pref/pref-colors.dtd)
   locale/@AB_CD@/communicator/pref/pref-content.dtd                         (%chrome/common/pref/pref-content.dtd)
   locale/@AB_CD@/communicator/pref/pref-cookies.dtd                         (%chrome/common/pref/pref-cookies.dtd)
   locale/@AB_CD@/communicator/pref/pref-download.dtd                        (%chrome/common/pref/pref-download.dtd)
   locale/@AB_CD@/communicator/pref/pref-fonts.dtd                           (%chrome/common/pref/pref-fonts.dtd)
   locale/@AB_CD@/communicator/pref/pref-history.dtd                         (%chrome/common/pref/pref-history.dtd)
   locale/@AB_CD@/communicator/pref/pref-http.dtd                            (%chrome/common/pref/pref-http.dtd)
--- a/suite/modules/Sanitizer.jsm
+++ b/suite/modules/Sanitizer.jsm
@@ -210,31 +210,26 @@ var Sanitizer = {
         var formHistory = Components.classes["@mozilla.org/satchel/form-history;1"]
                                     .getService(Components.interfaces.nsIFormHistory2);
         return formHistory.hasEntries;
       }
     },
 
     downloads: {
       clear: function() {
-        /* XXX: commented out as long as we aren't using toolkit's download manager
         var dlMgr = Components.classes["@mozilla.org/download-manager;1"]
                               .getService(Components.interfaces.nsIDownloadManager);
         dlMgr.cleanUp();
-        */
       },
 
-      canClear: false
-      /* XXX: use code below (instead of above line) once we are using toolkit's download manager
       get canClear() {
         var dlMgr = Components.classes["@mozilla.org/download-manager;1"]
                               .getService(Components.interfaces.nsIDownloadManager);
         return dlMgr.canCleanUp;
       }
-      */
     },
 
     passwords: {
       clear: function() {
         var pwmgr = Components.classes["@mozilla.org/login-manager;1"]
                               .getService(Components.interfaces.nsILoginManager);
         pwmgr.removeAllLogins();
       },
--- a/suite/modules/test/browser_sanitizer.js
+++ b/suite/modules/test/browser_sanitizer.js
@@ -169,17 +169,16 @@ var sanTests = {
       return this.check();
     },
 
     check: function() {
       return this.forms.entryExists("Sanitizer", "Foo");
     }
   },
 
-  /* XXX: commented out as long as we aren't using toolkit's download manager
   downloads: {
     desc: "Download",
     setup: function() {
       var ios = Components.classes["@mozilla.org/network/io-service;1"]
                           .getService(Components.interfaces.nsIIOService);
       var uri = ios.newURI("http://sanitizer.test/", null, null);
       var file = Components.classes["@mozilla.org/file/directory_service;1"]
                            .getService(Components.interfaces.nsIProperties)
@@ -201,17 +200,16 @@ var sanTests = {
       var dl = null;
       try {
         dl = this.dm.getDownload(this.dl.id);
       } catch(ex) {}
 
       return (dl && dl.displayName == "Sanitizer!");
     }
   },
-  */
 
   passwords: {
     desc: "Login manager",
     setup: function() {
       this.pm = Components.classes["@mozilla.org/login-manager;1"]
                           .getService(Components.interfaces.nsILoginManager);
       var info = Components.Constructor("@mozilla.org/login-manager/loginInfo;1",
                                         Components.interfaces.nsILoginInfo, "init");
--- a/suite/profile/migration/src/nsNetscapeProfileMigratorBase.cpp
+++ b/suite/profile/migration/src/nsNetscapeProfileMigratorBase.cpp
@@ -335,48 +335,16 @@ nsNetscapeProfileMigratorBase::SetCookie
   if (aTransform->prefHasValue)
     return aBranch->SetIntPref("network.cookie.cookieBehavior",
                                aTransform->intValue == 3 ? 0 :
                                aTransform->intValue);
 
   return NS_OK;
 }
 
-// XXX Bug 381157 When suite uses Toolkit's DM backend, we need to
-// activate this code.
-#ifdef SUITE_USING_TOOLKIT_DM
-nsresult
-nsNetscapeProfileMigratorBase::SetDownloadManager(PrefTransform* aTransform,
-                                                  nsIPrefBranch* aBranch)
-{
-  if (aTransform->prefHasValue) {
-    nsresult rv = NS_OK;
-
-    // Seamonkey's download manager uses a single pref to control behavior:
-    // 0 - show download manager window
-    // 1 - show individual progress dialogs
-    // 2 - show nothing
-    //
-    // Firefox has only a download manager window, but it can behave like
-    // a progress dialog, thus:
-    // 0 || 1  -> show downloads window when a download starts
-    // 2       -> don't show anything when a download starts
-    // 1       -> close the downloads window as if it were a progress
-    // window when downloads complete.
-    //
-    rv |= aBranch->SetBoolPref("browser.download.manager.showWhenStarting",
-                               aTransform->intValue != 2);
-    rv |= aBranch->SetBoolPref("browser.download.manager.closeWhenDone",
-                               aTransform->intValue == 1);
-    return rv;
-  }
-  return NS_OK;
-}
-#endif
-
 ///////////////////////////////////////////////////////////////////////////////
 // General Utility Methods
 
 nsresult
 nsNetscapeProfileMigratorBase::GetSourceProfile(const PRUnichar* aProfile)
 {
   PRUint32 count;
   mProfileNames->GetLength(&count);
--- a/suite/profile/migration/src/nsNetscapeProfileMigratorBase.h
+++ b/suite/profile/migration/src/nsNetscapeProfileMigratorBase.h
@@ -123,22 +123,16 @@ public:
   static nsresult SetString(PrefTransform* aTransform, nsIPrefBranch* aBranch);
   static nsresult GetBool(PrefTransform* aTransform, nsIPrefBranch* aBranch);
   static nsresult SetBool(PrefTransform* aTransform, nsIPrefBranch* aBranch);
   static nsresult GetInt(PrefTransform* aTransform, nsIPrefBranch* aBranch);
   static nsresult SetInt(PrefTransform* aTransform, nsIPrefBranch* aBranch);
   static nsresult SetFile(PrefTransform* aTransform, nsIPrefBranch* aBranch);
   static nsresult SetImage(PrefTransform* aTransform, nsIPrefBranch* aBranch);
   static nsresult SetCookie(PrefTransform* aTransform, nsIPrefBranch* aBranch);
-  // XXX Bug 381157 When suite uses Toolkit's DM backend, we need to
-  // activate this code.
-#ifdef SUITE_USING_TOOLKIT_DM
-  static nsresult SetDownloadManager(PrefTransform* aTransform,
-                                     nsIPrefBranch* aBranch);
-#endif
 
 protected:
   // This function is designed to be overriden by derived classes so that
   // the required profile data for the specific application can be obtained.
   virtual nsresult FillProfileDataFromRegistry() = 0;
 
   // General Utility Methods
   nsresult GetSourceProfile(const PRUnichar* aProfile);
--- a/suite/profile/migration/src/nsSeamonkeyProfileMigrator.cpp
+++ b/suite/profile/migration/src/nsSeamonkeyProfileMigrator.cpp
@@ -275,34 +275,18 @@ nsSeamonkeyProfileMigrator::PrefTransfor
 
   MAKESAMETYPEPREFTRANSFORM("browser.anchor_color",                    String),
   MAKESAMETYPEPREFTRANSFORM("browser.active_color",                    String),
   MAKESAMETYPEPREFTRANSFORM("browser.backspace_action",                Int),
   MAKESAMETYPEPREFTRANSFORM("browser.blink_allowed",                   Bool),
   MAKESAMETYPEPREFTRANSFORM("browser.cache.disk.capacity",             Int),
   MAKESAMETYPEPREFTRANSFORM("browser.cache.check_doc_frequency",       Int),
 
-  // XXX Bug 381157 When suite uses Toolkit's DM backend, we need to
-  // activate this code.
-#ifdef SUITE_USING_TOOLKIT_DM
-  MAKEPREFTRANSFORM("browser.downloadmanager.behavior", 0, Int,
-                    DownloadManager),
-#else
-  // Note browser.download.progressDnldDialog.* prefs are covered below.
+  // Note browser.download.* prefs are covered below.
   MAKESAMETYPEPREFTRANSFORM("browser.downloadmanager.behavior",        Int),
-  MAKESAMETYPEPREFTRANSFORM("browser.download.save_converter_index",   Int),
-  MAKESAMETYPEPREFTRANSFORM("browser.download.autoDownload",           Bool),
-  MAKESAMETYPEPREFTRANSFORM("browser.download.lastLocation",           Bool),
-  MAKESAMETYPEPREFTRANSFORM("browser.download.finished_download_alert", Bool),
-  MAKESAMETYPEPREFTRANSFORM("browser.download.finished_download_sound", Bool),
-  MAKEPREFTRANSFORM("browser.download.finished_sound_url", 0, String, File),
-#endif
-  MAKESAMETYPEPREFTRANSFORM("browser.download.dir",                    String),
-  MAKESAMETYPEPREFTRANSFORM("browser.download.show_plugins_in_list",   Bool),
-  MAKESAMETYPEPREFTRANSFORM("browser.download.hide_plugins_without_extensions", Bool),
 
   MAKESAMETYPEPREFTRANSFORM("browser.enable_automatic_image_resizing", Bool),
   MAKESAMETYPEPREFTRANSFORM("browser.fixup.alternate.enabled",         Bool),
   MAKESAMETYPEPREFTRANSFORM("browser.fixup.alternate.prefix",          String),
   MAKESAMETYPEPREFTRANSFORM("browser.fixup.alternate.suffix",          String),
   MAKESAMETYPEPREFTRANSFORM("browser.fixup.hide_user_pass",            Bool),
   MAKESAMETYPEPREFTRANSFORM("browser.frames.enabled",                  Bool),
   MAKESAMETYPEPREFTRANSFORM("browser.history.grouping",                String),
@@ -632,21 +616,17 @@ nsSeamonkeyProfileMigrator::TransformPre
     "mail.identity.",
     "mail.server.",
     "ldap_2.",
     "accessibility.",
     "applications.",
     "bidi.",
     "browser.chrome.",
     "browser.display.",
-  // XXX Bug 381157 When suite does not use Toolkit's DM backend,
-  // we need to activate this code.
-#ifndef SUITE_USING_TOOLKIT_DM
-    "browser.download.progressDnldDialog.",
-#endif
+    "browser.download.",
     "browser.search.",
     "browser.tabs.",
     "browser.urlbar.",
     "dom.",
     "editor.",
     "extensions.irc.",
     "extensions.venkman.",
     "font.",