Bug 395311 - EM general code cleanup. r=dtownsend, a1.9=mconnor

This commit is contained in:
rob_strong%exchangecode.com 2007-09-17 18:05:04 +00:00
Родитель 983ed3881d
Коммит d48e36bd11
2 изменённых файлов: 108 добавлений и 137 удалений

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

@ -113,5 +113,3 @@ goOnlineButtonAccesskey=G
newUpdateWindowTitle=%S Add-on Updates newUpdateWindowTitle=%S Add-on Updates
newUpdatesAvailableMsg=There are new updates available for your add-ons. newUpdatesAvailableMsg=There are new updates available for your add-ons.
toolkitName=Gecko Toolkit

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

@ -54,17 +54,6 @@ const Cr = Components.results;
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
const nsIExtensionManager = Ci.nsIExtensionManager;
const nsIAddonUpdateCheckListener = Ci.nsIAddonUpdateCheckListener;
const nsIUpdateItem = Ci.nsIUpdateItem;
const nsILocalFile = Ci.nsILocalFile;
const nsILineInputStream = Ci.nsILineInputStream;
const nsIInstallLocation = Ci.nsIInstallLocation;
const nsIURL = Ci.nsIURL
// XXXrstrong calling hasMoreElements on a nsIDirectoryEnumerator after
// it has been removed will cause a crash on Mac OS X - bug 292823
const nsIDirectoryEnumerator = Ci.nsIDirectoryEnumerator;
const PREF_EM_CHECK_COMPATIBILITY = "extensions.checkCompatibility"; const PREF_EM_CHECK_COMPATIBILITY = "extensions.checkCompatibility";
const PREF_EM_CHECK_UPDATE_SECURITY = "extensions.checkUpdateSecurity"; const PREF_EM_CHECK_UPDATE_SECURITY = "extensions.checkUpdateSecurity";
const PREF_EM_LAST_APP_VERSION = "extensions.lastAppVersion"; const PREF_EM_LAST_APP_VERSION = "extensions.lastAppVersion";
@ -100,8 +89,6 @@ const FILE_CHROME_MANIFEST = "chrome.manifest";
const UNKNOWN_XPCOM_ABI = "unknownABI"; const UNKNOWN_XPCOM_ABI = "unknownABI";
const FILE_LOGFILE = "extensionmanager.log";
const FILE_DEFAULT_THEME_JAR = "classic.jar"; const FILE_DEFAULT_THEME_JAR = "classic.jar";
const TOOLKIT_ID = "toolkit@mozilla.org" const TOOLKIT_ID = "toolkit@mozilla.org"
@ -144,7 +131,6 @@ const XMLURI_PARSE_ERROR = "http://www.mozilla.org/newlayout/xml/pa
const URI_GENERIC_ICON_XPINSTALL = "chrome://mozapps/skin/xpinstall/xpinstallItemGeneric.png"; const URI_GENERIC_ICON_XPINSTALL = "chrome://mozapps/skin/xpinstall/xpinstallItemGeneric.png";
const URI_GENERIC_ICON_THEME = "chrome://mozapps/skin/extensions/themeGeneric.png"; const URI_GENERIC_ICON_THEME = "chrome://mozapps/skin/extensions/themeGeneric.png";
const URI_XPINSTALL_CONFIRM_DIALOG = "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul"; const URI_XPINSTALL_CONFIRM_DIALOG = "chrome://mozapps/content/xpinstall/xpinstallConfirm.xul";
const URI_FINALIZE_DIALOG = "chrome://mozapps/content/extensions/finalize.xul";
const URI_EXTENSIONS_PROPERTIES = "chrome://mozapps/locale/extensions/extensions.properties"; const URI_EXTENSIONS_PROPERTIES = "chrome://mozapps/locale/extensions/extensions.properties";
const URI_BRAND_PROPERTIES = "chrome://branding/locale/brand.properties"; const URI_BRAND_PROPERTIES = "chrome://branding/locale/brand.properties";
const URI_DOWNLOADS_PROPERTIES = "chrome://mozapps/locale/downloads/downloads.properties"; const URI_DOWNLOADS_PROPERTIES = "chrome://mozapps/locale/downloads/downloads.properties";
@ -228,19 +214,6 @@ var BundleManager = {
this._appName = brandBundle.GetStringFromName("brandShortName"); this._appName = brandBundle.GetStringFromName("brandShortName");
} }
return this._appName; return this._appName;
},
_toolkitName: "",
/**
* The toolkit's display name.
*/
get toolkitName() {
if (!this._toolkitName) {
var brandBundle = this.getBundle(URI_EXTENSIONS_PROPERTIES)
this._toolkitName = brandBundle.GetStringFromName("toolkitName");
}
return this._toolkitName;
} }
}; };
@ -381,11 +354,11 @@ function getDirNoCreate(key, pathArray) {
function getDirInternal(key, pathArray, shouldCreate) { function getDirInternal(key, pathArray, shouldCreate) {
var fileLocator = Cc["@mozilla.org/file/directory_service;1"]. var fileLocator = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties); getService(Ci.nsIProperties);
var dir = fileLocator.get(key, nsILocalFile); var dir = fileLocator.get(key, Ci.nsILocalFile);
for (var i = 0; i < pathArray.length; ++i) { for (var i = 0; i < pathArray.length; ++i) {
dir.append(pathArray[i]); dir.append(pathArray[i]);
if (shouldCreate && !dir.exists()) if (shouldCreate && !dir.exists())
dir.create(nsILocalFile.DIRECTORY_TYPE, PERMS_DIRECTORY); dir.create(Ci.nsILocalFile.DIRECTORY_TYPE, PERMS_DIRECTORY);
} }
dir.followLinks = false; dir.followLinks = false;
return dir; return dir;
@ -443,7 +416,7 @@ function getAbsoluteDescriptor(itemLocation) {
*/ */
function getFileFromDescriptor(descriptor, installLocation) { function getFileFromDescriptor(descriptor, installLocation) {
var location = Cc["@mozilla.org/file/local;1"]. var location = Cc["@mozilla.org/file/local;1"].
createInstance(nsILocalFile); createInstance(Ci.nsILocalFile);
var m = descriptor.match(/^(abs|rel)\%(.*)$/); var m = descriptor.match(/^(abs|rel)\%(.*)$/);
if (!m) if (!m)
@ -467,7 +440,7 @@ function getFileFromDescriptor(descriptor, installLocation) {
*/ */
function fileIsItemPackage(file) { function fileIsItemPackage(file) {
var fileURL = getURIFromFile(file); var fileURL = getURIFromFile(file);
if (fileURL instanceof nsIURL) if (fileURL instanceof Ci.nsIURL)
var extension = fileURL.fileExtension.toLowerCase(); var extension = fileURL.fileExtension.toLowerCase();
return extension == "xpi" || extension == "jar"; return extension == "xpi" || extension == "jar";
} }
@ -486,7 +459,7 @@ function openSafeFileOutputStream(file, modeFlags) {
if (modeFlags === undefined) if (modeFlags === undefined)
modeFlags = MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE; modeFlags = MODE_WRONLY | MODE_CREATE | MODE_TRUNCATE;
if (!file.exists()) if (!file.exists())
file.create(nsILocalFile.NORMAL_FILE_TYPE, PERMS_FILE); file.create(Ci.nsILocalFile.NORMAL_FILE_TYPE, PERMS_FILE);
fos.init(file, modeFlags, PERMS_FILE, 0); fos.init(file, modeFlags, PERMS_FILE, 0);
return fos; return fos;
} }
@ -579,9 +552,9 @@ function getRandomFileName(fileName) {
* @returns The RDF URI prefix. * @returns The RDF URI prefix.
*/ */
function getItemPrefix(type) { function getItemPrefix(type) {
if (type & nsIUpdateItem.TYPE_EXTENSION) if (type & Ci.nsIUpdateItem.TYPE_EXTENSION)
return PREFIX_EXTENSION; return PREFIX_EXTENSION;
else if (type & nsIUpdateItem.TYPE_THEME) else if (type & Ci.nsIUpdateItem.TYPE_THEME)
return PREFIX_THEME; return PREFIX_THEME;
return PREFIX_ITEM_URI; return PREFIX_ITEM_URI;
} }
@ -706,10 +679,10 @@ function getAddonTypeFromInstallManifest(installManifest) {
// Install Manifest, so we fall back to a theme-only property to // Install Manifest, so we fall back to a theme-only property to
// differentiate. // differentiate.
if (getManifestProperty(installManifest, "internalName") !== undefined) if (getManifestProperty(installManifest, "internalName") !== undefined)
return nsIUpdateItem.TYPE_THEME; return Ci.nsIUpdateItem.TYPE_THEME;
// If no type is provided, default to "Extension" // If no type is provided, default to "Extension"
return nsIUpdateItem.TYPE_EXTENSION; return Ci.nsIUpdateItem.TYPE_EXTENSION;
} }
/** /**
@ -782,7 +755,7 @@ function showBlocklistMessage(items, fromInstall) {
if (fromInstall) { if (fromInstall) {
var wm = Cc["@mozilla.org/appshell/window-mediator;1"]. var wm = Cc["@mozilla.org/appshell/window-mediator;1"].
getService(Ci.nsIWindowMediator); getService(Ci.nsIWindowMediator);
win = wm.getMostRecentWindow(nsIUpdateItem.TYPE_THEME ? "Extension:Manager-themes" : win = wm.getMostRecentWindow(Ci.nsIUpdateItem.TYPE_THEME ? "Extension:Manager-themes" :
"Extension:Manager-extensions"); "Extension:Manager-extensions");
} }
var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"]. var ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].
@ -853,7 +826,7 @@ function getInstallManifest(file) {
var uri = Cc["@mozilla.org/network/io-service;1"]. var uri = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService) getService(Ci.nsIIOService)
.newFileURI(file); .newFileURI(file);
var url = uri.QueryInterface(nsIURL); var url = uri.QueryInterface(Ci.nsIURL);
showMessage("malformedTitle", [], "malformedMessage", showMessage("malformedTitle", [], "malformedMessage",
[BundleManager.appName, url.fileName]); [BundleManager.appName, url.fileName]);
} }
@ -949,7 +922,7 @@ function DirectoryInstallLocation(name, location, restricted, priority) {
} }
else { else {
try { try {
location.create(nsILocalFile.DIRECTORY_TYPE, 0775); location.create(Ci.nsILocalFile.DIRECTORY_TYPE, 0775);
} }
catch (e) { catch (e) {
LOG("DirectoryInstallLocation: failed to create location " + LOG("DirectoryInstallLocation: failed to create location " +
@ -988,12 +961,12 @@ DirectoryInstallLocation.prototype = {
createInstance(Ci.nsIFileInputStream); createInstance(Ci.nsIFileInputStream);
fis.init(file, -1, -1, false); fis.init(file, -1, -1, false);
var line = { value: "" }; var line = { value: "" };
if (fis instanceof nsILineInputStream) if (fis instanceof Ci.nsILineInputStream)
fis.readLine(line); fis.readLine(line);
fis.close(); fis.close();
if (line.value) { if (line.value) {
var linkedDirectory = Cc["@mozilla.org/file/local;1"]. var linkedDirectory = Cc["@mozilla.org/file/local;1"].
createInstance(nsILocalFile); createInstance(Ci.nsILocalFile);
try { try {
linkedDirectory.initWithPath(line.value); linkedDirectory.initWithPath(line.value);
} }
@ -1015,12 +988,12 @@ DirectoryInstallLocation.prototype = {
return new FileEnumerator(locations); return new FileEnumerator(locations);
try { try {
var entries = this._location.directoryEntries.QueryInterface(nsIDirectoryEnumerator); var entries = this._location.directoryEntries.QueryInterface(Ci.nsIDirectoryEnumerator);
while (true) { while (true) {
var entry = entries.nextFile; var entry = entries.nextFile;
if (!entry) if (!entry)
break; break;
entry instanceof nsILocalFile; entry instanceof Ci.nsILocalFile;
if (!entry.isDirectory() && gIDTest.test(entry.leafName)) { if (!entry.isDirectory() && gIDTest.test(entry.leafName)) {
var linkedDirectory = this._readDirectoryFromFile(entry); var linkedDirectory = this._readDirectoryFromFile(entry);
if (linkedDirectory && linkedDirectory.exists() && if (linkedDirectory && linkedDirectory.exists() &&
@ -1083,7 +1056,7 @@ DirectoryInstallLocation.prototype = {
var testFile = this.location; var testFile = this.location;
testFile.append("Access Privileges Test"); testFile.append("Access Privileges Test");
try { try {
testFile.createUnique(nsILocalFile.DIRECTORY_TYPE, PERMS_DIRECTORY); testFile.createUnique(Ci.nsILocalFile.DIRECTORY_TYPE, PERMS_DIRECTORY);
testFile.remove(false); testFile.remove(false);
this._canAccess = true; this._canAccess = true;
} }
@ -1109,7 +1082,7 @@ DirectoryInstallLocation.prototype = {
if (itemLocation.exists() && !itemLocation.isDirectory()) if (itemLocation.exists() && !itemLocation.isDirectory())
return this._readDirectoryFromFile(itemLocation); return this._readDirectoryFromFile(itemLocation);
if (!itemLocation.exists() && this.canAccess) if (!itemLocation.exists() && this.canAccess)
itemLocation.create(nsILocalFile.DIRECTORY_TYPE, PERMS_DIRECTORY); itemLocation.create(Ci.nsILocalFile.DIRECTORY_TYPE, PERMS_DIRECTORY);
return itemLocation; return itemLocation;
}, },
@ -1177,10 +1150,10 @@ DirectoryInstallLocation.prototype = {
if (!stageDir.exists() || !stageDir.isDirectory()) if (!stageDir.exists() || !stageDir.isDirectory())
return null; return null;
try { try {
var entries = stageDir.directoryEntries.QueryInterface(nsIDirectoryEnumerator); var entries = stageDir.directoryEntries.QueryInterface(Ci.nsIDirectoryEnumerator);
while (entries.hasMoreElements()) { while (entries.hasMoreElements()) {
var file = entries.nextFile; var file = entries.nextFile;
if (!(file instanceof nsILocalFile)) if (!(file instanceof Ci.nsILocalFile))
continue; continue;
if (file.isDirectory()) if (file.isDirectory())
removeDirRecursive(file); removeDirRecursive(file);
@ -1195,7 +1168,7 @@ DirectoryInstallLocation.prototype = {
} }
catch (e) { catch (e) {
} }
if (entries instanceof nsIDirectoryEnumerator) if (entries instanceof Ci.nsIDirectoryEnumerator)
entries.close(); entries.close();
return stageFile; return stageFile;
}, },
@ -1220,7 +1193,7 @@ DirectoryInstallLocation.prototype = {
parent = parent.parent; parent = parent.parent;
entries = parent.directoryEntries; entries = parent.directoryEntries;
} }
if (entries instanceof nsIDirectoryEnumerator) if (entries instanceof Ci.nsIDirectoryEnumerator)
entries.close(); entries.close();
} }
catch (e) { catch (e) {
@ -1315,7 +1288,7 @@ WinRegInstallLocation.prototype = {
var id = key.getValueName(i); var id = key.getValueName(i);
var dir = Cc["@mozilla.org/file/local;1"]. var dir = Cc["@mozilla.org/file/local;1"].
createInstance(nsILocalFile); createInstance(Ci.nsILocalFile);
dir.initWithPath(key.readStringValue(id)); dir.initWithPath(key.readStringValue(id));
if (dir.exists() && dir.isDirectory()) { if (dir.exists() && dir.isDirectory()) {
@ -1432,7 +1405,7 @@ Installer.prototype = {
return; return;
// Upgrade old-style contents.rdf Chrome Manifests if necessary. // Upgrade old-style contents.rdf Chrome Manifests if necessary.
if (this._type == nsIUpdateItem.TYPE_THEME) if (this._type == Ci.nsIUpdateItem.TYPE_THEME)
this.upgradeThemeChrome(); this.upgradeThemeChrome();
else else
this.upgradeExtensionChrome(); this.upgradeExtensionChrome();
@ -1471,7 +1444,7 @@ Installer.prototype = {
var target = installLocation.getItemFile(extensionID, entryName); var target = installLocation.getItemFile(extensionID, entryName);
if (!target.exists()) { if (!target.exists()) {
try { try {
target.create(nsILocalFile.DIRECTORY_TYPE, PERMS_DIRECTORY); target.create(Ci.nsILocalFile.DIRECTORY_TYPE, PERMS_DIRECTORY);
} }
catch (e) { catch (e) {
LOG("extractExtensionsFiles: failed to create target directory for extraction " + LOG("extractExtensionsFiles: failed to create target directory for extraction " +
@ -1488,7 +1461,7 @@ Installer.prototype = {
continue; continue;
try { try {
target.create(nsILocalFile.NORMAL_FILE_TYPE, PERMS_FILE); target.create(Ci.nsILocalFile.NORMAL_FILE_TYPE, PERMS_FILE);
} }
catch (e) { catch (e) {
LOG("extractExtensionsFiles: failed to create target file for extraction " + LOG("extractExtensionsFiles: failed to create target file for extraction " +
@ -1536,7 +1509,7 @@ Installer.prototype = {
continue; continue;
target = installLocation.getItemFile(id, entryName); target = installLocation.getItemFile(id, entryName);
try { try {
target.create(nsILocalFile.NORMAL_FILE_TYPE, PERMS_FILE); target.create(Ci.nsILocalFile.NORMAL_FILE_TYPE, PERMS_FILE);
} }
catch (e) { catch (e) {
LOG("extractThemeFiles: failed to create target file for extraction " + LOG("extractThemeFiles: failed to create target file for extraction " +
@ -1549,7 +1522,7 @@ Installer.prototype = {
else { // old theme structure requires only an install.rdf else { // old theme structure requires only an install.rdf
try { try {
var contentsManifestFile = installLocation.getItemFile(id, FILE_CONTENTS_MANIFEST); var contentsManifestFile = installLocation.getItemFile(id, FILE_CONTENTS_MANIFEST);
contentsManifestFile.create(nsILocalFile.NORMAL_FILE_TYPE, PERMS_FILE); contentsManifestFile.create(Ci.nsILocalFile.NORMAL_FILE_TYPE, PERMS_FILE);
zipReader.extract(FILE_CONTENTS_MANIFEST, contentsManifestFile); zipReader.extract(FILE_CONTENTS_MANIFEST, contentsManifestFile);
} }
catch (e) { catch (e) {
@ -1567,7 +1540,7 @@ Installer.prototype = {
throw e; // let the safe-op clean up throw e; // let the safe-op clean up
} }
if (!installer.metadataDS && installer._type == nsIUpdateItem.TYPE_THEME) { if (!installer.metadataDS && installer._type == Ci.nsIUpdateItem.TYPE_THEME) {
var themeName = extensionStrings.GetStringFromName("incompatibleThemeName"); var themeName = extensionStrings.GetStringFromName("incompatibleThemeName");
if (contentsManifestFile && contentsManifestFile.exists()) { if (contentsManifestFile && contentsManifestFile.exists()) {
var contentsManifest = gRDF.GetDataSourceBlocking(getURLSpecFromFile(contentsManifestFile)); var contentsManifest = gRDF.GetDataSourceBlocking(getURLSpecFromFile(contentsManifestFile));
@ -1577,7 +1550,7 @@ Installer.prototype = {
var elts = ctr.GetElements(); var elts = ctr.GetElements();
var nameArc = gRDF.GetResource(CHROME_NS("displayName")); var nameArc = gRDF.GetResource(CHROME_NS("displayName"));
while (elts.hasMoreElements()) { while (elts.hasMoreElements()) {
var elt = elts.getNext().QueryInterface(Components.interfaces.nsIRDFResource); var elt = elts.getNext().QueryInterface(Ci.nsIRDFResource);
themeName = stringData(contentsManifest.GetTarget(elt, nameArc, true)); themeName = stringData(contentsManifest.GetTarget(elt, nameArc, true));
if (themeName) if (themeName)
break; break;
@ -1588,7 +1561,7 @@ Installer.prototype = {
} }
} }
showIncompatibleError({ name: themeName, version: "", showIncompatibleError({ name: themeName, version: "",
type: nsIUpdateItem.TYPE_THEME }); type: Ci.nsIUpdateItem.TYPE_THEME });
LOG("Theme JAR file: " + jarFile.leafName + " contains an Old-Style " + LOG("Theme JAR file: " + jarFile.leafName + " contains an Old-Style " +
"Theme that is not compatible with this version of the software."); "Theme that is not compatible with this version of the software.");
throw new Error("Old Theme"); // let the safe-op clean up throw new Error("Old Theme"); // let the safe-op clean up
@ -1598,7 +1571,7 @@ Installer.prototype = {
var installer = this; var installer = this;
var callback = extractExtensionFiles; var callback = extractExtensionFiles;
if (this._type == nsIUpdateItem.TYPE_THEME) if (this._type == Ci.nsIUpdateItem.TYPE_THEME)
callback = extractThemeFiles; callback = extractThemeFiles;
safeInstallOperation(this._id, this._installLocation, safeInstallOperation(this._id, this._installLocation,
{ callback: callback, data: file }); { callback: callback, data: file });
@ -1623,7 +1596,7 @@ Installer.prototype = {
var chromeDir = this._installLocation.getItemFile(this._id, DIR_CHROME); var chromeDir = this._installLocation.getItemFile(this._id, DIR_CHROME);
// We're relying on the fact that there is only one JAR file // We're relying on the fact that there is only one JAR file
// in the "chrome" directory. This is a hack, but it works. // in the "chrome" directory. This is a hack, but it works.
var entries = chromeDir.directoryEntries.QueryInterface(nsIDirectoryEnumerator); var entries = chromeDir.directoryEntries.QueryInterface(Ci.nsIDirectoryEnumerator);
var jarFile = entries.nextFile; var jarFile = entries.nextFile;
if (jarFile) { if (jarFile) {
var jarFileURI = getURIFromFile(jarFile); var jarFileURI = getURIFromFile(jarFile);
@ -1680,7 +1653,7 @@ Installer.prototype = {
// Even if an extension doesn't have any chrome, we generate an empty // Even if an extension doesn't have any chrome, we generate an empty
// manifest file so that we don't try to upgrade from the "old-style" // manifest file so that we don't try to upgrade from the "old-style"
// chrome manifests at every startup. // chrome manifests at every startup.
manifestFile.create(nsILocalFile.NORMAL_FILE_TYPE, PERMS_FILE); manifestFile.create(Ci.nsILocalFile.NORMAL_FILE_TYPE, PERMS_FILE);
var manifestURI = getURIFromFile(manifestFile); var manifestURI = getURIFromFile(manifestFile);
var files = this.metadataDS.GetTargets(gInstallManifestRoot, EM_R("file"), true); var files = this.metadataDS.GetTargets(gInstallManifestRoot, EM_R("file"), true);
@ -1695,7 +1668,7 @@ Installer.prototype = {
var zipReader = getZipReaderForFile(chromeFile); var zipReader = getZipReaderForFile(chromeFile);
fileURLSpec = "jar:" + fileURLSpec + "!/"; fileURLSpec = "jar:" + fileURLSpec + "!/";
var contentsFile = this._installLocation.getItemFile(this._id, FILE_CONTENTS_MANIFEST); var contentsFile = this._installLocation.getItemFile(this._id, FILE_CONTENTS_MANIFEST);
contentsFile.create(nsILocalFile.NORMAL_FILE_TYPE, PERMS_FILE); contentsFile.create(Ci.nsILocalFile.NORMAL_FILE_TYPE, PERMS_FILE);
} }
var providers = [EM_R("package"), EM_R("skin"), EM_R("locale")]; var providers = [EM_R("package"), EM_R("skin"), EM_R("locale")];
@ -1825,16 +1798,16 @@ function safeInstallOperation(itemID, installLocation, installCallback) {
* |sourceDir| itself) we are moving files from. * |sourceDir| itself) we are moving files from.
*/ */
function moveDirectory(sourceDir, targetDir, currentDir) { function moveDirectory(sourceDir, targetDir, currentDir) {
var entries = currentDir.directoryEntries.QueryInterface(nsIDirectoryEnumerator); var entries = currentDir.directoryEntries.QueryInterface(Ci.nsIDirectoryEnumerator);
while (true) { while (true) {
var entry = entries.nextFile; var entry = entries.nextFile;
if (!entry) if (!entry)
break; break;
if (entry.isDirectory()) if (entry.isDirectory())
moveDirectory(sourceDir, targetDir, entry); moveDirectory(sourceDir, targetDir, entry);
else if (entry instanceof nsILocalFile) { else if (entry instanceof Ci.nsILocalFile) {
var rd = entry.getRelativeDescriptor(sourceDir); var rd = entry.getRelativeDescriptor(sourceDir);
var destination = targetDir.clone().QueryInterface(nsILocalFile); var destination = targetDir.clone().QueryInterface(Ci.nsILocalFile);
destination.setRelativeDescriptor(targetDir, rd); destination.setRelativeDescriptor(targetDir, rd);
moveFile(entry, destination.parent); moveFile(entry, destination.parent);
} }
@ -1922,7 +1895,7 @@ function safeInstallOperation(itemID, installLocation, installCallback) {
throw e; throw e;
} }
} }
itemLocationTrash.create(nsILocalFile.DIRECTORY_TYPE, PERMS_DIRECTORY); itemLocationTrash.create(Ci.nsILocalFile.DIRECTORY_TYPE, PERMS_DIRECTORY);
// Move the pointer file to the trash. // Move the pointer file to the trash.
moveFile(pointerFile, itemLocationTrash); moveFile(pointerFile, itemLocationTrash);
} }
@ -2115,7 +2088,7 @@ var StartupCache = {
var descriptor = null; var descriptor = null;
var mtime = null; var mtime = null;
if (itemLocation) { if (itemLocation) {
itemLocation.QueryInterface(nsILocalFile); itemLocation.QueryInterface(Ci.nsILocalFile);
descriptor = getDescriptorFromFile(itemLocation, installLocation); descriptor = getDescriptorFromFile(itemLocation, installLocation);
if (itemLocation.exists() && itemLocation.isDirectory()) if (itemLocation.exists() && itemLocation.isDirectory())
mtime = Math.floor(itemLocation.lastModifiedTime / 1000); mtime = Math.floor(itemLocation.lastModifiedTime / 1000);
@ -2210,7 +2183,7 @@ var StartupCache = {
var fis = Cc["@mozilla.org/network/file-input-stream;1"]. var fis = Cc["@mozilla.org/network/file-input-stream;1"].
createInstance(Ci.nsIFileInputStream); createInstance(Ci.nsIFileInputStream);
fis.init(itemChangeManifest, -1, -1, false); fis.init(itemChangeManifest, -1, -1, false);
if (fis instanceof nsILineInputStream) { if (fis instanceof Ci.nsILineInputStream) {
var line = { value: "" }; var line = { value: "" };
var more = false; var more = false;
do { do {
@ -2304,7 +2277,7 @@ function ExtensionManager() {
// Register Global Install Location // Register Global Install Location
var appGlobalExtensions = getDirNoCreate(KEY_APPDIR, [DIR_EXTENSIONS]); var appGlobalExtensions = getDirNoCreate(KEY_APPDIR, [DIR_EXTENSIONS]);
var priority = nsIInstallLocation.PRIORITY_APP_SYSTEM_GLOBAL; var priority = Ci.nsIInstallLocation.PRIORITY_APP_SYSTEM_GLOBAL;
var globalLocation = new DirectoryInstallLocation(KEY_APP_GLOBAL, var globalLocation = new DirectoryInstallLocation(KEY_APP_GLOBAL,
appGlobalExtensions, true, appGlobalExtensions, true,
priority); priority);
@ -2312,7 +2285,7 @@ function ExtensionManager() {
// Register App-Profile Install Location // Register App-Profile Install Location
var appProfileExtensions = getDirNoCreate(KEY_PROFILEDS, [DIR_EXTENSIONS]); var appProfileExtensions = getDirNoCreate(KEY_PROFILEDS, [DIR_EXTENSIONS]);
var priority = nsIInstallLocation.PRIORITY_APP_PROFILE; var priority = Ci.nsIInstallLocation.PRIORITY_APP_PROFILE;
var profileLocation = new DirectoryInstallLocation(KEY_APP_PROFILE, var profileLocation = new DirectoryInstallLocation(KEY_APP_PROFILE,
appProfileExtensions, false, appProfileExtensions, false,
priority); priority);
@ -2324,14 +2297,14 @@ function ExtensionManager() {
new WinRegInstallLocation("winreg-app-global", new WinRegInstallLocation("winreg-app-global",
nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE, nsIWindowsRegKey.ROOT_KEY_LOCAL_MACHINE,
true, true,
nsIInstallLocation.PRIORITY_APP_SYSTEM_GLOBAL + 10)); Ci.nsIInstallLocation.PRIORITY_APP_SYSTEM_GLOBAL + 10));
// Register HKEY_CURRENT_USER Install Location // Register HKEY_CURRENT_USER Install Location
InstallLocations.put( InstallLocations.put(
new WinRegInstallLocation("winreg-app-user", new WinRegInstallLocation("winreg-app-user",
nsIWindowsRegKey.ROOT_KEY_CURRENT_USER, nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
false, false,
nsIInstallLocation.PRIORITY_APP_SYSTEM_USER + 10)); Ci.nsIInstallLocation.PRIORITY_APP_SYSTEM_USER + 10));
#endif #endif
// Register Additional Install Locations // Register Additional Install Locations
@ -2341,7 +2314,7 @@ function ExtensionManager() {
while (locations.hasMoreElements()) { while (locations.hasMoreElements()) {
var entry = locations.getNext().QueryInterface(Ci.nsISupportsCString).data; var entry = locations.getNext().QueryInterface(Ci.nsISupportsCString).data;
var contractID = categoryManager.getCategoryEntry(CATEGORY_INSTALL_LOCATIONS, entry); var contractID = categoryManager.getCategoryEntry(CATEGORY_INSTALL_LOCATIONS, entry);
var location = Cc[contractID].getService(nsIInstallLocation); var location = Cc[contractID].getService(Ci.nsIInstallLocation);
InstallLocations.put(location); InstallLocations.put(location);
} }
} }
@ -2604,11 +2577,11 @@ ExtensionManager.prototype = {
if (!getPref("getBoolPref", PREF_EM_UPDATE_ENABLED, true)) if (!getPref("getBoolPref", PREF_EM_UPDATE_ENABLED, true))
return; return;
var items = this.getItemList(nsIUpdateItem.TYPE_ADDON, { }); var items = this.getItemList(Ci.nsIUpdateItem.TYPE_ADDON, { });
var updater = new ExtensionItemUpdater(gApp.ID, gApp.version, this); var updater = new ExtensionItemUpdater(gApp.ID, gApp.version, this);
updater.checkForUpdates(items, items.length, updater.checkForUpdates(items, items.length,
nsIExtensionManager.UPDATE_CHECK_NEWVERSION, Ci.nsIExtensionManager.UPDATE_CHECK_NEWVERSION,
new BackgroundUpdateCheckListener(this.datasource)); new BackgroundUpdateCheckListener(this.datasource));
}, },
@ -2653,7 +2626,7 @@ ExtensionManager.prototype = {
InstallLocations.get(KEY_APP_GLOBAL), InstallLocations.get(KEY_APP_GLOBAL),
installData.type); installData.type);
installer._installExtensionFiles(file); installer._installExtensionFiles(file);
if (installData.type == nsIUpdateItem.TYPE_THEME) if (installData.type == Ci.nsIUpdateItem.TYPE_THEME)
installer.upgradeThemeChrome(); installer.upgradeThemeChrome();
else else
installer.upgradeExtensionChrome(); installer.upgradeExtensionChrome();
@ -2897,7 +2870,7 @@ ExtensionManager.prototype = {
// enumeration returned is pre-sorted. // enumeration returned is pre-sorted.
var installLocations = this.installLocations; var installLocations = this.installLocations;
while (installLocations.hasMoreElements()) { while (installLocations.hasMoreElements()) {
var location = installLocations.getNext().QueryInterface(nsIInstallLocation); var location = installLocations.getNext().QueryInterface(Ci.nsIInstallLocation);
// Hash the set of items actually held by the Install Location. // Hash the set of items actually held by the Install Location.
var actualItems = { }; var actualItems = { };
@ -3088,8 +3061,8 @@ ExtensionManager.prototype = {
// If we have extensions that were installed before the new flat chrome // If we have extensions that were installed before the new flat chrome
// manifests, and are still valid, we need to manually create the flat // manifests, and are still valid, we need to manually create the flat
// manifest files. // manifest files.
var extensions = this._getActiveItems(nsIUpdateItem.TYPE_EXTENSION + var extensions = this._getActiveItems(Ci.nsIUpdateItem.TYPE_EXTENSION +
nsIUpdateItem.TYPE_LOCALE); Ci.nsIUpdateItem.TYPE_LOCALE);
for (var i = 0; i < extensions.length; ++i) { for (var i = 0; i < extensions.length; ++i) {
var e = extensions[i]; var e = extensions[i];
var itemLocation = e.location.getItemLocation(e.id); var itemLocation = e.location.getItemLocation(e.id);
@ -3103,7 +3076,7 @@ ExtensionManager.prototype = {
var itemLocation = installLocation.getItemLocation(e.id); var itemLocation = installLocation.getItemLocation(e.id);
if (itemLocation.exists() && itemLocation.isDirectory()) { if (itemLocation.exists() && itemLocation.isDirectory()) {
var installer = new Installer(ds, e.id, installLocation, var installer = new Installer(ds, e.id, installLocation,
nsIUpdateItem.TYPE_EXTENSION); Ci.nsIUpdateItem.TYPE_EXTENSION);
installer.upgradeExtensionChrome(); installer.upgradeExtensionChrome();
} }
} }
@ -3116,7 +3089,7 @@ ExtensionManager.prototype = {
} }
} }
var themes = this._getActiveItems(nsIUpdateItem.TYPE_THEME); var themes = this._getActiveItems(Ci.nsIUpdateItem.TYPE_THEME);
// If we have themes that were installed before the new flat chrome // If we have themes that were installed before the new flat chrome
// manifests, and are still valid, we need to manually create the flat // manifests, and are still valid, we need to manually create the flat
// manifest files. // manifest files.
@ -3143,7 +3116,7 @@ ExtensionManager.prototype = {
// We're relying on the fact that there is only one JAR file // We're relying on the fact that there is only one JAR file
// in the "chrome" directory. This is a hack, but it works. // in the "chrome" directory. This is a hack, but it works.
entries = chromeDir.directoryEntries.QueryInterface(nsIDirectoryEnumerator); entries = chromeDir.directoryEntries.QueryInterface(Ci.nsIDirectoryEnumerator);
var jarFile = entries.nextFile; var jarFile = entries.nextFile;
if (jarFile) { if (jarFile) {
var jarFileURI = getURIFromFile(jarFile); var jarFileURI = getURIFromFile(jarFile);
@ -3563,7 +3536,7 @@ ExtensionManager.prototype = {
if (!entry.isDirectory() || installRDF.exists() || !chromeDir.exists()) if (!entry.isDirectory() || installRDF.exists() || !chromeDir.exists())
continue; continue;
var chromeEntries = chromeDir.directoryEntries.QueryInterface(nsIDirectoryEnumerator); var chromeEntries = chromeDir.directoryEntries.QueryInterface(Ci.nsIDirectoryEnumerator);
if (!chromeEntries.hasMoreElements()) if (!chromeEntries.hasMoreElements())
continue; continue;
@ -3627,7 +3600,7 @@ ExtensionManager.prototype = {
var currAppID = gApp.ID; var currAppID = gApp.ID;
for (var i = 0; i < itemsToCheck.length; ++i) { for (var i = 0; i < itemsToCheck.length; ++i) {
var item = ds.getItemForID(itemsToCheck[i]); var item = ds.getItemForID(itemsToCheck[i]);
var oldPrefix = (item.type == nsIUpdateItem.TYPE_EXTENSION) ? PREFIX_EXTENSION : PREFIX_THEME; var oldPrefix = (item.type == Ci.nsIUpdateItem.TYPE_EXTENSION) ? PREFIX_EXTENSION : PREFIX_THEME;
var oldRes = gRDF.GetResource(oldPrefix + item.id); var oldRes = gRDF.GetResource(oldPrefix + item.id);
// Disable the item if it was disabled in the version 1.0 extensions // Disable the item if it was disabled in the version 1.0 extensions
// datasource. // datasource.
@ -3732,9 +3705,9 @@ ExtensionManager.prototype = {
// //
// To do this we obtain a list of active extensions and themes and write // To do this we obtain a list of active extensions and themes and write
// these to the extensions.ini file in the profile directory. // these to the extensions.ini file in the profile directory.
var validExtensions = this._getActiveItems(nsIUpdateItem.TYPE_EXTENSION + var validExtensions = this._getActiveItems(Ci.nsIUpdateItem.TYPE_EXTENSION +
nsIUpdateItem.TYPE_LOCALE); Ci.nsIUpdateItem.TYPE_LOCALE);
var validThemes = this._getActiveItems(nsIUpdateItem.TYPE_THEME); var validThemes = this._getActiveItems(Ci.nsIUpdateItem.TYPE_THEME);
var extensionsLocationsFile = getFile(KEY_PROFILEDIR, [FILE_EXTENSION_MANIFEST]); var extensionsLocationsFile = getFile(KEY_PROFILEDIR, [FILE_EXTENSION_MANIFEST]);
var fos = openSafeFileOutputStream(extensionsLocationsFile); var fos = openSafeFileOutputStream(extensionsLocationsFile);
@ -3743,7 +3716,7 @@ ExtensionManager.prototype = {
fos.write(extensionSectionHeader, extensionSectionHeader.length); fos.write(extensionSectionHeader, extensionSectionHeader.length);
for (var i = 0; i < validExtensions.length; ++i) { for (var i = 0; i < validExtensions.length; ++i) {
var e = validExtensions[i]; var e = validExtensions[i];
var itemLocation = e.location.getItemLocation(e.id).QueryInterface(nsILocalFile); var itemLocation = e.location.getItemLocation(e.id).QueryInterface(Ci.nsILocalFile);
var descriptor = getAbsoluteDescriptor(itemLocation); var descriptor = getAbsoluteDescriptor(itemLocation);
var line = "Extension" + i + "=" + descriptor + "\r\n"; var line = "Extension" + i + "=" + descriptor + "\r\n";
fos.write(line, line.length); fos.write(line, line.length);
@ -3753,7 +3726,7 @@ ExtensionManager.prototype = {
fos.write(themeSectionHeader, themeSectionHeader.length); fos.write(themeSectionHeader, themeSectionHeader.length);
for (i = 0; i < validThemes.length; ++i) { for (i = 0; i < validThemes.length; ++i) {
var e = validThemes[i]; var e = validThemes[i];
var itemLocation = e.location.getItemLocation(e.id).QueryInterface(nsILocalFile); var itemLocation = e.location.getItemLocation(e.id).QueryInterface(Ci.nsILocalFile);
var descriptor = getAbsoluteDescriptor(itemLocation); var descriptor = getAbsoluteDescriptor(itemLocation);
var line = "Extension" + i + "=" + descriptor + "\r\n"; var line = "Extension" + i + "=" + descriptor + "\r\n";
fos.write(line, line.length); fos.write(line, line.length);
@ -3781,7 +3754,7 @@ ExtensionManager.prototype = {
try { try {
var autoregFile = getFile(KEY_PROFILEDIR, [FILE_AUTOREG]); var autoregFile = getFile(KEY_PROFILEDIR, [FILE_AUTOREG]);
if (val && !autoregFile.exists()) if (val && !autoregFile.exists())
autoregFile.create(nsILocalFile.NORMAL_FILE_TYPE, PERMS_FILE); autoregFile.create(Ci.nsILocalFile.NORMAL_FILE_TYPE, PERMS_FILE);
} }
catch (e) { catch (e) {
} }
@ -4058,7 +4031,7 @@ ExtensionManager.prototype = {
var branch = settingsThingy.getBranch(appPrefix + targetApp.id); var branch = settingsThingy.getBranch(appPrefix + targetApp.id);
var path = branch.getProperty("ExtensionsLocation"); var path = branch.getProperty("ExtensionsLocation");
var destination = Cc["@mozilla.org/file/local;1"]. var destination = Cc["@mozilla.org/file/local;1"].
createInstance(nsILocalFile); createInstance(Ci.nsILocalFile);
destination.initWithPath(path); destination.initWithPath(path);
xpiFile.copyTo(file, xpiFile.leafName); xpiFile.copyTo(file, xpiFile.leafName);
} }
@ -4074,7 +4047,7 @@ ExtensionManager.prototype = {
* within a xpi. * within a xpi.
*/ */
function installMultiXPI(xpiFile, installData) { function installMultiXPI(xpiFile, installData) {
var fileURL = getURIFromFile(xpiFile).QueryInterface(nsIURL); var fileURL = getURIFromFile(xpiFile).QueryInterface(Ci.nsIURL);
if (fileURL.fileExtension.toLowerCase() != "xpi") { if (fileURL.fileExtension.toLowerCase() != "xpi") {
LOG("Invalid File Extension: Item: \"" + fileURL.fileName + "\" has an " + LOG("Invalid File Extension: Item: \"" + fileURL.fileName + "\" has an " +
"invalid file extension. Only xpi file extensions are allowed for " + "invalid file extension. Only xpi file extensions are allowed for " +
@ -4103,7 +4076,7 @@ ExtensionManager.prototype = {
var entryName = entries.getNext(); var entryName = entries.getNext();
var target = getFile(KEY_TEMPDIR, [entryName]); var target = getFile(KEY_TEMPDIR, [entryName]);
try { try {
target.createUnique(nsILocalFile.NORMAL_FILE_TYPE, PERMS_FILE); target.createUnique(Ci.nsILocalFile.NORMAL_FILE_TYPE, PERMS_FILE);
} }
catch (e) { catch (e) {
LOG("installMultiXPI: failed to create target file for extraction " + LOG("installMultiXPI: failed to create target file for extraction " +
@ -4139,7 +4112,7 @@ ExtensionManager.prototype = {
function IncompatibleObserver() {} function IncompatibleObserver() {}
IncompatibleObserver.prototype = { IncompatibleObserver.prototype = {
_id: null, _id: null,
_type: nsIUpdateItem.TYPE_ANY, _type: Ci.nsIUpdateItem.TYPE_ANY,
_xpi: null, _xpi: null,
_installManifest: null, _installManifest: null,
_installRDF: null, _installRDF: null,
@ -4175,7 +4148,7 @@ ExtensionManager.prototype = {
installData.updateKey || "", installData.updateKey || "",
installData.type, installData.type,
installData.currentApp.id); installData.currentApp.id);
em.update([item], 1, nsIExtensionManager.UPDATE_CHECK_COMPATIBILITY, this); em.update([item], 1, Ci.nsIExtensionManager.UPDATE_CHECK_COMPATIBILITY, this);
}, },
/** /**
@ -4218,7 +4191,7 @@ ExtensionManager.prototype = {
LOG("Version Check Phone Home Completed"); LOG("Version Check Phone Home Completed");
// Only compatibility updates (e.g. STATUS_VERSIONINFO) are currently // Only compatibility updates (e.g. STATUS_VERSIONINFO) are currently
// supported // supported
if (status == nsIAddonUpdateCheckListener.STATUS_VERSIONINFO) { if (status == Ci.nsIAddonUpdateCheckListener.STATUS_VERSIONINFO) {
em.datasource.setTargetApplicationInfo(addon.id, em.datasource.setTargetApplicationInfo(addon.id,
addon.targetAppID, addon.targetAppID,
addon.minAppVersion, addon.minAppVersion,
@ -4314,7 +4287,7 @@ ExtensionManager.prototype = {
break; break;
case INSTALLERROR_SUCCESS: case INSTALLERROR_SUCCESS:
// Installation of multiple extensions / themes contained within a single xpi. // Installation of multiple extensions / themes contained within a single xpi.
if (installData.type == nsIUpdateItem.TYPE_MULTI_XPI) { if (installData.type == Ci.nsIUpdateItem.TYPE_MULTI_XPI) {
installMultiXPI(aXPIFile, installData); installMultiXPI(aXPIFile, installData);
break; break;
} }
@ -4426,7 +4399,7 @@ ExtensionManager.prototype = {
*/ */
installRequiresRestart: function(id, type) { installRequiresRestart: function(id, type) {
switch (type) { switch (type) {
case nsIUpdateItem.TYPE_THEME: case Ci.nsIUpdateItem.TYPE_THEME:
var internalName = this.datasource.getItemProperty(id, "internalName"); var internalName = this.datasource.getItemProperty(id, "internalName");
var needsRestart = false; var needsRestart = false;
if (gPref.prefHasUserValue(PREF_DSS_SKIN_TO_SELECT)) if (gPref.prefHasUserValue(PREF_DSS_SKIN_TO_SELECT))
@ -5115,7 +5088,7 @@ ExtensionManager.prototype = {
var appVersion = gApp.version; var appVersion = gApp.version;
if (items.length == 0) if (items.length == 0)
items = this.getItemList(nsIUpdateItem.TYPE_ADDON, { }); items = this.getItemList(Ci.nsIUpdateItem.TYPE_ADDON, { });
var updater = new ExtensionItemUpdater(appID, appVersion, this); var updater = new ExtensionItemUpdater(appID, appVersion, this);
updater.checkForUpdates(items, items.length, updateCheckType, listener); updater.checkForUpdates(items, items.length, updateCheckType, listener);
@ -5133,7 +5106,7 @@ ExtensionManager.prototype = {
*/ */
checkForBlocklistChanges: function() { checkForBlocklistChanges: function() {
var ds = this.datasource; var ds = this.datasource;
var items = this.getItemList(nsIUpdateItem.TYPE_ADDON, { }); var items = this.getItemList(Ci.nsIUpdateItem.TYPE_ADDON, { });
for (var i = 0; i < items.length; ++i) { for (var i = 0; i < items.length; ++i) {
var id = items[i].id; var id = items[i].id;
ds.updateProperty(id, "blocklisted"); ds.updateProperty(id, "blocklisted");
@ -5141,7 +5114,7 @@ ExtensionManager.prototype = {
this._appEnableItem(id); this._appEnableItem(id);
} }
items = ds.getBlocklistedItemList(null, null, nsIUpdateItem.TYPE_ADDON, items = ds.getBlocklistedItemList(null, null, Ci.nsIUpdateItem.TYPE_ADDON,
false); false);
for (i = 0; i < items.length; ++i) for (i = 0; i < items.length; ++i)
this._appDisableItem(items[i].id); this._appDisableItem(items[i].id);
@ -5733,7 +5706,7 @@ BackgroundUpdateCheckListener.prototype = {
}, },
onAddonUpdateEnded: function(item, status) { onAddonUpdateEnded: function(item, status) {
if (status == nsIAddonUpdateCheckListener.STATUS_UPDATE) { if (status == Ci.nsIAddonUpdateCheckListener.STATUS_UPDATE) {
var lastupdate = this._emDS.getItemProperty(item.id, "availableUpdateVersion"); var lastupdate = this._emDS.getItemProperty(item.id, "availableUpdateVersion");
if (lastupdate != item.version) { if (lastupdate != item.version) {
gPref.setBoolPref(PREF_UPDATE_NOTIFYUSER, true); gPref.setBoolPref(PREF_UPDATE_NOTIFYUSER, true);
@ -5887,7 +5860,7 @@ ExtensionItemUpdater.prototype = {
this._em._appEnableItem(aLocalItem.id); this._em._appEnableItem(aLocalItem.id);
return true; return true;
} }
else if (this._updateCheckType == nsIExtensionManager.UPDATE_SYNC_COMPATIBILITY) else if (this._updateCheckType == Ci.nsIExtensionManager.UPDATE_SYNC_COMPATIBILITY)
this._emDS.updateTargetAppInfo(aLocalItem.id, this._emDS.updateTargetAppInfo(aLocalItem.id,
aRemoteItem.targetAppID, aRemoteItem.targetAppID,
aRemoteItem.minAppVersion, aRemoteItem.minAppVersion,
@ -5963,7 +5936,7 @@ RDFItemUpdater.prototype = {
// A preference setting can disable updating for this item // A preference setting can disable updating for this item
try { try {
if (!gPref.getBoolPref(PREF_EM_ITEM_UPDATE_ENABLED.replace(/%UUID%/, aItem.id))) { if (!gPref.getBoolPref(PREF_EM_ITEM_UPDATE_ENABLED.replace(/%UUID%/, aItem.id))) {
var status = nsIAddonUpdateCheckListener.STATUS_DISABLED; var status = Ci.nsIAddonUpdateCheckListener.STATUS_DISABLED;
this._updater.checkForDone(aItem, status); this._updater.checkForDone(aItem, status);
return; return;
} }
@ -5973,7 +5946,7 @@ RDFItemUpdater.prototype = {
// Items managed by the app are not checked for updates. // Items managed by the app are not checked for updates.
var emDS = this._updater._emDS; var emDS = this._updater._emDS;
if (emDS.getItemProperty(aItem.id, "appManaged") == "true") { if (emDS.getItemProperty(aItem.id, "appManaged") == "true") {
var status = nsIAddonUpdateCheckListener.STATUS_APP_MANAGED; var status = Ci.nsIAddonUpdateCheckListener.STATUS_APP_MANAGED;
this._updater.checkForDone(aItem, status); this._updater.checkForDone(aItem, status);
return; return;
} }
@ -5982,7 +5955,7 @@ RDFItemUpdater.prototype = {
// for updates. // for updates.
var opType = emDS.getItemProperty(aItem.id, "opType"); var opType = emDS.getItemProperty(aItem.id, "opType");
if (opType) { if (opType) {
var status = nsIAddonUpdateCheckListener.STATUS_PENDING_OP; var status = Ci.nsIAddonUpdateCheckListener.STATUS_PENDING_OP;
this._updater.checkForDone(aItem, status); this._updater.checkForDone(aItem, status);
return; return;
} }
@ -5992,16 +5965,16 @@ RDFItemUpdater.prototype = {
// not managed by the app. // not managed by the app.
if (installLocation && (installLocation.name == "winreg-app-global" || if (installLocation && (installLocation.name == "winreg-app-global" ||
installLocation.name == "winreg-app-user")) { installLocation.name == "winreg-app-user")) {
var status = nsIAddonUpdateCheckListener.STATUS_NOT_MANAGED; var status = Ci.nsIAddonUpdateCheckListener.STATUS_NOT_MANAGED;
this._updater.checkForDone(aItem, status); this._updater.checkForDone(aItem, status);
return; return;
} }
// Don't check items for updates if the location can't be written to except // Don't check items for updates if the location can't be written to except
// when performing a version only update. // when performing a version only update.
if ((aUpdateCheckType == nsIExtensionManager.UPDATE_CHECK_NEWVERSION) && if ((aUpdateCheckType == Ci.nsIExtensionManager.UPDATE_CHECK_NEWVERSION) &&
(!installLocation || !installLocation.canAccess)) { (!installLocation || !installLocation.canAccess)) {
var status = nsIAddonUpdateCheckListener.STATUS_READ_ONLY; var status = Ci.nsIAddonUpdateCheckListener.STATUS_READ_ONLY;
this._updater.checkForDone(aItem, status); this._updater.checkForDone(aItem, status);
return; return;
} }
@ -6077,7 +6050,7 @@ RDFItemUpdater.prototype = {
LOG("RDFItemUpdater:checkForUpdates: There was an error loading the \r\n" + LOG("RDFItemUpdater:checkForUpdates: There was an error loading the \r\n" +
" update datasource for: " + dsURI + ", item = " + aItem.id + ", error: " + e); " update datasource for: " + dsURI + ", item = " + aItem.id + ", error: " + e);
this._updater.checkForDone(aItem, this._updater.checkForDone(aItem,
nsIAddonUpdateCheckListener.STATUS_FAILURE); Ci.nsIAddonUpdateCheckListener.STATUS_FAILURE);
return; return;
} }
@ -6117,7 +6090,7 @@ RDFItemUpdater.prototype = {
// one should not be a barrier in either case. // one should not be a barrier in either case.
LOG("RDFItemUpdater::onXMLLoad: " + e); LOG("RDFItemUpdater::onXMLLoad: " + e);
this._updater.checkForDone(aItem, this._updater.checkForDone(aItem,
nsIAddonUpdateCheckListener.STATUS_FAILURE); Ci.nsIAddonUpdateCheckListener.STATUS_FAILURE);
return; return;
} }
var responseXML = request.responseXML; var responseXML = request.responseXML;
@ -6127,8 +6100,8 @@ RDFItemUpdater.prototype = {
// for updates on AMO even if they are not hosted there. // for updates on AMO even if they are not hosted there.
if (!responseXML || responseXML.documentElement.namespaceURI == XMLURI_PARSE_ERROR || if (!responseXML || responseXML.documentElement.namespaceURI == XMLURI_PARSE_ERROR ||
(request.status != 200 && request.status != 0)) { (request.status != 200 && request.status != 0)) {
this._updater.checkForDone(aItem, (aItem.updateRDF ? nsIAddonUpdateCheckListener.STATUS_FAILURE : this._updater.checkForDone(aItem, (aItem.updateRDF ? Ci.nsIAddonUpdateCheckListener.STATUS_FAILURE :
nsIAddonUpdateCheckListener.STATUS_NONE)); Ci.nsIAddonUpdateCheckListener.STATUS_NONE));
return; return;
} }
@ -6165,7 +6138,7 @@ RDFItemUpdater.prototype = {
LOG("RDFItemUpdater:onError: There was an error loading the \r\n" + LOG("RDFItemUpdater:onError: There was an error loading the \r\n" +
"the update datasource for item " + aItem.id + ", error: " + statusText); "the update datasource for item " + aItem.id + ", error: " + statusText);
this._updater.checkForDone(aItem, this._updater.checkForDone(aItem,
nsIAddonUpdateCheckListener.STATUS_FAILURE); Ci.nsIAddonUpdateCheckListener.STATUS_FAILURE);
}, },
onDatasourceLoaded: function(aDatasource, aLocalItem) { onDatasourceLoaded: function(aDatasource, aLocalItem) {
@ -6240,28 +6213,28 @@ RDFItemUpdater.prototype = {
if (!verifier.verifyData(updateString, signature, aLocalItem.updateKey)) { if (!verifier.verifyData(updateString, signature, aLocalItem.updateKey)) {
LOG("RDFItemUpdater:onDatasourceLoaded: Update manifest for " + LOG("RDFItemUpdater:onDatasourceLoaded: Update manifest for " +
aLocalItem.id + " failed signature check."); aLocalItem.id + " failed signature check.");
this._updater.checkForDone(aLocalItem, nsIAddonUpdateCheckListener.STATUS_FAILURE); this._updater.checkForDone(aLocalItem, Ci.nsIAddonUpdateCheckListener.STATUS_FAILURE);
return; return;
} }
} }
catch (e) { catch (e) {
LOG("RDFItemUpdater:onDatasourceLoaded: Failed to verify signature for " + LOG("RDFItemUpdater:onDatasourceLoaded: Failed to verify signature for " +
aLocalItem.id + ". This indicates a malformed update key or signature."); aLocalItem.id + ". This indicates a malformed update key or signature.");
this._updater.checkForDone(aLocalItem, nsIAddonUpdateCheckListener.STATUS_FAILURE); this._updater.checkForDone(aLocalItem, Ci.nsIAddonUpdateCheckListener.STATUS_FAILURE);
return; return;
} }
} }
catch (e) { catch (e) {
LOG("RDFItemUpdater:onDatasourceLoaded: Failed to generate signature " + LOG("RDFItemUpdater:onDatasourceLoaded: Failed to generate signature " +
"string for " + aLocalItem.id + ". Serializer threw " + e); "string for " + aLocalItem.id + ". Serializer threw " + e);
this._updater.checkForDone(aLocalItem, nsIAddonUpdateCheckListener.STATUS_FAILURE); this._updater.checkForDone(aLocalItem, Ci.nsIAddonUpdateCheckListener.STATUS_FAILURE);
return; return;
} }
} }
else { else {
LOG("RDFItemUpdater:onDatasourceLoaded: Update manifest for " + LOG("RDFItemUpdater:onDatasourceLoaded: Update manifest for " +
aLocalItem.id + " did not contain a signature."); aLocalItem.id + " did not contain a signature.");
this._updater.checkForDone(aLocalItem, nsIAddonUpdateCheckListener.STATUS_FAILURE); this._updater.checkForDone(aLocalItem, Ci.nsIAddonUpdateCheckListener.STATUS_FAILURE);
return; return;
} }
} }
@ -6272,13 +6245,13 @@ RDFItemUpdater.prototype = {
var newerItem, sameItem; var newerItem, sameItem;
// Firefox 1.0PR+ update.rdf format // Firefox 1.0PR+ update.rdf format
if (this._updateCheckType == nsIExtensionManager.UPDATE_CHECK_NEWVERSION) { if (this._updateCheckType == Ci.nsIExtensionManager.UPDATE_CHECK_NEWVERSION) {
// Look for newer versions of this item, we only do this in "normal" // Look for newer versions of this item, we only do this in "normal"
// mode... see comment by ExtensionItemUpdater_checkForUpdates // mode... see comment by ExtensionItemUpdater_checkForUpdates
// about how we do this in all cases but Install Phone Home - which // about how we do this in all cases but Install Phone Home - which
// only needs to do a version check. // only needs to do a version check.
newerItem = this._parseV20UpdateInfo(aDatasource, aLocalItem, newerItem = this._parseV20UpdateInfo(aDatasource, aLocalItem,
nsIExtensionManager.UPDATE_CHECK_NEWVERSION); Ci.nsIExtensionManager.UPDATE_CHECK_NEWVERSION);
if (newerItem) { if (newerItem) {
++this._updater._updateCount; ++this._updater._updateCount;
@ -6290,7 +6263,7 @@ RDFItemUpdater.prototype = {
// Now look for updated version compatibility metadata for the currently // Now look for updated version compatibility metadata for the currently
// installed version... // installed version...
sameItem = this._parseV20UpdateInfo(aDatasource, aLocalItem, sameItem = this._parseV20UpdateInfo(aDatasource, aLocalItem,
nsIExtensionManager.UPDATE_CHECK_COMPATIBILITY); Ci.nsIExtensionManager.UPDATE_CHECK_COMPATIBILITY);
if (sameItem) { if (sameItem) {
// Install-time updates are not written to the DS because there is no // Install-time updates are not written to the DS because there is no
@ -6303,19 +6276,19 @@ RDFItemUpdater.prototype = {
LOG("RDFItemUpdater:onDatasourceLoaded: Found info about the installed\r\n" + LOG("RDFItemUpdater:onDatasourceLoaded: Found info about the installed\r\n" +
"version of this item: " + sameItem.objectSource); "version of this item: " + sameItem.objectSource);
} }
var item = null, status = nsIAddonUpdateCheckListener.STATUS_NONE; var item = null, status = Ci.nsIAddonUpdateCheckListener.STATUS_NONE;
if (this._updateCheckType == nsIExtensionManager.UPDATE_CHECK_NEWVERSION if (this._updateCheckType == Ci.nsIExtensionManager.UPDATE_CHECK_NEWVERSION
&& newerItem) { && newerItem) {
item = newerItem; item = newerItem;
status = nsIAddonUpdateCheckListener.STATUS_UPDATE; status = Ci.nsIAddonUpdateCheckListener.STATUS_UPDATE;
} }
else if (sameItem) { else if (sameItem) {
item = sameItem; item = sameItem;
status = nsIAddonUpdateCheckListener.STATUS_VERSIONINFO; status = Ci.nsIAddonUpdateCheckListener.STATUS_VERSIONINFO;
} }
else { else {
item = aLocalItem; item = aLocalItem;
status = nsIAddonUpdateCheckListener.STATUS_NO_UPDATE; status = Ci.nsIAddonUpdateCheckListener.STATUS_NO_UPDATE;
} }
// Only one call of this._updater.checkForDone is needed for RDF // Only one call of this._updater.checkForDone is needed for RDF
// responses, since there is only one response per item. // responses, since there is only one response per item.
@ -6428,7 +6401,7 @@ RDFItemUpdater.prototype = {
* version is greater than any previously found update. Otherwise check * version is greater than any previously found update. Otherwise check
* if this update is for the same version as we have installed. */ * if this update is for the same version as we have installed. */
var result = gVersionChecker.compare(version, aNewestVersionFound); var result = gVersionChecker.compare(version, aNewestVersionFound);
if (aUpdateCheckType == nsIExtensionManager.UPDATE_CHECK_NEWVERSION ? result <= 0 : result != 0) if (aUpdateCheckType == Ci.nsIExtensionManager.UPDATE_CHECK_NEWVERSION ? result <= 0 : result != 0)
return null; return null;
var taArc = gRDF.GetResource(EM_NS("targetApplication")); var taArc = gRDF.GetResource(EM_NS("targetApplication"));
@ -6444,7 +6417,7 @@ RDFItemUpdater.prototype = {
var updateLink = this._getPropertyFromResource(aDataSource, targetApp, "updateLink", aLocalItem); var updateLink = this._getPropertyFromResource(aDataSource, targetApp, "updateLink", aLocalItem);
var updateHash = this._getPropertyFromResource(aDataSource, targetApp, "updateHash", aLocalItem); var updateHash = this._getPropertyFromResource(aDataSource, targetApp, "updateHash", aLocalItem);
if (aUpdateCheckType == nsIExtensionManager.UPDATE_CHECK_NEWVERSION) { if (aUpdateCheckType == Ci.nsIExtensionManager.UPDATE_CHECK_NEWVERSION) {
// New version information is useless without a link to get it from // New version information is useless without a link to get it from
if (!updateLink) if (!updateLink)
continue; continue;
@ -6477,7 +6450,7 @@ RDFItemUpdater.prototype = {
appID); appID);
if (this._updater._isValidUpdate(aLocalItem, updatedItem)) { if (this._updater._isValidUpdate(aLocalItem, updatedItem)) {
if (aUpdateCheckType == nsIExtensionManager.UPDATE_CHECK_NEWVERSION) { if (aUpdateCheckType == Ci.nsIExtensionManager.UPDATE_CHECK_NEWVERSION) {
var infourl = this._getPropertyFromResource(aDataSource, targetApp, var infourl = this._getPropertyFromResource(aDataSource, targetApp,
"updateInfoURL"); "updateInfoURL");
if (infourl) if (infourl)
@ -7688,7 +7661,7 @@ ExtensionsDataSource.prototype = {
* The version of the item * The version of the item
*/ */
addIncompatibleUpdateItem: function(name, url, type, version) { addIncompatibleUpdateItem: function(name, url, type, version) {
var iconURL = (type == nsIUpdateItem.TYPE_THEME) ? URI_GENERIC_ICON_THEME : var iconURL = (type == Ci.nsIUpdateItem.TYPE_THEME) ? URI_GENERIC_ICON_THEME :
URI_GENERIC_ICON_XPINSTALL; URI_GENERIC_ICON_XPINSTALL;
var extensionsStrings = BundleManager.getBundle(URI_EXTENSIONS_PROPERTIES); var extensionsStrings = BundleManager.getBundle(URI_EXTENSIONS_PROPERTIES);
var updateMsg = extensionsStrings.formatStringFromName("incompatibleUpdateMessage", var updateMsg = extensionsStrings.formatStringFromName("incompatibleUpdateMessage",
@ -7878,7 +7851,7 @@ ExtensionsDataSource.prototype = {
LOG("Datasource: Addon Update Ended: " + addon.id + ", status: " + status); LOG("Datasource: Addon Update Ended: " + addon.id + ", status: " + status);
var url = null, hash = null, version = null; var url = null, hash = null, version = null;
var updateAvailable = status == nsIAddonUpdateCheckListener.STATUS_UPDATE; var updateAvailable = status == Ci.nsIAddonUpdateCheckListener.STATUS_UPDATE;
if (updateAvailable) { if (updateAvailable) {
url = EM_L(addon.xpiURL); url = EM_L(addon.xpiURL);
if (addon.xpiHash) if (addon.xpiHash)
@ -7938,7 +7911,7 @@ ExtensionsDataSource.prototype = {
_rdfGet_iconURL: function(item, property) { _rdfGet_iconURL: function(item, property) {
var id = stripPrefix(item.Value, PREFIX_ITEM_URI); var id = stripPrefix(item.Value, PREFIX_ITEM_URI);
var type = this.getItemProperty(id, "type"); var type = this.getItemProperty(id, "type");
if (type & nsIUpdateItem.TYPE_THEME) if (type & Ci.nsIUpdateItem.TYPE_THEME)
return this._getThemeImageURL(item, "icon.png", URI_GENERIC_ICON_THEME); return this._getThemeImageURL(item, "icon.png", URI_GENERIC_ICON_THEME);
if (inSafeMode()) if (inSafeMode())
@ -7969,7 +7942,7 @@ ExtensionsDataSource.prototype = {
*/ */
_rdfGet_previewImage: function(item, property) { _rdfGet_previewImage: function(item, property) {
var type = this.getItemProperty(stripPrefix(item.Value, PREFIX_ITEM_URI), "type"); var type = this.getItemProperty(stripPrefix(item.Value, PREFIX_ITEM_URI), "type");
if (type != -1 && type & nsIUpdateItem.TYPE_THEME) if (type != -1 && type & Ci.nsIUpdateItem.TYPE_THEME)
return this._getThemeImageURL(item, "preview.png", null); return this._getThemeImageURL(item, "preview.png", null);
return null; return null;
}, },