-// Copyright (c) 2008-2011 by Kris Maglione <maglione.k at Gmail>
+// Copyright (c) 2008-2012 Kris Maglione <maglione.k at Gmail>
//
// This work is licensed for reuse under an MIT license. Details are
// given in the LICENSE.txt file included with this file.
-/* use strict */
+"use strict";
try {
var global = this;
-Components.utils.import("resource://dactyl/bootstrap.jsm");
defineModule("services", {
- exports: ["services"]
-}, this);
+ exports: ["PrivateBrowsingUtils", "services"]
+});
+
+try {
+ var { PrivateBrowsingUtils } = Cu.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
+}
+catch (e) {}
/**
* A lazily-instantiated XPCOM class and service cache.
this.add("appShell", "@mozilla.org/appshell/appShellService;1", "nsIAppShellService");
this.add("appStartup", "@mozilla.org/toolkit/app-startup;1", "nsIAppStartup");
this.add("bookmarks", "@mozilla.org/browser/nav-bookmarks-service;1", "nsINavBookmarksService");
- this.add("bootstrap", "@dactyl.googlecode.com/base/bootstrap");
this.add("browserSearch", "@mozilla.org/browser/search-service;1", "nsIBrowserSearchService");
this.add("cache", "@mozilla.org/network/cache-service;1", "nsICacheService");
this.add("charset", "@mozilla.org/charset-converter-manager;1", "nsICharsetConverterManager");
this.addClass("Xmlhttp", "@mozilla.org/xmlextras/xmlhttprequest;1", [], "open");
this.addClass("XPathEvaluator", "@mozilla.org/dom/xpath-evaluator;1", "nsIDOMXPathEvaluator");
this.addClass("XMLDocument", "@mozilla.org/xml/xml-document;1", ["nsIDOMXMLDocument", "nsIDOMNodeSelector"]);
+ this.addClass("XMLSerializer","@mozilla.org/xmlextras/xmlserializer;1", ["nsIDOMSerializer"]);
this.addClass("ZipReader", "@mozilla.org/libjar/zip-reader;1", "nsIZipReader", "open", false);
this.addClass("ZipWriter", "@mozilla.org/zipwriter;1", "nsIZipWriter", "open", false);
},
reinit: function () {},
- _create: function (name, args) {
+ _create: function _create(name, args) {
try {
var service = this.services[name];
}
return res;
}
- catch (e if service.quiet !== false) {
+ catch (e) {
+ if (service.quiet === false)
+ throw e.stack ? e : Error(e);
+
if (typeof util !== "undefined")
util.reportError(e);
else
* @param {string} meth The name of the function used to instantiate
* the service.
*/
- add: function (name, class_, ifaces, meth) {
+ add: function add(name, class_, ifaces, meth) {
const self = this;
this.services[name] = { method: meth, class: class_, interfaces: Array.concat(ifaces || []) };
if (name in this && ifaces && !this.__lookupGetter__(name) && !(this[name] instanceof Ci.nsISupports))
* @param {string} init Name of a property or method used to initialize the
* class.
*/
- addClass: function (name, class_, ifaces, init, quiet) {
+ addClass: function addClass(name, class_, ifaces, init, quiet) {
const self = this;
this.services[name] = { class: class_, interfaces: Array.concat(ifaces || []), method: "createInstance", init: init, quiet: quiet };
if (init)
memoize(this.services[name], "callable",
function () callable(XPCOMShim(this.interfaces)[this.init]));
- this[name] = function () self._create(name, arguments);
+ this[name] = function Create() self._create(name, arguments);
update.apply(null, [this[name]].concat([Ci[i] for each (i in Array.concat(ifaces))]));
return this[name];
},
*
* @param {string} name The service's cache key.
*/
- has: function (name) Set.has(this.services, name) && this.services[name].class in Cc &&
+ has: function has(name) Set.has(this.services, name) && this.services[name].class in Cc &&
this.services[name].interfaces.every(function (iface) iface in Ci)
});