Bug 475830 - Downloads should end up in My Documents/Downloads for winxp
authorShawn Wilsher <sdwilsh@shawnwilsher.com>
Thu, 29 Jan 2009 13:24:41 -0500
changeset 24399 8e03c785ee07808d8015b6eea8ab7a8b4d76d235
parent 24398 01c42e286b4c7065a1724ba81753214f2d1eaa2b
child 24400 bf337d3b5347f44a2569eec87bbd02480a4cf35d
push id5025
push usersdwilsh@shawnwilsher.com
push dateThu, 29 Jan 2009 18:27:51 +0000
treeherdermozilla-central@8e03c785ee07 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs475830
milestone1.9.2a1pre
Bug 475830 - Downloads should end up in My Documents/Downloads for winxp Per discussion with beltzner on irc. r=gavin
toolkit/components/downloads/src/nsDownloadManager.cpp
--- a/toolkit/components/downloads/src/nsDownloadManager.cpp
+++ b/toolkit/components/downloads/src/nsDownloadManager.cpp
@@ -1253,17 +1253,17 @@ nsDownloadManager::GetDefaultDownloadsDi
      do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   // OSX:
   // Safari download folder or Desktop/Downloads
   // Vista:
   // Downloads
   // XP/2K:
-  // Desktop/Downloads
+  // My Documents/Downloads
   // Linux:
   // XDG user dir spec, with a fallback to Home/Downloads
 
   nsXPIDLString folderName;
   mBundle->GetStringFromName(NS_LITERAL_STRING("downloadsFolder").get(),
                              getter_Copies(folderName));
 
 #if defined (XP_MACOSX)
@@ -1306,21 +1306,27 @@ nsDownloadManager::GetDefaultDownloadsDi
      do_GetService(NS_SYSTEMINFO_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   PRInt32 version;
   NS_NAMED_LITERAL_STRING(osVersion, "version");
   rv = infoService->GetPropertyAsInt32(osVersion, &version);
   NS_ENSURE_SUCCESS(rv, rv);
   if (version < 6) { // XP/2K
+    // First get "My Documents"
+    rv = dirService->Get(NS_WIN_PERSONAL_DIR,
+                         NS_GET_IID(nsILocalFile),
+                         getter_AddRefs(downloadDir));
+    NS_ENSURE_SUCCESS(rv, rv);
+
     rv = downloadDir->Append(folderName);
     NS_ENSURE_SUCCESS(rv, rv);
 
-    // This could be the first time we are creating the downloads folder on the
-    // desktop, so make sure it exists.
+    // This could be the first time we are creating the downloads folder in My
+    // Documents, so make sure it exists.
     PRBool exists;
     rv = downloadDir->Exists(&exists);
     NS_ENSURE_SUCCESS(rv, rv);
     if (!exists) {
       rv = downloadDir->Create(nsIFile::DIRECTORY_TYPE, 0755);
       NS_ENSURE_SUCCESS(rv, rv);
     }
   }