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/. */
5 const Cc = Components.classes;
6 const Ci = Components.interfaces;
7 const Cu = Components.utils;
9 const WEBAPP_REGISTRY_DIR = "WebappRegD";
10 const NS_APP_CHROME_DIR_LIST = "AChromDL";
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");
17 function DirectoryProvider() {}
19 DirectoryProvider.prototype = {
20 classID: Components.ID("{e1799fda-4b2f-4457-b671-e0641d95698d}"),
22 QueryInterface: XPCOMUtils.generateQI([Ci.nsIDirectoryServiceProvider,
23 Ci.nsIDirectoryServiceProvider2]),
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);
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).
37 getFiles: function(prop, persistent) {
38 if (prop == NS_APP_CHROME_DIR_LIST) {
41 QueryInterface: XPCOMUtils.generateQI([Ci.nsISimpleEnumerator]),
42 hasMoreElements: function() {
47 return FileUtils.getDir("AppRegD", ["chrome"], false);
56 this.NSGetFactory = XPCOMUtils.generateNSGetFactory([DirectoryProvider]);