Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | const XULRUNTIME_CONTRACTID = "@mozilla.org/xre/runtime;1"; |
michael@0 | 5 | const XULRUNTIME_CID = Components.ID("7685dac8-3637-4660-a544-928c5ec0e714}"); |
michael@0 | 6 | |
michael@0 | 7 | Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); |
michael@0 | 8 | |
michael@0 | 9 | let gAppInfo = null; |
michael@0 | 10 | |
michael@0 | 11 | function createAppInfo(id, name, version, platformVersion) { |
michael@0 | 12 | gAppInfo = { |
michael@0 | 13 | // nsIXULAppInfo |
michael@0 | 14 | vendor: "Mozilla", |
michael@0 | 15 | name: name, |
michael@0 | 16 | ID: id, |
michael@0 | 17 | version: version, |
michael@0 | 18 | appBuildID: "2007010101", |
michael@0 | 19 | platformVersion: platformVersion ? platformVersion : "1.0", |
michael@0 | 20 | platformBuildID: "2007010101", |
michael@0 | 21 | |
michael@0 | 22 | // nsIXULRuntime |
michael@0 | 23 | inSafeMode: false, |
michael@0 | 24 | logConsoleErrors: true, |
michael@0 | 25 | OS: "XPCShell", |
michael@0 | 26 | replacedLockTime: 0, |
michael@0 | 27 | XPCOMABI: "noarch-spidermonkey", |
michael@0 | 28 | invalidateCachesOnRestart: function invalidateCachesOnRestart() { |
michael@0 | 29 | // Do nothing |
michael@0 | 30 | }, |
michael@0 | 31 | |
michael@0 | 32 | // nsICrashReporter |
michael@0 | 33 | annotations: { |
michael@0 | 34 | }, |
michael@0 | 35 | |
michael@0 | 36 | annotateCrashReport: function(key, data) { |
michael@0 | 37 | this.annotations[key] = data; |
michael@0 | 38 | }, |
michael@0 | 39 | |
michael@0 | 40 | QueryInterface: XPCOMUtils.generateQI([Ci.nsIXULAppInfo, |
michael@0 | 41 | Ci.nsIXULRuntime, |
michael@0 | 42 | Ci.nsICrashReporter, |
michael@0 | 43 | Ci.nsISupports]) |
michael@0 | 44 | }; |
michael@0 | 45 | |
michael@0 | 46 | let XULAppInfoFactory = { |
michael@0 | 47 | createInstance: function (outer, iid) { |
michael@0 | 48 | if (outer != null) |
michael@0 | 49 | throw Components.results.NS_ERROR_NO_AGGREGATION; |
michael@0 | 50 | return gAppInfo.QueryInterface(iid); |
michael@0 | 51 | } |
michael@0 | 52 | }; |
michael@0 | 53 | let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); |
michael@0 | 54 | registrar.registerFactory(XULRUNTIME_CID, "XULRuntime", |
michael@0 | 55 | XULRUNTIME_CONTRACTID, XULAppInfoFactory); |
michael@0 | 56 | |
michael@0 | 57 | } |