Bug 1381853 - lazy load downloads scripts into the browser window, r=mconley.

This commit is contained in:
Florian Quèze 2017-07-23 00:18:00 +02:00
Родитель 520a79823f
Коммит b5647ed1c0
3 изменённых файлов: 20 добавлений и 14 удалений

Просмотреть файл

@ -27,7 +27,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "gPhotonStructure",
/* global AboutHome:false,
BrowserUITelemetry:false, BrowserUsageTelemetry:false, BrowserUtils:false,
CastingApps:false, CharsetMenu:false, Color:false, ContentSearch:false,
CustomizableUI: false,
CustomizableUI: false, DownloadsCommon: false,
Deprecated:false, E10SUtils:false, ExtensionsUI: false, FormValidationHandler:false,
GMPInstallManager:false, LightweightThemeManager:false, Log:false,
LoginManagerParent:false, NewTabUtils:false, PageThumbs:false,
@ -60,6 +60,7 @@ XPCOMUtils.defineLazyPreferenceGetter(this, "gPhotonStructure",
["ContextualIdentityService", "resource://gre/modules/ContextualIdentityService.jsm"],
["CustomizableUI", "resource:///modules/CustomizableUI.jsm"],
["Deprecated", "resource://gre/modules/Deprecated.jsm"],
["DownloadsCommon", "resource:///modules/DownloadsCommon.jsm"],
["E10SUtils", "resource:///modules/E10SUtils.jsm"],
["ExtensionsUI", "resource:///modules/ExtensionsUI.jsm"],
["FormValidationHandler", "resource:///modules/FormValidationHandler.jsm"],
@ -139,6 +140,16 @@ XPCOMUtils.defineLazyScriptGetter(this, "gBrowserThumbnails",
XPCOMUtils.defineLazyScriptGetter(this, ["setContextMenuContentData",
"openContextMenu", "nsContextMenu"],
"chrome://browser/content/nsContextMenu.js");
XPCOMUtils.defineLazyScriptGetter(this, ["DownloadsPanel",
"DownloadsOverlayLoader",
"DownloadsView", "DownloadsViewUI",
"DownloadsViewController",
"DownloadsSummary", "DownloadsFooter",
"DownloadsBlockedSubview"],
"chrome://browser/content/downloads/downloads.js");
XPCOMUtils.defineLazyScriptGetter(this, ["DownloadsButton",
"DownloadsIndicatorView"],
"chrome://browser/content/downloads/indicator.js");
// lazy service getters
@ -1622,8 +1633,7 @@ var gBrowserInit = {
// downloads will start right away, and initializing again won't hurt.
setTimeout(function() {
try {
Cu.import("resource:///modules/DownloadsCommon.jsm", {})
.DownloadsCommon.initializeAllDataLinks();
DownloadsCommon.initializeAllDataLinks();
Cu.import("resource:///modules/DownloadsTaskbar.jsm", {})
.DownloadsTaskbar.registerIndicator(window);
} catch (ex) {

Просмотреть файл

@ -67,8 +67,6 @@
<script type="application/javascript" src="chrome://global/content/contentAreaUtils.js"/>
<script type="application/javascript" src="chrome://browser/content/downloads/downloads.js"/>
<script type="application/javascript" src="chrome://browser/content/downloads/indicator.js"/>
<script type="application/javascript" src="chrome://browser/content/places/editBookmarkOverlay.js"/>
# All sets except for popupsets (commands, keys, stringbundles and broadcasters) *must* go into the

Просмотреть файл

@ -66,8 +66,6 @@ var { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "DownloadsCommon",
"resource:///modules/DownloadsCommon.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "DownloadsViewUI",
"resource:///modules/DownloadsViewUI.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
@ -84,7 +82,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "Services",
/**
* Main entry point for the downloads panel interface.
*/
const DownloadsPanel = {
var DownloadsPanel = {
// Initialization and termination
/**
@ -577,7 +575,7 @@ XPCOMUtils.defineConstant(this, "DownloadsPanel", DownloadsPanel);
* Allows loading the downloads panel and the status indicator interfaces on
* demand, to improve startup performance.
*/
const DownloadsOverlayLoader = {
var DownloadsOverlayLoader = {
/**
* We cannot load two overlays at the same time, thus we use a queue of
* pending load requests.
@ -657,7 +655,7 @@ XPCOMUtils.defineConstant(this, "DownloadsOverlayLoader", DownloadsOverlayLoader
* download state and real-time data. In addition, handles part of the user
* interaction events raised by the downloads list widget.
*/
const DownloadsView = {
var DownloadsView = {
// Functions handling download items in the list
/**
@ -1189,7 +1187,7 @@ DownloadsViewItem.prototype = {
* widget, in particular the "commands" that apply to multiple items, and
* dispatches the commands that apply to individual items.
*/
const DownloadsViewController = {
var DownloadsViewController = {
// Initialization and termination
initialize() {
@ -1292,7 +1290,7 @@ XPCOMUtils.defineConstant(this, "DownloadsViewController", DownloadsViewControll
* Manages the summary at the bottom of the downloads panel list if the number
* of items in the list exceeds the panels limit.
*/
const DownloadsSummary = {
var DownloadsSummary = {
/**
* Sets the active state of the summary. When active, the summary subscribes
@ -1476,7 +1474,7 @@ XPCOMUtils.defineConstant(this, "DownloadsSummary", DownloadsSummary);
* Manages events sent to to the footer vbox, which contains both the
* DownloadsSummary as well as the "Show All Downloads" button.
*/
const DownloadsFooter = {
var DownloadsFooter = {
/**
* Focuses the appropriate element within the footer. If the summary
@ -1530,7 +1528,7 @@ XPCOMUtils.defineConstant(this, "DownloadsFooter", DownloadsFooter);
/**
* Manages the blocked subview that slides in when you click a blocked download.
*/
const DownloadsBlockedSubview = {
var DownloadsBlockedSubview = {
get subview() {
let subview = document.getElementById("downloadsPanel-blockedSubview");