[gnome-shell/wip/rstrode/login-screen-extensions: 3440/3441] extensionSystem: Allow extensions to run on the login screen
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/rstrode/login-screen-extensions: 3440/3441] extensionSystem: Allow extensions to run on the login screen
- Date: Mon, 30 Aug 2021 13:26:30 +0000 (UTC)
commit eff7b3c99efc04da3cd2e66e327a7f3bd5327b76
Author: Ray Strode <rstrode redhat com>
Date: Sat Aug 28 13:54:39 2021 -0400
extensionSystem: Allow extensions to run on the login screen
At the moment it's not realy possible to extend the login screen to do
things it doesn't have built-in support for. This means in order
to support niche use cases, those cases have to change the main
code base. For instance, oVirt and Vmware deployments want to be able
to automaticaly log in guest VMs when a user pre-authenticates through a
console on a management host. To support those use cases, we added
code to the login screen directly, even though most machines will never
be associated with oVirt or Vmware management hosts.
We also get requests from e.g. government users that need certain features
at the login screen that wouldn't get used much outside of government
deployments. For instance, we've gotten requests that a machine contains
prominently displays that it has "Top Secret" information.
All of these use cases seem like they would better handled via
extensions that could be installed in the specific deployments. The
problem is extensions only run in the user session, and get
disabled at the login screen automatically.
This commit changes that. Now extensions can specify in their metadata
via a new sessionModes property, which modes that want to run in. For
backward compatibility, if an extension doesn't specify which session
modes it works in, its assumed the extension only works in the user
session.
js/ui/extensionSystem.js | 33 +++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js
index 6b624fca09..278d31f089 100644
--- a/js/ui/extensionSystem.js
+++ b/js/ui/extensionSystem.js
@@ -75,6 +75,28 @@ var ExtensionManager = class {
return [...this._extensions.keys()];
}
+ _extensionSupportsSessionMode(uuid) {
+ let extension = this.lookup(uuid);
+
+ if (extension.sessionModes.includes(Main.sessionMode.currentMode))
+ return true;
+
+ if (extension.sessionModes.includes(Main.sessionMode.parentMode))
+ return true;
+
+ return false;
+ }
+
+ _sessionModeCanUseExtension(uuid) {
+ if (!Main.sessionMode.allowExtensions)
+ return false;
+
+ if (!this._extensionSupportsSessionMode(uuid))
+ return false;
+
+ return true;
+ }
+
_callExtensionDisable(uuid) {
let extension = this.lookup(uuid);
if (!extension)
@@ -134,7 +156,7 @@ var ExtensionManager = class {
}
_callExtensionEnable(uuid) {
- if (!Main.sessionMode.allowExtensions)
+ if (!this._sessionModeCanUseExtension(uuid))
return;
let extension = this.lookup(uuid);
@@ -316,6 +338,7 @@ var ExtensionManager = class {
hasPrefs: dir.get_child('prefs.js').query_exists(null),
hasUpdate: false,
canChange: false,
+ sessionModes: meta['session-modes'] ? meta['session-modes'] : [ 'user' ],
};
this._extensions.set(uuid, extension);
@@ -400,7 +423,7 @@ var ExtensionManager = class {
}
_callExtensionInit(uuid) {
- if (!Main.sessionMode.allowExtensions)
+ if (!this._sessionModeCanUseExtension(uuid))
return false;
let extension = this.lookup(uuid);
@@ -489,13 +512,15 @@ var ExtensionManager = class {
// Find and enable all the newly enabled extensions: UUIDs found in the
// new setting, but not in the old one.
newEnabledExtensions
- .filter(uuid => !this._enabledExtensions.includes(uuid))
+ .filter(uuid => !this._enabledExtensions.includes(uuid) &&
+ this._extensionSupportsSessionMode(uuid))
.forEach(uuid => this._callExtensionEnable(uuid));
// Find and disable all the newly disabled extensions: UUIDs found in the
// old setting, but not in the new one.
this._extensionOrder
- .filter(uuid => !newEnabledExtensions.includes(uuid))
+ .filter(uuid => !newEnabledExtensions.includes(uuid) ||
+ !this._extensionSupportsSessionMode(uuid))
.reverse().forEach(uuid => this._callExtensionDisable(uuid));
this._enabledExtensions = newEnabledExtensions;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]