X-Git-Url: https://git.donarmstrong.com/?p=dactyl.git;a=blobdiff_plain;f=common%2Fmodules%2Fservices.jsm;h=377cd13edec5345d5e8809a9b35474bcf89c7752;hp=d3ac781fac3fdfff5fde6cf3a5ca43cfa444b45b;hb=3d837eb266a3a01d424192aa4ec1a167366178c5;hpb=d8a3bcebff36df7b128b36e0b57b715479e155a0 diff --git a/common/modules/services.jsm b/common/modules/services.jsm index d3ac781..377cd13 100644 --- a/common/modules/services.jsm +++ b/common/modules/services.jsm @@ -1,4 +1,4 @@ -// Copyright (c) 2008-2012 Kris Maglione +// Copyright (c) 2008-2013 Kris Maglione // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. @@ -47,13 +47,13 @@ var Services = Module("Services", { this.add("downloadManager", "@mozilla.org/download-manager;1", "nsIDownloadManager"); this.add("environment", "@mozilla.org/process/environment;1", "nsIEnvironment"); this.add("extensionManager", "@mozilla.org/extensions/manager;1", "nsIExtensionManager"); - this.add("externalApp", "@mozilla.org/uriloader/external-helper-app-service;1", "nsPIExternalAppLauncher") + this.add("externalApp", "@mozilla.org/uriloader/external-helper-app-service;1", "nsPIExternalAppLauncher"); this.add("externalProtocol", "@mozilla.org/uriloader/external-protocol-service;1", "nsIExternalProtocolService"); this.add("favicon", "@mozilla.org/browser/favicon-service;1", "nsIFaviconService"); this.add("file:", this.PROTOCOL + "file", "nsIFileProtocolHandler"); this.add("focus", "@mozilla.org/focus-manager;1", "nsIFocusManager"); - this.add("history", "@mozilla.org/browser/global-history;2", - ["nsIBrowserHistory", "nsIGlobalHistory2", "nsINavHistoryService", "nsPIPlacesDatabase"]); + this.add("history", "@mozilla.org/browser/nav-history-service;1", + ["nsIBrowserHistory", "nsINavHistoryService", "nsPIPlacesDatabase"]); this.add("io", "@mozilla.org/network/io-service;1", "nsIIOService"); this.add("json", "@mozilla.org/dom/json;1", "nsIJSON", "createInstance"); this.add("listeners", "@mozilla.org/eventlistenerservice;1", "nsIEventListenerService"); @@ -99,7 +99,7 @@ var Services = Module("Services", { this.addClass("Persist", "@mozilla.org/embedding/browser/nsWebBrowserPersist;1", "nsIWebBrowserPersist"); this.addClass("Pipe", "@mozilla.org/pipe;1", "nsIPipe", "init"); this.addClass("Process", "@mozilla.org/process/util;1", "nsIProcess", "init"); - this.addClass("Pump", "@mozilla.org/network/input-stream-pump;1", "nsIInputStreamPump", "init") + this.addClass("Pump", "@mozilla.org/network/input-stream-pump;1", "nsIInputStreamPump", "init"); this.addClass("StreamChannel","@mozilla.org/network/input-stream-channel;1", ["nsIInputStreamChannel", "nsIChannel"], "setURI"); this.addClass("StreamCopier", "@mozilla.org/network/async-stream-copier;1","nsIAsyncStreamCopier", "init"); @@ -126,7 +126,7 @@ var Services = Module("Services", { if (!service.interfaces.length) return res.wrappedJSObject || res; - service.interfaces.forEach(function (iface) res.QueryInterface(Ci[iface])); + service.interfaces.forEach(function (iface) res instanceof Ci[iface]); if (service.init && args.length) { if (service.callable) res[service.init].apply(res, args); @@ -139,7 +139,7 @@ var Services = Module("Services", { if (service.quiet === false) throw e.stack ? e : Error(e); - if (typeof util !== "undefined") + if (typeof util !== "undefined" && util != null) util.reportError(e); else dump("dactyl: Service creation failed for '" + service.class + "': " + e + "\n" + (e.stack || Error(e).stack)); @@ -176,13 +176,12 @@ var Services = Module("Services", { * class. */ 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 Create() self._create(name, arguments); + this[name] = (function Create() this._create(name, arguments)).bind(this); update.apply(null, [this[name]].concat([Ci[i] for each (i in Array.concat(ifaces))])); return this[name]; }, @@ -214,4 +213,4 @@ endModule(); } catch(e){dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack);} -// vim: set fdm=marker sw=4 sts=4 et ft=javascript: +// vim: set fdm=marker sw=4 sts=4 ts=8 et ft=javascript: