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
This commit is contained in:
parent
8d137eae5b
commit
cc94076ffb
@ -22,6 +22,7 @@ const ExtensionState = {
|
|||||||
ERROR: 3,
|
ERROR: 3,
|
||||||
OUT_OF_DATE: 4,
|
OUT_OF_DATE: 4,
|
||||||
DOWNLOADING: 5,
|
DOWNLOADING: 5,
|
||||||
|
INITIALIZED: 6,
|
||||||
|
|
||||||
// Used as an error state for operations on unknown extensions,
|
// Used as an error state for operations on unknown extensions,
|
||||||
// should never be in a real extensionMeta object.
|
// should never be in a real extensionMeta object.
|
||||||
@ -62,8 +63,6 @@ const extensionMeta = {};
|
|||||||
const extensions = {};
|
const extensions = {};
|
||||||
// Maps uuid -> extension state object (returned from init())
|
// Maps uuid -> extension state object (returned from init())
|
||||||
const extensionStateObjs = {};
|
const extensionStateObjs = {};
|
||||||
// Maps uuid -> [GFile to the extension directory, Extension type]
|
|
||||||
const extensionDirs = {};
|
|
||||||
// Contains the order that extensions were enabled in.
|
// Contains the order that extensions were enabled in.
|
||||||
const extensionOrder = [];
|
const extensionOrder = [];
|
||||||
|
|
||||||
@ -260,11 +259,11 @@ function disableExtension(uuid) {
|
|||||||
|
|
||||||
function enableExtension(uuid) {
|
function enableExtension(uuid) {
|
||||||
let meta = extensionMeta[uuid];
|
let meta = extensionMeta[uuid];
|
||||||
if (!meta) {
|
if (!meta)
|
||||||
if (extensionDirs[uuid]) {
|
return;
|
||||||
let [dir, type] = extensionDirs[uuid];
|
|
||||||
loadExtension(dir, type);
|
if (meta.state == ExtensionState.INITIALIZED) {
|
||||||
}
|
loadExtension(meta.dir, meta.type, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,7 +295,7 @@ function logExtensionError(uuid, message, state) {
|
|||||||
state: state });
|
state: state });
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadExtension(dir, type) {
|
function loadExtension(dir, type, enabled) {
|
||||||
let info;
|
let info;
|
||||||
let uuid = dir.get_basename();
|
let uuid = dir.get_basename();
|
||||||
|
|
||||||
@ -353,6 +352,7 @@ function loadExtension(dir, type) {
|
|||||||
|
|
||||||
extensionMeta[uuid] = meta;
|
extensionMeta[uuid] = meta;
|
||||||
meta.type = type;
|
meta.type = type;
|
||||||
|
meta.dir = dir;
|
||||||
meta.path = dir.get_path();
|
meta.path = dir.get_path();
|
||||||
meta.error = '';
|
meta.error = '';
|
||||||
|
|
||||||
@ -366,6 +366,11 @@ function loadExtension(dir, type) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!enabled) {
|
||||||
|
meta.state = ExtensionState.INITIALIZED;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let extensionJs = dir.get_child('extension.js');
|
let extensionJs = dir.get_child('extension.js');
|
||||||
if (!extensionJs.query_exists(null)) {
|
if (!extensionJs.query_exists(null)) {
|
||||||
logExtensionError(uuid, 'Missing extension.js');
|
logExtensionError(uuid, 'Missing extension.js');
|
||||||
@ -485,9 +490,7 @@ function _loadExtensionsIn(dir, type) {
|
|||||||
let name = info.get_name();
|
let name = info.get_name();
|
||||||
let child = dir.get_child(name);
|
let child = dir.get_child(name);
|
||||||
let enabled = enabledExtensions.indexOf(name) != -1;
|
let enabled = enabledExtensions.indexOf(name) != -1;
|
||||||
extensionDirs[name] = [dir, type];
|
loadExtension(child, type, enabled);
|
||||||
if (enabled)
|
|
||||||
loadExtension(child, type);
|
|
||||||
}
|
}
|
||||||
fileEnum.close(null);
|
fileEnum.close(null);
|
||||||
}
|
}
|
||||||
|
@ -737,6 +737,7 @@ Extensions.prototype = {
|
|||||||
case ExtensionSystem.ExtensionState.ENABLED:
|
case ExtensionSystem.ExtensionState.ENABLED:
|
||||||
return _("Enabled");
|
return _("Enabled");
|
||||||
case ExtensionSystem.ExtensionState.DISABLED:
|
case ExtensionSystem.ExtensionState.DISABLED:
|
||||||
|
case ExtensionSystem.ExtensionState.INITIALIZED:
|
||||||
return _("Disabled");
|
return _("Disabled");
|
||||||
case ExtensionSystem.ExtensionState.ERROR:
|
case ExtensionSystem.ExtensionState.ERROR:
|
||||||
return _("Error");
|
return _("Error");
|
||||||
|
Loading…
Reference in New Issue
Block a user