[gnome-shell] extensionSystem: Only load importers for enabled extensions
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] extensionSystem: Only load importers for enabled extensions
- Date: Thu, 20 Oct 2011 21:38:53 +0000 (UTC)
commit 4ae2a0b2a5ff58bbbdf4e72870fdac4569b6d7c8
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Fri Oct 14 17:58:23 2011 -0400
extensionSystem: Only load importers for enabled extensions
Rather than loading and enabling all extensions at Shell init time, save some
time and gain some basic security by not loading extensions if they're
not enabled.
https://bugzilla.gnome.org/show_bug.cgi?id=661815
js/ui/extensionSystem.js | 19 ++++++++++++++-----
1 files changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js
index f31f2b4..c30da01 100644
--- a/js/ui/extensionSystem.js
+++ b/js/ui/extensionSystem.js
@@ -62,6 +62,9 @@ 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 = {};
+
// Arrays of uuids
var enabledExtensions;
// GFile for user extensions
@@ -225,8 +228,13 @@ function disableExtension(uuid) {
function enableExtension(uuid) {
let meta = extensionMeta[uuid];
- if (!meta)
+ if (!meta) {
+ if (extensionDirs[uuid]) {
+ let [dir, type] = extensionDirs[uuid];
+ loadExtension(dir, type);
+ }
return;
+ }
if (meta.state != ExtensionState.DISABLED)
return;
@@ -254,7 +262,7 @@ function logExtensionError(uuid, message, state) {
state: state });
}
-function loadExtension(dir, enabled, type) {
+function loadExtension(dir, type) {
let info;
let uuid = dir.get_basename();
@@ -383,8 +391,7 @@ function loadExtension(dir, enabled, type) {
meta.state = ExtensionState.DISABLED;
- if (enabled)
- enableExtension(uuid);
+ enableExtension(uuid);
_signals.emit('extension-loaded', meta.uuid);
_signals.emit('extension-state-changed', meta);
@@ -444,7 +451,9 @@ function _loadExtensionsIn(dir, type) {
let name = info.get_name();
let child = dir.get_child(name);
let enabled = enabledExtensions.indexOf(name) != -1;
- loadExtension(child, enabled, type);
+ extensionDirs[name] = [dir, type];
+ if (enabled)
+ loadExtension(child, type);
}
fileEnum.close(null);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]