extensionSystem: Make unloadExtension take an extension object, not a UUID

For consistency with loadExtension.

https://bugzilla.gnome.org/show_bug.cgi?id=682578
This commit is contained in:
Jasper St. Pierre 2012-08-23 22:36:33 -03:00
parent 18c62a1987
commit 4696bfbb80
2 changed files with 6 additions and 10 deletions

View File

@ -60,7 +60,7 @@ function uninstallExtension(uuid) {
if (extension.type != ExtensionUtils.ExtensionType.PER_USER) if (extension.type != ExtensionUtils.ExtensionType.PER_USER)
return false; return false;
if (!ExtensionSystem.unloadExtension(uuid)) if (!ExtensionSystem.unloadExtension(extension))
return false; return false;
FileUtils.recursivelyDeleteDir(extension.dir, true); FileUtils.recursivelyDeleteDir(extension.dir, true);
@ -124,7 +124,7 @@ function updateExtension(uuid) {
let oldExtension = ExtensionUtils.extensions[uuid]; let oldExtension = ExtensionUtils.extensions[uuid];
let extensionDir = oldExtension.dir; let extensionDir = oldExtension.dir;
if (!ExtensionSystem.unloadExtension(uuid)) if (!ExtensionSystem.unloadExtension(oldExtension))
return; return;
FileUtils.recursivelyMoveDir(extensionDir, oldExtensionTmpDir); FileUtils.recursivelyMoveDir(extensionDir, oldExtensionTmpDir);
@ -135,7 +135,7 @@ function updateExtension(uuid) {
try { try {
ExtensionSystem.loadExtension(extension); ExtensionSystem.loadExtension(extension);
} catch(e) { } catch(e) {
ExtensionSystem.unloadExtension(uuid); ExtensionSystem.unloadExtension(extension);
logError(e, 'Error loading extension %s'.format(uuid)); logError(e, 'Error loading extension %s'.format(uuid));

View File

@ -158,20 +158,16 @@ function loadExtension(extension) {
_signals.emit('extension-state-changed', extension); _signals.emit('extension-state-changed', extension);
} }
function unloadExtension(uuid) { function unloadExtension(extension) {
let extension = ExtensionUtils.extensions[uuid];
if (!extension)
return false;
// Try to disable it -- if it's ERROR'd, we can't guarantee that, // Try to disable it -- if it's ERROR'd, we can't guarantee that,
// but it will be removed on next reboot, and hopefully nothing // but it will be removed on next reboot, and hopefully nothing
// broke too much. // broke too much.
disableExtension(uuid); disableExtension(extension.uuid);
extension.state = ExtensionState.UNINSTALLED; extension.state = ExtensionState.UNINSTALLED;
_signals.emit('extension-state-changed', extension); _signals.emit('extension-state-changed', extension);
delete ExtensionUtils.extensions[uuid]; delete ExtensionUtils.extensions[extension.uuid];
return true; return true;
} }