comparison tests/41701d2c0341.diff @ 10:7ae60d2ff1c2

commitwatcher/agent.py mozbasewatcher.py tests/41701d2c0341.diff
author Jeff Hammel <jhammel@mozilla.com>
date Sat, 28 Sep 2013 05:10:14 -0700
parents
children
comparison
equal deleted inserted replaced
9:08dd6fbbec3a 10:7ae60d2ff1c2
1
2 # HG changeset patch
3 # User Raymond Lee <raymond@raysquare.com>
4 # Date 1380236746 -28800
5 # Node ID 41701d2c03414fb308a4233f5f69a0416008bf9c
6 # Parent a00aba84b699ea26bc3e90428938124d8dae6d26
7 Bug 875731 - Replace callers of nsIDownloadManager.usersDownloadsDirectory with Downloads.getUserDownloadsDirectory mobile/andriod/. r=mfinkle
8
9 diff --git a/mobile/android/components/HelperAppDialog.js b/mobile/android/components/HelperAppDialog.js
10 --- a/mobile/android/components/HelperAppDialog.js
11 +++ b/mobile/android/components/HelperAppDialog.js
12 @@ -8,16 +8,21 @@ const Cu = Components.utils;
13 const Cr = Components.results;
14
15 const PREF_BD_USEDOWNLOADDIR = "browser.download.useDownloadDir";
16 const URI_GENERIC_ICON_DOWNLOAD = "drawable://alert_download";
17
18 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
19 Cu.import("resource://gre/modules/Services.jsm");
20
21 +XPCOMUtils.defineLazyModuleGetter(this, "Downloads",
22 + "resource://gre/modules/Downloads.jsm");
23 +XPCOMUtils.defineLazyModuleGetter(this, "Task",
24 + "resource://gre/modules/Task.jsm");
25 +
26 // -----------------------------------------------------------------------
27 // HelperApp Launcher Dialog
28 // -----------------------------------------------------------------------
29
30 function HelperAppLauncherDialog() { }
31
32 HelperAppLauncherDialog.prototype = {
33 classID: Components.ID("{e9d277a0-268a-4ec2-bb8c-10fdf3e44611}"),
34 @@ -25,25 +30,26 @@ HelperAppLauncherDialog.prototype = {
35
36 show: function hald_show(aLauncher, aContext, aReason) {
37 // Save everything by default
38 aLauncher.MIMEInfo.preferredAction = Ci.nsIMIMEInfo.useSystemDefault;
39 aLauncher.saveToDisk(null, false);
40 },
41
42 promptForSaveToFile: function hald_promptForSaveToFile(aLauncher, aContext, aDefaultFile, aSuggestedFileExt, aForcePrompt) {
43 - // Retrieve the user's default download directory
44 - let dnldMgr = Cc["@mozilla.org/download-manager;1"].getService(Ci.nsIDownloadManager);
45 - let defaultFolder = dnldMgr.userDownloadsDirectory;
46 + return Task.spawn(function() {
47 + // Retrieve the user's default download directory
48 + let defaultFolder = yield Downloads.getPreferredDownloadsDirectory();
49
50 - try {
51 - file = this.validateLeafName(defaultFolder, aDefaultFile, aSuggestedFileExt);
52 - } catch (e) { }
53 + try {
54 + file = this.validateLeafName(defaultFolder, aDefaultFile, aSuggestedFileExt);
55 + } catch (e) { }
56
57 - return file;
58 + throw new Task.Result(file);
59 + }.bind(this));
60 },
61
62 validateLeafName: function hald_validateLeafName(aLocalFile, aLeafName, aFileExt) {
63 if (!(aLocalFile && this.isUsableDirectory(aLocalFile)))
64 return null;
65
66 // Remove any leading periods, since we don't want to save hidden files
67 // automatically.
68