mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 670023 - Use ES5's strict mode in Add-ons Manager frontend and backend code. r=dtownsend
This commit is contained in:
parent
828131f468
commit
cd9c3c38b5
@ -37,6 +37,8 @@
|
||||
# ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cr = Components.results;
|
||||
@ -45,6 +47,8 @@ const KEY_PROFILEDIR = "ProfD";
|
||||
const FILE_EXTENSIONS_LOG = "extensions.log";
|
||||
const PREF_LOGGING_ENABLED = "extensions.logging.enabled";
|
||||
|
||||
const LOGGER_FILE_PERM = parseInt("666", 8);
|
||||
|
||||
const NS_PREFBRANCH_PREFCHANGE_TOPIC_ID = "nsPref:changed";
|
||||
|
||||
Components.utils.import("resource://gre/modules/FileUtils.jsm");
|
||||
@ -119,7 +123,7 @@ AddonLogger.prototype = {
|
||||
var logfile = FileUtils.getFile(KEY_PROFILEDIR, [FILE_EXTENSIONS_LOG]);
|
||||
var stream = Cc["@mozilla.org/network/file-output-stream;1"].
|
||||
createInstance(Ci.nsIFileOutputStream);
|
||||
stream.init(logfile, 0x02 | 0x08 | 0x10, 0666, 0); // write, create, append
|
||||
stream.init(logfile, 0x02 | 0x08 | 0x10, LOGGER_FILE_PERM, 0); // write, create, append
|
||||
var writer = Cc["@mozilla.org/intl/converter-output-stream;1"].
|
||||
createInstance(Ci.nsIConverterOutputStream);
|
||||
writer.init(stream, "UTF-8", 0, 0x0000);
|
||||
|
@ -37,6 +37,8 @@
|
||||
# ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cr = Components.results;
|
||||
|
@ -37,6 +37,8 @@
|
||||
# ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
@ -1510,7 +1512,7 @@ var AddonDatabase = {
|
||||
}
|
||||
|
||||
let returnedAddons = {};
|
||||
for each (addon in addons)
|
||||
for each (let addon in addons)
|
||||
returnedAddons[addon.id] = addon;
|
||||
aCallback(returnedAddons);
|
||||
}
|
||||
|
@ -42,6 +42,8 @@
|
||||
* from an add-on's remote update manifest.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
|
@ -35,6 +35,8 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
"use strict";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["LightweightThemeManager"];
|
||||
|
||||
const Cc = Components.classes;
|
||||
|
@ -37,6 +37,8 @@
|
||||
# ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
|
@ -37,6 +37,8 @@
|
||||
# ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cr = Components.results;
|
||||
@ -390,7 +392,7 @@ function findClosestLocale(aLocales) {
|
||||
for each (var locale in matchLocales) {
|
||||
var lparts = locale.split("-");
|
||||
for each (var localized in aLocales) {
|
||||
for each (found in localized.locales) {
|
||||
for each (let found in localized.locales) {
|
||||
found = found.toLowerCase();
|
||||
// Exact match is returned immediately
|
||||
if (locale == found)
|
||||
@ -1900,8 +1902,8 @@ var XPIProvider = {
|
||||
return;
|
||||
|
||||
let seenFiles = [];
|
||||
entries = stagingDir.directoryEntries
|
||||
.QueryInterface(Ci.nsIDirectoryEnumerator);
|
||||
let entries = stagingDir.directoryEntries
|
||||
.QueryInterface(Ci.nsIDirectoryEnumerator);
|
||||
while (entries.hasMoreElements()) {
|
||||
let stageDirEntry = entries.getNext().QueryInterface(Ci.nsILocalFile);
|
||||
|
||||
@ -2778,7 +2780,7 @@ var XPIProvider = {
|
||||
}, this);
|
||||
|
||||
// Cache the new install location states
|
||||
cache = JSON.stringify(this.getInstallLocationStates());
|
||||
let cache = JSON.stringify(this.getInstallLocationStates());
|
||||
Services.prefs.setCharPref(PREF_INSTALL_CACHE, cache);
|
||||
|
||||
return changed;
|
||||
@ -3691,6 +3693,50 @@ var XPIProvider = {
|
||||
AddonManagerPrivate.callAddonListeners("onUninstalling", wrapper,
|
||||
requiresRestart);
|
||||
|
||||
// Reveal the highest priority add-on with the same ID
|
||||
function revealAddon(aAddon) {
|
||||
XPIDatabase.makeAddonVisible(aAddon);
|
||||
|
||||
let wrappedAddon = createWrapper(aAddon);
|
||||
AddonManagerPrivate.callAddonListeners("onInstalling", wrappedAddon, false);
|
||||
|
||||
if (!isAddonDisabled(aAddon) && !XPIProvider.enableRequiresRestart(aAddon)) {
|
||||
aAddon.active = true;
|
||||
XPIDatabase.updateAddonActive(aAddon);
|
||||
}
|
||||
|
||||
if (aAddon.bootstrap) {
|
||||
let file = aAddon._installLocation.getLocationForID(aAddon.id);
|
||||
XPIProvider.callBootstrapMethod(aAddon.id, aAddon.version, file,
|
||||
"install", BOOTSTRAP_REASONS.ADDON_INSTALL);
|
||||
|
||||
if (aAddon.active) {
|
||||
XPIProvider.callBootstrapMethod(aAddon.id, aAddon.version, file,
|
||||
"startup", BOOTSTRAP_REASONS.ADDON_INSTALL);
|
||||
}
|
||||
else {
|
||||
XPIProvider.unloadBootstrapScope(aAddon.id);
|
||||
}
|
||||
}
|
||||
|
||||
// We always send onInstalled even if a restart is required to enable
|
||||
// the revealed add-on
|
||||
AddonManagerPrivate.callAddonListeners("onInstalled", wrappedAddon);
|
||||
}
|
||||
|
||||
function checkInstallLocation(aPos) {
|
||||
if (aPos < 0)
|
||||
return;
|
||||
|
||||
let location = XPIProvider.installLocations[aPos];
|
||||
XPIDatabase.getAddonInLocation(aAddon.id, location.name, function(aNewAddon) {
|
||||
if (aNewAddon)
|
||||
revealAddon(aNewAddon);
|
||||
else
|
||||
checkInstallLocation(aPos - 1);
|
||||
})
|
||||
}
|
||||
|
||||
if (!requiresRestart) {
|
||||
if (aAddon.bootstrap) {
|
||||
let file = aAddon._installLocation.getLocationForID(aAddon.id);
|
||||
@ -3708,50 +3754,6 @@ var XPIProvider = {
|
||||
XPIDatabase.removeAddonMetadata(aAddon);
|
||||
AddonManagerPrivate.callAddonListeners("onUninstalled", wrapper);
|
||||
|
||||
// Reveal the highest priority add-on with the same ID
|
||||
function revealAddon(aAddon) {
|
||||
XPIDatabase.makeAddonVisible(aAddon);
|
||||
|
||||
let wrappedAddon = createWrapper(aAddon);
|
||||
AddonManagerPrivate.callAddonListeners("onInstalling", wrappedAddon, false);
|
||||
|
||||
if (!isAddonDisabled(aAddon) && !XPIProvider.enableRequiresRestart(aAddon)) {
|
||||
aAddon.active = true;
|
||||
XPIDatabase.updateAddonActive(aAddon);
|
||||
}
|
||||
|
||||
if (aAddon.bootstrap) {
|
||||
let file = aAddon._installLocation.getLocationForID(aAddon.id);
|
||||
XPIProvider.callBootstrapMethod(aAddon.id, aAddon.version, file,
|
||||
"install", BOOTSTRAP_REASONS.ADDON_INSTALL);
|
||||
|
||||
if (aAddon.active) {
|
||||
XPIProvider.callBootstrapMethod(aAddon.id, aAddon.version, file,
|
||||
"startup", BOOTSTRAP_REASONS.ADDON_INSTALL);
|
||||
}
|
||||
else {
|
||||
XPIProvider.unloadBootstrapScope(aAddon.id);
|
||||
}
|
||||
}
|
||||
|
||||
// We always send onInstalled even if a restart is required to enable
|
||||
// the revealed add-on
|
||||
AddonManagerPrivate.callAddonListeners("onInstalled", wrappedAddon);
|
||||
}
|
||||
|
||||
function checkInstallLocation(aPos) {
|
||||
if (aPos < 0)
|
||||
return;
|
||||
|
||||
let location = XPIProvider.installLocations[aPos];
|
||||
XPIDatabase.getAddonInLocation(aAddon.id, location.name, function(aNewAddon) {
|
||||
if (aNewAddon)
|
||||
revealAddon(aNewAddon);
|
||||
else
|
||||
checkInstallLocation(aPos - 1);
|
||||
})
|
||||
}
|
||||
|
||||
checkInstallLocation(this.installLocations.length - 1);
|
||||
}
|
||||
|
||||
@ -5032,26 +5034,28 @@ var XPIDatabase = {
|
||||
addAddonMetadata: function XPIDB_addAddonMetadata(aAddon, aDescriptor) {
|
||||
this.beginTransaction();
|
||||
|
||||
var self = this;
|
||||
function insertLocale(aLocale) {
|
||||
let localestmt = self.getStatement("addAddonMetadata_locale");
|
||||
let stringstmt = self.getStatement("addAddonMetadata_strings");
|
||||
|
||||
copyProperties(aLocale, PROP_LOCALE_SINGLE, localestmt.params);
|
||||
executeStatement(localestmt);
|
||||
let row = XPIDatabase.connection.lastInsertRowID;
|
||||
|
||||
PROP_LOCALE_MULTI.forEach(function(aProp) {
|
||||
aLocale[aProp].forEach(function(aStr) {
|
||||
stringstmt.params.locale = row;
|
||||
stringstmt.params.type = aProp;
|
||||
stringstmt.params.value = aStr;
|
||||
executeStatement(stringstmt);
|
||||
});
|
||||
});
|
||||
return row;
|
||||
}
|
||||
|
||||
// Any errors in here should rollback the transaction
|
||||
try {
|
||||
let localestmt = this.getStatement("addAddonMetadata_locale");
|
||||
let stringstmt = this.getStatement("addAddonMetadata_strings");
|
||||
|
||||
function insertLocale(aLocale) {
|
||||
copyProperties(aLocale, PROP_LOCALE_SINGLE, localestmt.params);
|
||||
executeStatement(localestmt);
|
||||
let row = XPIDatabase.connection.lastInsertRowID;
|
||||
|
||||
PROP_LOCALE_MULTI.forEach(function(aProp) {
|
||||
aLocale[aProp].forEach(function(aStr) {
|
||||
stringstmt.params.locale = row;
|
||||
stringstmt.params.type = aProp;
|
||||
stringstmt.params.value = aStr;
|
||||
executeStatement(stringstmt);
|
||||
});
|
||||
});
|
||||
return row;
|
||||
}
|
||||
|
||||
if (aAddon.visible) {
|
||||
let stmt = this.getStatement("clearVisibleAddons");
|
||||
@ -7512,7 +7516,7 @@ DirectoryInstallLocation.prototype = {
|
||||
}
|
||||
|
||||
if (entry.isFile() && !directLoad) {
|
||||
newEntry = this._readDirectoryFromFile(entry);
|
||||
let newEntry = this._readDirectoryFromFile(entry);
|
||||
if (!newEntry) {
|
||||
LOG("Deleting stale pointer file " + entry.path);
|
||||
entry.remove(true);
|
||||
|
@ -43,6 +43,8 @@
|
||||
* as passing new installs from webpages to the AddonManager.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cr = Components.results;
|
||||
@ -139,18 +141,18 @@ amManager.prototype = {
|
||||
}
|
||||
let uri = aUris.shift();
|
||||
AddonManager.getInstallForURL(uri, function(aInstall) {
|
||||
function callCallback(aUri, aStatus) {
|
||||
try {
|
||||
aCallback.onInstallEnded(aUri, aStatus);
|
||||
}
|
||||
catch (e) {
|
||||
Components.utils.reportError(e);
|
||||
}
|
||||
}
|
||||
|
||||
if (aInstall) {
|
||||
installs.push(aInstall);
|
||||
if (aCallback) {
|
||||
function callCallback(aUri, aStatus) {
|
||||
try {
|
||||
aCallback.onInstallEnded(aUri, aStatus);
|
||||
}
|
||||
catch (e) {
|
||||
Components.utils.reportError(e);
|
||||
}
|
||||
}
|
||||
|
||||
aInstall.addListener({
|
||||
onDownloadCancelled: function(aInstall) {
|
||||
callCallback(uri, USER_CANCELLED);
|
||||
|
@ -37,6 +37,8 @@
|
||||
# ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cr = Components.results;
|
||||
|
@ -44,6 +44,8 @@
|
||||
* confirmation when all the add-ons have been downloaded.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cr = Components.results;
|
||||
|
@ -36,6 +36,8 @@
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
"use strict";
|
||||
|
||||
function init() {
|
||||
var addon = window.arguments[0];
|
||||
var extensionsStrings = document.getElementById("extensionsStrings");
|
||||
|
@ -35,6 +35,8 @@
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
"use strict";
|
||||
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var gArgs;
|
||||
|
@ -35,6 +35,8 @@
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
"use strict";
|
||||
|
||||
function Startup() {
|
||||
var bundle = document.getElementById("extensionsStrings");
|
||||
var addon = window.arguments[0].addon;
|
||||
|
@ -37,6 +37,8 @@
|
||||
# ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
(function(){
|
||||
|
||||
let Cc = Components.classes;
|
||||
|
@ -35,6 +35,8 @@
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
"use strict";
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cu = Components.utils;
|
||||
@ -225,13 +227,14 @@ var HTML5History = {
|
||||
},
|
||||
|
||||
popState: function() {
|
||||
window.addEventListener("popstate", function(event) {
|
||||
window.removeEventListener("popstate", arguments.callee, true);
|
||||
function onStatePopped(aEvent) {
|
||||
window.removeEventListener("popstate", onStatePopped, true);
|
||||
// TODO To ensure we can't go forward again we put an additional entry
|
||||
// for the current state into the history. Ideally we would just strip
|
||||
// the history but there doesn't seem to be a way to do that. Bug 590661
|
||||
window.history.pushState(event.state, document.title);
|
||||
}, true);
|
||||
window.history.pushState(aEvent.state, document.title);
|
||||
}
|
||||
window.addEventListener("popstate", onStatePopped, true);
|
||||
window.history.back();
|
||||
gViewController.updateCommand("cmd_back");
|
||||
gViewController.updateCommand("cmd_forward");
|
||||
|
@ -75,6 +75,8 @@ const kDialog = "dialog";
|
||||
* result: The dlgtype of button that was used to dismiss the dialog.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var gButtons = { };
|
||||
|
||||
function init() {
|
||||
|
@ -38,6 +38,8 @@
|
||||
|
||||
// This UI is only opened from the Extension Manager when the app is upgraded.
|
||||
|
||||
"use strict";
|
||||
|
||||
const PREF_UPDATE_EXTENSIONS_ENABLED = "extensions.update.enabled";
|
||||
const PREF_XPINSTALL_ENABLED = "xpinstall.enabled";
|
||||
|
||||
|
@ -40,6 +40,8 @@
|
||||
# ***** END LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
const Cr = Components.results;
|
||||
@ -1036,20 +1038,21 @@ Blocklist.prototype = {
|
||||
restartApp();
|
||||
|
||||
Services.obs.notifyObservers(self, "blocklist-updated", "");
|
||||
Services.obs.removeObserver(arguments.callee, "addon-blocklist-closed");
|
||||
Services.obs.removeObserver(applyBlocklistChanges, "addon-blocklist-closed");
|
||||
}
|
||||
|
||||
Services.obs.addObserver(applyBlocklistChanges, "addon-blocklist-closed", false)
|
||||
|
||||
function blocklistUnloadHandler(event) {
|
||||
if (event.target.location == URI_BLOCKLIST_DIALOG) {
|
||||
applyBlocklistChanges();
|
||||
blocklistWindow.removeEventListener("unload", blocklistUnloadHandler);
|
||||
}
|
||||
}
|
||||
|
||||
let blocklistWindow = Services.ww.openWindow(null, URI_BLOCKLIST_DIALOG, "",
|
||||
"chrome,centerscreen,dialog,titlebar", args);
|
||||
|
||||
blocklistWindow.addEventListener("unload", function(event) {
|
||||
if(event.target.location == URI_BLOCKLIST_DIALOG) {
|
||||
applyBlocklistChanges();
|
||||
blocklistWindow.removeEventListener("unload", arguments.callee);
|
||||
}
|
||||
},false)
|
||||
blocklistWindow.addEventListener("unload", blocklistUnloadHandler, false);
|
||||
});
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user