michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: "use strict"; michael@0: michael@0: let Cc = Components.classes; michael@0: let Ci = Components.interfaces; michael@0: let Cu = Components.utils; michael@0: let Cr = Components.results; michael@0: michael@0: Cu.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: Cu.import("resource://gre/modules/Services.jsm"); michael@0: michael@0: XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils", michael@0: "resource://gre/modules/PlacesUtils.jsm"); michael@0: michael@0: XPCOMUtils.defineLazyModuleGetter(this, "NetUtil", michael@0: "resource://gre/modules/NetUtil.jsm"); michael@0: michael@0: XPCOMUtils.defineLazyModuleGetter(this, "NewTabUtils", michael@0: "resource://gre/modules/NewTabUtils.jsm"); michael@0: michael@0: XPCOMUtils.defineLazyModuleGetter(this, "Promise", michael@0: "resource://gre/modules/Promise.jsm"); michael@0: michael@0: XPCOMUtils.defineLazyModuleGetter(this, "Task", michael@0: "resource://gre/modules/Task.jsm"); michael@0: michael@0: XPCOMUtils.defineLazyModuleGetter(this, "CrossSlide", michael@0: "resource:///modules/CrossSlide.jsm"); michael@0: michael@0: XPCOMUtils.defineLazyModuleGetter(this, "OS", michael@0: "resource://gre/modules/osfile.jsm"); michael@0: michael@0: XPCOMUtils.defineLazyModuleGetter(this, "View", michael@0: "resource:///modules/View.jsm"); michael@0: michael@0: XPCOMUtils.defineLazyServiceGetter(window, "gHistSvc", michael@0: "@mozilla.org/browser/nav-history-service;1", michael@0: "nsINavHistoryService", michael@0: "nsIBrowserHistory"); michael@0: michael@0: let ScriptContexts = {}; michael@0: [ michael@0: ["Util", "chrome://browser/content/Util.js"], michael@0: ["Site", "chrome://browser/content/Site.js"], michael@0: ["StartUI", "chrome://browser/content/StartUI.js"], michael@0: ["Bookmarks", "chrome://browser/content/bookmarks.js"], michael@0: ["BookmarksView", "chrome://browser/content/BookmarksView.js"], michael@0: ["HistoryView", "chrome://browser/content/HistoryView.js"], michael@0: ["TopSitesView", "chrome://browser/content/TopSitesView.js"], michael@0: ["RemoteTabsView", "chrome://browser/content/RemoteTabsView.js"], michael@0: ["BookmarksStartView", "chrome://browser/content/BookmarksView.js"], michael@0: ["HistoryStartView", "chrome://browser/content/HistoryView.js"], michael@0: ["TopSitesStartView", "chrome://browser/content/TopSitesView.js"], michael@0: ["RemoteTabsStartView", "chrome://browser/content/RemoteTabsView.js"], michael@0: ["ItemPinHelper", "chrome://browser/content/helperui/ItemPinHelper.js"], michael@0: ].forEach(function (aScript) { michael@0: let [name, script] = aScript; michael@0: XPCOMUtils.defineLazyGetter(window, name, function() { michael@0: let sandbox; michael@0: if (script in ScriptContexts) { michael@0: sandbox = ScriptContexts[script]; michael@0: } else { michael@0: sandbox = ScriptContexts[script] = {}; michael@0: Services.scriptloader.loadSubScript(script, sandbox); michael@0: } michael@0: return sandbox[name]; michael@0: }); michael@0: }); michael@0: michael@0: // singleton michael@0: XPCOMUtils.defineLazyGetter(this, "TopSites", function() { michael@0: return StartUI.chromeWin.TopSites; michael@0: }); michael@0: michael@0: #ifdef MOZ_SERVICES_SYNC michael@0: XPCOMUtils.defineLazyGetter(this, "Weave", function() { michael@0: Components.utils.import("resource://services-sync/main.js"); michael@0: return Weave; michael@0: }); michael@0: #endif