From 75570b799511bc8e9c8a8f6f76f52afac3b62b44 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Tue, 5 Jun 2012 13:03:42 -0400 Subject: [PATCH] extensionSystem: Add a method to unload an extension https://bugzilla.gnome.org/show_bug.cgi?id=677586 --- js/ui/extensionDownloader.js | 14 +++----------- js/ui/extensionSystem.js | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/js/ui/extensionDownloader.js b/js/ui/extensionDownloader.js index eda387241..c19559adb 100644 --- a/js/ui/extensionDownloader.js +++ b/js/ui/extensionDownloader.js @@ -41,22 +41,14 @@ function uninstallExtensionFromUUID(uuid) { if (!extension) return false; - // 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 - // broke too much. - ExtensionSystem.disableExtension(uuid); - // Don't try to uninstall system extensions if (extension.type != ExtensionUtils.ExtensionType.PER_USER) return false; - extension.state = ExtensionSystem.ExtensionState.UNINSTALLED; - _signals.emit('extension-state-changed', extension); - - delete ExtensionUtils.extensions[uuid]; - - FileUtils.recursivelyDeleteDir(Gio.file_new_for_path(extension.path)); + if (!ExtensionSystem.unloadExtension(uuid)) + return false; + FileUtils.recursivelyDeleteDir(extension.dir); return true; } diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js index c33162d4d..abd219ea6 100644 --- a/js/ui/extensionSystem.js +++ b/js/ui/extensionSystem.js @@ -167,6 +167,23 @@ function loadExtension(extension) { _signals.emit('extension-state-changed', extension); } +function unloadExtension(uuid) { + let extension = ExtensionUtils.extensions[uuid]; + if (!extension) + return false; + + // 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 + // broke too much. + disableExtension(uuid); + + extension.state = ExtensionState.UNINSTALLED; + _signals.emit('extension-state-changed', extension); + + delete ExtensionUtils.extensions[uuid]; + return true; +} + function initExtension(uuid) { let extension = ExtensionUtils.extensions[uuid]; let dir = extension.dir;