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 michael@0: * file, 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: michael@0: Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: michael@0: // ----------------------------------------------------------------------- michael@0: // Directory Provider for special browser folders and files michael@0: // ----------------------------------------------------------------------- michael@0: michael@0: const NS_APP_CACHE_PARENT_DIR = "cachePDir"; michael@0: michael@0: function DirectoryProvider() {} michael@0: michael@0: DirectoryProvider.prototype = { michael@0: classID: Components.ID("{ef0f7a87-c1ee-45a8-8d67-26f586e46a4b}"), michael@0: michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsIDirectoryServiceProvider]), michael@0: michael@0: getFile: function(prop, persistent) { michael@0: if (prop == NS_APP_CACHE_PARENT_DIR) { michael@0: let dirsvc = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties); michael@0: let profile = dirsvc.get("ProfD", Ci.nsIFile); michael@0: michael@0: let sysInfo = Cc["@mozilla.org/system-info;1"].getService(Ci.nsIPropertyBag2); michael@0: let device = sysInfo.get("device"); michael@0: switch (device) { michael@0: default: michael@0: return profile; michael@0: } michael@0: } michael@0: michael@0: // We are retuning null to show failure instead for throwing an error. The michael@0: // interface is called quite a bit and throwing an error is noisy. Returning michael@0: // null works with the way the interface is called [see bug 529077] michael@0: return null; michael@0: } michael@0: }; michael@0: michael@0: this.NSGetFactory = XPCOMUtils.generateNSGetFactory([DirectoryProvider]); michael@0: