extensionSystem: Make methods to call extension functions private

While public methods to enable/disable extensions make sense for an
extension manager, the existing ones are only used internally. Make
them private and rename them, so that we can re-use the current
names for more useful public methods.

https://bugzilla.gnome.org/show_bug.cgi?id=789852
This commit is contained in:
Florian Müllner 2019-07-08 02:53:32 +02:00 committed by Florian Müllner
parent ea17740719
commit 6a4c55b852

View File

@ -24,7 +24,7 @@ var ExtensionManager = class {
this._sessionUpdated(); this._sessionUpdated();
} }
disableExtension(uuid) { _callExtensionDisable(uuid) {
let extension = ExtensionUtils.extensions[uuid]; let extension = ExtensionUtils.extensions[uuid];
if (!extension) if (!extension)
return; return;
@ -82,13 +82,13 @@ var ExtensionManager = class {
} }
} }
enableExtension(uuid) { _callExtensionEnable(uuid) {
let extension = ExtensionUtils.extensions[uuid]; let extension = ExtensionUtils.extensions[uuid];
if (!extension) if (!extension)
return; return;
if (extension.state == ExtensionState.INITIALIZED) if (extension.state == ExtensionState.INITIALIZED)
this.initExtension(uuid); this._callExtensionInit(uuid);
if (extension.state != ExtensionState.DISABLED) if (extension.state != ExtensionState.DISABLED)
return; return;
@ -155,10 +155,10 @@ var ExtensionManager = class {
} else { } else {
let enabled = this._enabledExtensions.includes(extension.uuid); let enabled = this._enabledExtensions.includes(extension.uuid);
if (enabled) { if (enabled) {
if (!this.initExtension(extension.uuid)) if (!this._callExtensionInit(extension.uuid))
return; return;
if (extension.state == ExtensionState.DISABLED) if (extension.state == ExtensionState.DISABLED)
this.enableExtension(extension.uuid); this._callExtensionEnable(extension.uuid);
} else { } else {
extension.state = ExtensionState.INITIALIZED; extension.state = ExtensionState.INITIALIZED;
} }
@ -171,7 +171,7 @@ var ExtensionManager = class {
// 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.
this.disableExtension(extension.uuid); this._callExtensionDisable(extension.uuid);
extension.state = ExtensionState.UNINSTALLED; extension.state = ExtensionState.UNINSTALLED;
this.emit('extension-state-changed', extension); this.emit('extension-state-changed', extension);
@ -200,7 +200,7 @@ var ExtensionManager = class {
this.loadExtension(newExtension); this.loadExtension(newExtension);
} }
initExtension(uuid) { _callExtensionInit(uuid) {
let extension = ExtensionUtils.extensions[uuid]; let extension = ExtensionUtils.extensions[uuid];
let dir = extension.dir; let dir = extension.dir;
@ -266,7 +266,7 @@ var ExtensionManager = class {
newEnabledExtensions.filter( newEnabledExtensions.filter(
uuid => !this._enabledExtensions.includes(uuid) uuid => !this._enabledExtensions.includes(uuid)
).forEach(uuid => { ).forEach(uuid => {
this.enableExtension(uuid); this._callExtensionEnable(uuid);
}); });
// Find and disable all the newly disabled extensions: UUIDs found in the // Find and disable all the newly disabled extensions: UUIDs found in the
@ -274,7 +274,7 @@ var ExtensionManager = class {
this._enabledExtensions.filter( this._enabledExtensions.filter(
item => !newEnabledExtensions.includes(item) item => !newEnabledExtensions.includes(item)
).forEach(uuid => { ).forEach(uuid => {
this.disableExtension(uuid); this._callExtensionDisable(uuid);
}); });
this._enabledExtensions = newEnabledExtensions; this._enabledExtensions = newEnabledExtensions;
@ -291,7 +291,7 @@ var ExtensionManager = class {
if (Main.sessionMode.allowExtensions) { if (Main.sessionMode.allowExtensions) {
this._enabledExtensions.forEach(uuid => { this._enabledExtensions.forEach(uuid => {
this.enableExtension(uuid); this._callExtensionEnable(uuid);
}); });
} }
} }
@ -313,7 +313,7 @@ var ExtensionManager = class {
finder.scanExtensions(); finder.scanExtensions();
} }
enableAllExtensions() { _enableAllExtensions() {
if (this._enabled) if (this._enabled)
return; return;
@ -322,19 +322,19 @@ var ExtensionManager = class {
this._initted = true; this._initted = true;
} else { } else {
this._enabledExtensions.forEach(uuid => { this._enabledExtensions.forEach(uuid => {
this.enableExtension(uuid); this._callExtensionEnable(uuid);
}); });
} }
this._enabled = true; this._enabled = true;
} }
disableAllExtensions() { _disableAllExtensions() {
if (!this._enabled) if (!this._enabled)
return; return;
if (this._initted) { if (this._initted) {
this._extensionOrder.slice().reverse().forEach(uuid => { this._extensionOrder.slice().reverse().forEach(uuid => {
this.disableExtension(uuid); this._callExtensionDisable(uuid);
}); });
} }
@ -349,9 +349,9 @@ var ExtensionManager = class {
if (Main.sessionMode.allowExtensions) { if (Main.sessionMode.allowExtensions) {
if (this._initted) if (this._initted)
this._enabledExtensions = this._getEnabledExtensions(); this._enabledExtensions = this._getEnabledExtensions();
this.enableAllExtensions(); this._enableAllExtensions();
} else { } else {
this.disableAllExtensions(); this._disableAllExtensions();
} }
} }
}; };