From cc94076ffb5825596c98be6d421da53f229c3be7 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Tue, 25 Oct 2011 14:38:25 -0400 Subject: [PATCH] extensionSystem: Fix deferred loading of extensions We need to show the list of installed extensions on EGO, so we can't defer loading by not creating the extension meta. https://bugzilla.gnome.org/show_bug.cgi?id=662704 --- js/ui/extensionSystem.js | 25 ++++++++++++++----------- js/ui/lookingGlass.js | 1 + 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js index 95c3a29ed..66f0904d7 100644 --- a/js/ui/extensionSystem.js +++ b/js/ui/extensionSystem.js @@ -22,6 +22,7 @@ const ExtensionState = { ERROR: 3, OUT_OF_DATE: 4, DOWNLOADING: 5, + INITIALIZED: 6, // Used as an error state for operations on unknown extensions, // should never be in a real extensionMeta object. @@ -62,8 +63,6 @@ const extensionMeta = {}; const extensions = {}; // Maps uuid -> extension state object (returned from init()) const extensionStateObjs = {}; -// Maps uuid -> [GFile to the extension directory, Extension type] -const extensionDirs = {}; // Contains the order that extensions were enabled in. const extensionOrder = []; @@ -260,11 +259,11 @@ function disableExtension(uuid) { function enableExtension(uuid) { let meta = extensionMeta[uuid]; - if (!meta) { - if (extensionDirs[uuid]) { - let [dir, type] = extensionDirs[uuid]; - loadExtension(dir, type); - } + if (!meta) + return; + + if (meta.state == ExtensionState.INITIALIZED) { + loadExtension(meta.dir, meta.type, true); return; } @@ -296,7 +295,7 @@ function logExtensionError(uuid, message, state) { state: state }); } -function loadExtension(dir, type) { +function loadExtension(dir, type, enabled) { let info; let uuid = dir.get_basename(); @@ -353,6 +352,7 @@ function loadExtension(dir, type) { extensionMeta[uuid] = meta; meta.type = type; + meta.dir = dir; meta.path = dir.get_path(); meta.error = ''; @@ -366,6 +366,11 @@ function loadExtension(dir, type) { return; } + if (!enabled) { + meta.state = ExtensionState.INITIALIZED; + return; + } + let extensionJs = dir.get_child('extension.js'); if (!extensionJs.query_exists(null)) { logExtensionError(uuid, 'Missing extension.js'); @@ -485,9 +490,7 @@ function _loadExtensionsIn(dir, type) { let name = info.get_name(); let child = dir.get_child(name); let enabled = enabledExtensions.indexOf(name) != -1; - extensionDirs[name] = [dir, type]; - if (enabled) - loadExtension(child, type); + loadExtension(child, type, enabled); } fileEnum.close(null); } diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js index 0f0dfe901..4e383b364 100644 --- a/js/ui/lookingGlass.js +++ b/js/ui/lookingGlass.js @@ -737,6 +737,7 @@ Extensions.prototype = { case ExtensionSystem.ExtensionState.ENABLED: return _("Enabled"); case ExtensionSystem.ExtensionState.DISABLED: + case ExtensionSystem.ExtensionState.INITIALIZED: return _("Disabled"); case ExtensionSystem.ExtensionState.ERROR: return _("Error");