|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
|
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 const Cc = Components.classes; |
|
6 const Ci = Components.interfaces; |
|
7 const Cu = Components.utils; |
|
8 |
|
9 const WEBAPP_REGISTRY_DIR = "WebappRegD"; |
|
10 const NS_APP_CHROME_DIR_LIST = "AChromDL"; |
|
11 |
|
12 Cu.import("resource://gre/modules/FileUtils.jsm"); |
|
13 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
|
14 Cu.import("resource://webapprt/modules/WebappRT.jsm"); |
|
15 Cu.import("resource://gre/modules/Services.jsm"); |
|
16 |
|
17 function DirectoryProvider() {} |
|
18 |
|
19 DirectoryProvider.prototype = { |
|
20 classID: Components.ID("{e1799fda-4b2f-4457-b671-e0641d95698d}"), |
|
21 |
|
22 QueryInterface: XPCOMUtils.generateQI([Ci.nsIDirectoryServiceProvider, |
|
23 Ci.nsIDirectoryServiceProvider2]), |
|
24 |
|
25 getFile: function(prop, persistent) { |
|
26 if (prop == WEBAPP_REGISTRY_DIR) { |
|
27 let dir = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile); |
|
28 dir.initWithPath(WebappRT.config.registryDir); |
|
29 return dir; |
|
30 } |
|
31 |
|
32 // We return null to show failure instead of throwing an error, |
|
33 // which works with the way the interface is called (per bug 529077). |
|
34 return null; |
|
35 }, |
|
36 |
|
37 getFiles: function(prop, persistent) { |
|
38 if (prop == NS_APP_CHROME_DIR_LIST) { |
|
39 return { |
|
40 _done: false, |
|
41 QueryInterface: XPCOMUtils.generateQI([Ci.nsISimpleEnumerator]), |
|
42 hasMoreElements: function() { |
|
43 return !this._done; |
|
44 }, |
|
45 getNext: function() { |
|
46 this._done = true; |
|
47 return FileUtils.getDir("AppRegD", ["chrome"], false); |
|
48 } |
|
49 }; |
|
50 } |
|
51 |
|
52 return null; |
|
53 }, |
|
54 }; |
|
55 |
|
56 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([DirectoryProvider]); |