michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: const Cc = Components.classes; michael@0: const Ci = Components.interfaces; michael@0: const Cu = Components.utils; michael@0: michael@0: const WEBAPP_REGISTRY_DIR = "WebappRegD"; michael@0: const NS_APP_CHROME_DIR_LIST = "AChromDL"; michael@0: michael@0: Cu.import("resource://gre/modules/FileUtils.jsm"); michael@0: Cu.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: Cu.import("resource://webapprt/modules/WebappRT.jsm"); michael@0: Cu.import("resource://gre/modules/Services.jsm"); michael@0: michael@0: function DirectoryProvider() {} michael@0: michael@0: DirectoryProvider.prototype = { michael@0: classID: Components.ID("{e1799fda-4b2f-4457-b671-e0641d95698d}"), michael@0: michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsIDirectoryServiceProvider, michael@0: Ci.nsIDirectoryServiceProvider2]), michael@0: michael@0: getFile: function(prop, persistent) { michael@0: if (prop == WEBAPP_REGISTRY_DIR) { michael@0: let dir = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile); michael@0: dir.initWithPath(WebappRT.config.registryDir); michael@0: return dir; michael@0: } michael@0: michael@0: // We return null to show failure instead of throwing an error, michael@0: // which works with the way the interface is called (per bug 529077). michael@0: return null; michael@0: }, michael@0: michael@0: getFiles: function(prop, persistent) { michael@0: if (prop == NS_APP_CHROME_DIR_LIST) { michael@0: return { michael@0: _done: false, michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsISimpleEnumerator]), michael@0: hasMoreElements: function() { michael@0: return !this._done; michael@0: }, michael@0: getNext: function() { michael@0: this._done = true; michael@0: return FileUtils.getDir("AppRegD", ["chrome"], false); michael@0: } michael@0: }; michael@0: } michael@0: michael@0: return null; michael@0: }, michael@0: }; michael@0: michael@0: this.NSGetFactory = XPCOMUtils.generateNSGetFactory([DirectoryProvider]);