browser/metro/base/content/browser-scripts.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/metro/base/content/browser-scripts.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,173 @@
     1.4 +// -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*-
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +Cu.import("resource://gre/modules/XPCOMUtils.jsm");
    1.10 +Cu.import("resource://gre/modules/Services.jsm");
    1.11 +
    1.12 +/*
    1.13 + * JS modules
    1.14 + */
    1.15 +
    1.16 +XPCOMUtils.defineLazyModuleGetter(this, "Downloads",
    1.17 +                                  "resource://gre/modules/Downloads.jsm");
    1.18 +
    1.19 +XPCOMUtils.defineLazyModuleGetter(this, "FormHistory",
    1.20 +                                  "resource://gre/modules/FormHistory.jsm");
    1.21 +
    1.22 +XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
    1.23 +                                  "resource://gre/modules/FileUtils.jsm");
    1.24 +
    1.25 +XPCOMUtils.defineLazyModuleGetter(this, "PageThumbs",
    1.26 +                                  "resource://gre/modules/PageThumbs.jsm");
    1.27 +
    1.28 +XPCOMUtils.defineLazyModuleGetter(this, "PluralForm",
    1.29 +                                  "resource://gre/modules/PluralForm.jsm");
    1.30 +
    1.31 +XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
    1.32 +                                  "resource://gre/modules/PlacesUtils.jsm");
    1.33 +
    1.34 +XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
    1.35 +                                  "resource://gre/modules/NetUtil.jsm");
    1.36 +
    1.37 +XPCOMUtils.defineLazyModuleGetter(this, "DownloadUtils",
    1.38 +                                  "resource://gre/modules/DownloadUtils.jsm");
    1.39 +
    1.40 +XPCOMUtils.defineLazyModuleGetter(this, "NewTabUtils",
    1.41 +                                  "resource://gre/modules/NewTabUtils.jsm");
    1.42 +
    1.43 +XPCOMUtils.defineLazyModuleGetter(this, "Promise",
    1.44 +                                  "resource://gre/modules/Promise.jsm");
    1.45 +
    1.46 +XPCOMUtils.defineLazyModuleGetter(this, "ColorUtils",
    1.47 +                                  "resource:///modules/colorUtils.jsm");
    1.48 +
    1.49 +#ifdef NIGHTLY_BUILD
    1.50 +XPCOMUtils.defineLazyModuleGetter(this, "ShumwayUtils",
    1.51 +                                  "resource://shumway/ShumwayUtils.jsm");
    1.52 +
    1.53 +XPCOMUtils.defineLazyModuleGetter(this, "PdfJs",
    1.54 +                                  "resource://pdf.js/PdfJs.jsm");
    1.55 +#endif
    1.56 +
    1.57 +XPCOMUtils.defineLazyModuleGetter(this, "Task",
    1.58 +                                  "resource://gre/modules/Task.jsm");
    1.59 +
    1.60 +XPCOMUtils.defineLazyModuleGetter(this, "OS",
    1.61 +                                  "resource://gre/modules/osfile.jsm");
    1.62 +
    1.63 +XPCOMUtils.defineLazyModuleGetter(this, "UITelemetry",
    1.64 +                                  "resource://gre/modules/UITelemetry.jsm");
    1.65 +
    1.66 +#ifdef MOZ_UPDATER
    1.67 +XPCOMUtils.defineLazyModuleGetter(this, "AddonManager",
    1.68 +                                  "resource://gre/modules/AddonManager.jsm");
    1.69 +#endif
    1.70 +
    1.71 +/*
    1.72 + * Services
    1.73 + */
    1.74 +
    1.75 +XPCOMUtils.defineLazyServiceGetter(this, "StyleSheetSvc",
    1.76 +                                   "@mozilla.org/content/style-sheet-service;1",
    1.77 +                                   "nsIStyleSheetService");
    1.78 +XPCOMUtils.defineLazyServiceGetter(window, "gHistSvc",
    1.79 +                                   "@mozilla.org/browser/nav-history-service;1",
    1.80 +                                   "nsINavHistoryService",
    1.81 +                                   "nsIBrowserHistory");
    1.82 +XPCOMUtils.defineLazyServiceGetter(window, "gURIFixup",
    1.83 +                                   "@mozilla.org/docshell/urifixup;1",
    1.84 +                                   "nsIURIFixup");
    1.85 +XPCOMUtils.defineLazyServiceGetter(window, "gFaviconService",
    1.86 +                                   "@mozilla.org/browser/favicon-service;1",
    1.87 +                                   "nsIFaviconService");
    1.88 +XPCOMUtils.defineLazyServiceGetter(window, "gFocusManager",
    1.89 +                                   "@mozilla.org/focus-manager;1",
    1.90 +                                   "nsIFocusManager");
    1.91 +XPCOMUtils.defineLazyServiceGetter(window, "gEventListenerService",
    1.92 +                                   "@mozilla.org/eventlistenerservice;1",
    1.93 +                                   "nsIEventListenerService");
    1.94 +#ifdef MOZ_CRASHREPORTER
    1.95 +XPCOMUtils.defineLazyServiceGetter(this, "CrashReporter",
    1.96 +                                   "@mozilla.org/xre/app-info;1",
    1.97 +                                   "nsICrashReporter");
    1.98 +#endif
    1.99 +
   1.100 +/*
   1.101 + * window.Rect is used by
   1.102 + * http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-Rect
   1.103 + * so it is not possible to set a lazy getter for Geometry.jsm.
   1.104 + */
   1.105 +Cu.import("resource://gre/modules/Geometry.jsm");
   1.106 +/*
   1.107 + * Browser scripts
   1.108 + */
   1.109 +let ScriptContexts = {};
   1.110 +[
   1.111 +  ["ContentAreaObserver", "chrome://browser/content/ContentAreaObserver.js"],
   1.112 +  ["WebProgress", "chrome://browser/content/WebProgress.js"],
   1.113 +  ["FindHelperUI", "chrome://browser/content/helperui/FindHelperUI.js"],
   1.114 +  ["FormHelperUI", "chrome://browser/content/helperui/FormHelperUI.js"],
   1.115 +  ["BrowserTouchHandler", "chrome://browser/content/BrowserTouchHandler.js"],
   1.116 +  ["AlertsHelper", "chrome://browser/content/helperui/AlertsHelper.js"],
   1.117 +  ["AutofillMenuUI", "chrome://browser/content/helperui/MenuUI.js"],
   1.118 +  ["ContextMenuUI", "chrome://browser/content/helperui/MenuUI.js"],
   1.119 +  ["MenuControlUI", "chrome://browser/content/helperui/MenuUI.js"],
   1.120 +  ["MenuPopup", "chrome://browser/content/helperui/MenuUI.js"],
   1.121 +  ["IndexedDB", "chrome://browser/content/helperui/IndexedDB.js"],
   1.122 +  ["OfflineApps", "chrome://browser/content/helperui/OfflineApps.js"],
   1.123 +  ["SelectHelperUI", "chrome://browser/content/helperui/SelectHelperUI.js"],
   1.124 +  ["SelectionHelperUI", "chrome://browser/content/helperui/SelectionHelperUI.js"],
   1.125 +  ["SelectionPrototype", "chrome://browser/content/library/SelectionPrototype.js"],
   1.126 +  ["ChromeSelectionHandler", "chrome://browser/content/helperui/ChromeSelectionHandler.js"],
   1.127 +  ["CommandUpdater", "chrome://browser/content/commandUtil.js"],
   1.128 +  ["ContextCommands", "chrome://browser/content/ContextCommands.js"],
   1.129 +  ["Bookmarks", "chrome://browser/content/bookmarks.js"],
   1.130 +  ["MetroDownloadsView", "chrome://browser/content/downloads.js"],
   1.131 +  ["ConsolePanelView", "chrome://browser/content/console.js"],
   1.132 +  ["Site", "chrome://browser/content/Site.js"],
   1.133 +  ["TopSites", "chrome://browser/content/TopSites.js"],
   1.134 +  ["Sanitizer", "chrome://browser/content/sanitize.js"],
   1.135 +  ["SanitizeUI", "chrome://browser/content/sanitizeUI.js"],
   1.136 +  ["SSLExceptions", "chrome://browser/content/exceptions.js"],
   1.137 +  ["ItemPinHelper", "chrome://browser/content/helperui/ItemPinHelper.js"],
   1.138 +  ["NavButtonSlider", "chrome://browser/content/NavButtonSlider.js"],
   1.139 +  ["ContextUI", "chrome://browser/content/ContextUI.js"],
   1.140 +  ["FlyoutPanelsUI", "chrome://browser/content/flyoutpanels/FlyoutPanelsUI.js"],
   1.141 +  ["SettingsCharm", "chrome://browser/content/flyoutpanels/SettingsCharm.js"],
   1.142 +  ["APZCObserver", "chrome://browser/content/apzc.js"],
   1.143 +].forEach(function (aScript) {
   1.144 +  let [name, script] = aScript;
   1.145 +  XPCOMUtils.defineLazyGetter(window, name, function() {
   1.146 +    let sandbox;
   1.147 +    if (script in ScriptContexts) {
   1.148 +      sandbox = ScriptContexts[script];
   1.149 +    } else {
   1.150 +      sandbox = ScriptContexts[script] = {};
   1.151 +      Services.scriptloader.loadSubScript(script, sandbox);
   1.152 +    }
   1.153 +    return sandbox[name];
   1.154 +  });
   1.155 +});
   1.156 +#ifdef MOZ_SERVICES_SYNC
   1.157 +XPCOMUtils.defineLazyGetter(this, "Weave", function() {
   1.158 +  Components.utils.import("resource://services-sync/main.js");
   1.159 +  return Weave;
   1.160 +});
   1.161 +#endif
   1.162 +
   1.163 +/*
   1.164 + * Delay load some global scripts using a custom namespace
   1.165 + */
   1.166 +XPCOMUtils.defineLazyGetter(this, "GlobalOverlay", function() {
   1.167 +  let GlobalOverlay = {};
   1.168 +  Services.scriptloader.loadSubScript("chrome://global/content/globalOverlay.js", GlobalOverlay);
   1.169 +  return GlobalOverlay;
   1.170 +});
   1.171 +
   1.172 +XPCOMUtils.defineLazyGetter(this, "ContentAreaUtils", function() {
   1.173 +  let ContentAreaUtils = {};
   1.174 +  Services.scriptloader.loadSubScript("chrome://global/content/contentAreaUtils.js", ContentAreaUtils);
   1.175 +  return ContentAreaUtils;
   1.176 +});

mercurial