|
1 // -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*- |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 Cu.import("resource://gre/modules/XPCOMUtils.jsm"); |
|
7 Cu.import("resource://gre/modules/Services.jsm"); |
|
8 |
|
9 /* |
|
10 * JS modules |
|
11 */ |
|
12 |
|
13 XPCOMUtils.defineLazyModuleGetter(this, "Downloads", |
|
14 "resource://gre/modules/Downloads.jsm"); |
|
15 |
|
16 XPCOMUtils.defineLazyModuleGetter(this, "FormHistory", |
|
17 "resource://gre/modules/FormHistory.jsm"); |
|
18 |
|
19 XPCOMUtils.defineLazyModuleGetter(this, "FileUtils", |
|
20 "resource://gre/modules/FileUtils.jsm"); |
|
21 |
|
22 XPCOMUtils.defineLazyModuleGetter(this, "PageThumbs", |
|
23 "resource://gre/modules/PageThumbs.jsm"); |
|
24 |
|
25 XPCOMUtils.defineLazyModuleGetter(this, "PluralForm", |
|
26 "resource://gre/modules/PluralForm.jsm"); |
|
27 |
|
28 XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils", |
|
29 "resource://gre/modules/PlacesUtils.jsm"); |
|
30 |
|
31 XPCOMUtils.defineLazyModuleGetter(this, "NetUtil", |
|
32 "resource://gre/modules/NetUtil.jsm"); |
|
33 |
|
34 XPCOMUtils.defineLazyModuleGetter(this, "DownloadUtils", |
|
35 "resource://gre/modules/DownloadUtils.jsm"); |
|
36 |
|
37 XPCOMUtils.defineLazyModuleGetter(this, "NewTabUtils", |
|
38 "resource://gre/modules/NewTabUtils.jsm"); |
|
39 |
|
40 XPCOMUtils.defineLazyModuleGetter(this, "Promise", |
|
41 "resource://gre/modules/Promise.jsm"); |
|
42 |
|
43 XPCOMUtils.defineLazyModuleGetter(this, "ColorUtils", |
|
44 "resource:///modules/colorUtils.jsm"); |
|
45 |
|
46 #ifdef NIGHTLY_BUILD |
|
47 XPCOMUtils.defineLazyModuleGetter(this, "ShumwayUtils", |
|
48 "resource://shumway/ShumwayUtils.jsm"); |
|
49 |
|
50 XPCOMUtils.defineLazyModuleGetter(this, "PdfJs", |
|
51 "resource://pdf.js/PdfJs.jsm"); |
|
52 #endif |
|
53 |
|
54 XPCOMUtils.defineLazyModuleGetter(this, "Task", |
|
55 "resource://gre/modules/Task.jsm"); |
|
56 |
|
57 XPCOMUtils.defineLazyModuleGetter(this, "OS", |
|
58 "resource://gre/modules/osfile.jsm"); |
|
59 |
|
60 XPCOMUtils.defineLazyModuleGetter(this, "UITelemetry", |
|
61 "resource://gre/modules/UITelemetry.jsm"); |
|
62 |
|
63 #ifdef MOZ_UPDATER |
|
64 XPCOMUtils.defineLazyModuleGetter(this, "AddonManager", |
|
65 "resource://gre/modules/AddonManager.jsm"); |
|
66 #endif |
|
67 |
|
68 /* |
|
69 * Services |
|
70 */ |
|
71 |
|
72 XPCOMUtils.defineLazyServiceGetter(this, "StyleSheetSvc", |
|
73 "@mozilla.org/content/style-sheet-service;1", |
|
74 "nsIStyleSheetService"); |
|
75 XPCOMUtils.defineLazyServiceGetter(window, "gHistSvc", |
|
76 "@mozilla.org/browser/nav-history-service;1", |
|
77 "nsINavHistoryService", |
|
78 "nsIBrowserHistory"); |
|
79 XPCOMUtils.defineLazyServiceGetter(window, "gURIFixup", |
|
80 "@mozilla.org/docshell/urifixup;1", |
|
81 "nsIURIFixup"); |
|
82 XPCOMUtils.defineLazyServiceGetter(window, "gFaviconService", |
|
83 "@mozilla.org/browser/favicon-service;1", |
|
84 "nsIFaviconService"); |
|
85 XPCOMUtils.defineLazyServiceGetter(window, "gFocusManager", |
|
86 "@mozilla.org/focus-manager;1", |
|
87 "nsIFocusManager"); |
|
88 XPCOMUtils.defineLazyServiceGetter(window, "gEventListenerService", |
|
89 "@mozilla.org/eventlistenerservice;1", |
|
90 "nsIEventListenerService"); |
|
91 #ifdef MOZ_CRASHREPORTER |
|
92 XPCOMUtils.defineLazyServiceGetter(this, "CrashReporter", |
|
93 "@mozilla.org/xre/app-info;1", |
|
94 "nsICrashReporter"); |
|
95 #endif |
|
96 |
|
97 /* |
|
98 * window.Rect is used by |
|
99 * http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-Rect |
|
100 * so it is not possible to set a lazy getter for Geometry.jsm. |
|
101 */ |
|
102 Cu.import("resource://gre/modules/Geometry.jsm"); |
|
103 /* |
|
104 * Browser scripts |
|
105 */ |
|
106 let ScriptContexts = {}; |
|
107 [ |
|
108 ["ContentAreaObserver", "chrome://browser/content/ContentAreaObserver.js"], |
|
109 ["WebProgress", "chrome://browser/content/WebProgress.js"], |
|
110 ["FindHelperUI", "chrome://browser/content/helperui/FindHelperUI.js"], |
|
111 ["FormHelperUI", "chrome://browser/content/helperui/FormHelperUI.js"], |
|
112 ["BrowserTouchHandler", "chrome://browser/content/BrowserTouchHandler.js"], |
|
113 ["AlertsHelper", "chrome://browser/content/helperui/AlertsHelper.js"], |
|
114 ["AutofillMenuUI", "chrome://browser/content/helperui/MenuUI.js"], |
|
115 ["ContextMenuUI", "chrome://browser/content/helperui/MenuUI.js"], |
|
116 ["MenuControlUI", "chrome://browser/content/helperui/MenuUI.js"], |
|
117 ["MenuPopup", "chrome://browser/content/helperui/MenuUI.js"], |
|
118 ["IndexedDB", "chrome://browser/content/helperui/IndexedDB.js"], |
|
119 ["OfflineApps", "chrome://browser/content/helperui/OfflineApps.js"], |
|
120 ["SelectHelperUI", "chrome://browser/content/helperui/SelectHelperUI.js"], |
|
121 ["SelectionHelperUI", "chrome://browser/content/helperui/SelectionHelperUI.js"], |
|
122 ["SelectionPrototype", "chrome://browser/content/library/SelectionPrototype.js"], |
|
123 ["ChromeSelectionHandler", "chrome://browser/content/helperui/ChromeSelectionHandler.js"], |
|
124 ["CommandUpdater", "chrome://browser/content/commandUtil.js"], |
|
125 ["ContextCommands", "chrome://browser/content/ContextCommands.js"], |
|
126 ["Bookmarks", "chrome://browser/content/bookmarks.js"], |
|
127 ["MetroDownloadsView", "chrome://browser/content/downloads.js"], |
|
128 ["ConsolePanelView", "chrome://browser/content/console.js"], |
|
129 ["Site", "chrome://browser/content/Site.js"], |
|
130 ["TopSites", "chrome://browser/content/TopSites.js"], |
|
131 ["Sanitizer", "chrome://browser/content/sanitize.js"], |
|
132 ["SanitizeUI", "chrome://browser/content/sanitizeUI.js"], |
|
133 ["SSLExceptions", "chrome://browser/content/exceptions.js"], |
|
134 ["ItemPinHelper", "chrome://browser/content/helperui/ItemPinHelper.js"], |
|
135 ["NavButtonSlider", "chrome://browser/content/NavButtonSlider.js"], |
|
136 ["ContextUI", "chrome://browser/content/ContextUI.js"], |
|
137 ["FlyoutPanelsUI", "chrome://browser/content/flyoutpanels/FlyoutPanelsUI.js"], |
|
138 ["SettingsCharm", "chrome://browser/content/flyoutpanels/SettingsCharm.js"], |
|
139 ["APZCObserver", "chrome://browser/content/apzc.js"], |
|
140 ].forEach(function (aScript) { |
|
141 let [name, script] = aScript; |
|
142 XPCOMUtils.defineLazyGetter(window, name, function() { |
|
143 let sandbox; |
|
144 if (script in ScriptContexts) { |
|
145 sandbox = ScriptContexts[script]; |
|
146 } else { |
|
147 sandbox = ScriptContexts[script] = {}; |
|
148 Services.scriptloader.loadSubScript(script, sandbox); |
|
149 } |
|
150 return sandbox[name]; |
|
151 }); |
|
152 }); |
|
153 #ifdef MOZ_SERVICES_SYNC |
|
154 XPCOMUtils.defineLazyGetter(this, "Weave", function() { |
|
155 Components.utils.import("resource://services-sync/main.js"); |
|
156 return Weave; |
|
157 }); |
|
158 #endif |
|
159 |
|
160 /* |
|
161 * Delay load some global scripts using a custom namespace |
|
162 */ |
|
163 XPCOMUtils.defineLazyGetter(this, "GlobalOverlay", function() { |
|
164 let GlobalOverlay = {}; |
|
165 Services.scriptloader.loadSubScript("chrome://global/content/globalOverlay.js", GlobalOverlay); |
|
166 return GlobalOverlay; |
|
167 }); |
|
168 |
|
169 XPCOMUtils.defineLazyGetter(this, "ContentAreaUtils", function() { |
|
170 let ContentAreaUtils = {}; |
|
171 Services.scriptloader.loadSubScript("chrome://global/content/contentAreaUtils.js", ContentAreaUtils); |
|
172 return ContentAreaUtils; |
|
173 }); |