|
1 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
|
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 const Cc = Components.classes; |
|
6 const Ci = Components.interfaces; |
|
7 const Cu = Components.utils; |
|
8 const Cr = Components.results; |
|
9 |
|
10 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
|
11 Cu.import("resource://gre/modules/Services.jsm"); |
|
12 |
|
13 XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils", |
|
14 "resource://gre/modules/PlacesUtils.jsm"); |
|
15 XPCOMUtils.defineLazyModuleGetter(this, "FileUtils", |
|
16 "resource://gre/modules/FileUtils.jsm"); |
|
17 XPCOMUtils.defineLazyModuleGetter(this, "MigrationUtils", |
|
18 "resource:///modules/MigrationUtils.jsm"); |
|
19 // Initialize profile. |
|
20 let gProfD = do_get_profile(); |
|
21 |
|
22 // Create a fake XULAppInfo to satisfy the eventual needs of the migrators. |
|
23 let (XULAppInfo = { |
|
24 // nsIXUlAppInfo |
|
25 get vendor() "Mozilla", |
|
26 get name() "XPCShell", |
|
27 get ID() "xpcshell@tests.mozilla.org", |
|
28 get version() "1", |
|
29 get appBuildID() "2007010101", |
|
30 get platformVersion() "1.0", |
|
31 get platformBuildID() "2007010101", |
|
32 |
|
33 // nsIXUlRuntime (partial) |
|
34 get inSafeMode() false, |
|
35 logConsoleErrors: true, |
|
36 get OS() "XPCShell", |
|
37 get XPCOMABI() "noarch-spidermonkey", |
|
38 invalidateCachesOnRestart: function () {}, |
|
39 |
|
40 // nsIWinAppHelper |
|
41 get userCanElevate() false, |
|
42 |
|
43 QueryInterface: function (aIID) { |
|
44 let interfaces = [Ci.nsIXULAppInfo, Ci.nsIXULRuntime]; |
|
45 if ("nsIWinAppHelper" in Ci) |
|
46 interfaces.push(Ci.nsIWinAppHelper); |
|
47 if (!interfaces.some(function (v) aIID.equals(v))) |
|
48 throw Cr.NS_ERROR_NO_INTERFACE; |
|
49 return this; |
|
50 } |
|
51 }) { |
|
52 const CONTRACT_ID = "@mozilla.org/xre/app-info;1"; |
|
53 const CID = Components.ID("7685dac8-3637-4660-a544-928c5ec0e714}"); |
|
54 |
|
55 let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); |
|
56 registrar.registerFactory(CID, "XULAppInfo", CONTRACT_ID, { |
|
57 createInstance: function (aOuter, aIID) { |
|
58 if (aOuter != null) |
|
59 throw Cr.NS_ERROR_NO_AGGREGATION; |
|
60 return XULAppInfo.QueryInterface(aIID); |
|
61 }, |
|
62 QueryInterface: XPCOMUtils.generateQI(Ci.nsIFactory) |
|
63 }); |
|
64 } |