|
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 |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 "use strict"; |
|
6 |
|
7 let Cc = Components.classes; |
|
8 let Ci = Components.interfaces; |
|
9 let Cu = Components.utils; |
|
10 let Cr = Components.results; |
|
11 |
|
12 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
|
13 Cu.import("resource://gre/modules/Services.jsm"); |
|
14 |
|
15 XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils", |
|
16 "resource://gre/modules/PlacesUtils.jsm"); |
|
17 |
|
18 XPCOMUtils.defineLazyModuleGetter(this, "NetUtil", |
|
19 "resource://gre/modules/NetUtil.jsm"); |
|
20 |
|
21 XPCOMUtils.defineLazyModuleGetter(this, "NewTabUtils", |
|
22 "resource://gre/modules/NewTabUtils.jsm"); |
|
23 |
|
24 XPCOMUtils.defineLazyModuleGetter(this, "Promise", |
|
25 "resource://gre/modules/Promise.jsm"); |
|
26 |
|
27 XPCOMUtils.defineLazyModuleGetter(this, "Task", |
|
28 "resource://gre/modules/Task.jsm"); |
|
29 |
|
30 XPCOMUtils.defineLazyModuleGetter(this, "CrossSlide", |
|
31 "resource:///modules/CrossSlide.jsm"); |
|
32 |
|
33 XPCOMUtils.defineLazyModuleGetter(this, "OS", |
|
34 "resource://gre/modules/osfile.jsm"); |
|
35 |
|
36 XPCOMUtils.defineLazyModuleGetter(this, "View", |
|
37 "resource:///modules/View.jsm"); |
|
38 |
|
39 XPCOMUtils.defineLazyServiceGetter(window, "gHistSvc", |
|
40 "@mozilla.org/browser/nav-history-service;1", |
|
41 "nsINavHistoryService", |
|
42 "nsIBrowserHistory"); |
|
43 |
|
44 let ScriptContexts = {}; |
|
45 [ |
|
46 ["Util", "chrome://browser/content/Util.js"], |
|
47 ["Site", "chrome://browser/content/Site.js"], |
|
48 ["StartUI", "chrome://browser/content/StartUI.js"], |
|
49 ["Bookmarks", "chrome://browser/content/bookmarks.js"], |
|
50 ["BookmarksView", "chrome://browser/content/BookmarksView.js"], |
|
51 ["HistoryView", "chrome://browser/content/HistoryView.js"], |
|
52 ["TopSitesView", "chrome://browser/content/TopSitesView.js"], |
|
53 ["RemoteTabsView", "chrome://browser/content/RemoteTabsView.js"], |
|
54 ["BookmarksStartView", "chrome://browser/content/BookmarksView.js"], |
|
55 ["HistoryStartView", "chrome://browser/content/HistoryView.js"], |
|
56 ["TopSitesStartView", "chrome://browser/content/TopSitesView.js"], |
|
57 ["RemoteTabsStartView", "chrome://browser/content/RemoteTabsView.js"], |
|
58 ["ItemPinHelper", "chrome://browser/content/helperui/ItemPinHelper.js"], |
|
59 ].forEach(function (aScript) { |
|
60 let [name, script] = aScript; |
|
61 XPCOMUtils.defineLazyGetter(window, name, function() { |
|
62 let sandbox; |
|
63 if (script in ScriptContexts) { |
|
64 sandbox = ScriptContexts[script]; |
|
65 } else { |
|
66 sandbox = ScriptContexts[script] = {}; |
|
67 Services.scriptloader.loadSubScript(script, sandbox); |
|
68 } |
|
69 return sandbox[name]; |
|
70 }); |
|
71 }); |
|
72 |
|
73 // singleton |
|
74 XPCOMUtils.defineLazyGetter(this, "TopSites", function() { |
|
75 return StartUI.chromeWin.TopSites; |
|
76 }); |
|
77 |
|
78 #ifdef MOZ_SERVICES_SYNC |
|
79 XPCOMUtils.defineLazyGetter(this, "Weave", function() { |
|
80 Components.utils.import("resource://services-sync/main.js"); |
|
81 return Weave; |
|
82 }); |
|
83 #endif |