Ensure extensions are reenabled after unlock

Resolves: #2013801
This commit is contained in:
Ray Strode 2021-10-13 15:46:51 -04:00
parent 5b4afbc956
commit 291b4f917b
2 changed files with 194 additions and 12 deletions

View File

@ -2,7 +2,7 @@
Name: gnome-shell Name: gnome-shell
Version: 40.4 Version: 40.4
Release: 3%{?dist} Release: 4%{?dist}
Summary: Window management and application launching for GNOME Summary: Window management and application launching for GNOME
License: GPLv2+ License: GPLv2+
@ -252,6 +252,10 @@ desktop-file-validate %{buildroot}%{_datadir}/applications/evolution-calendar.de
%{_mandir}/man1/gnome-shell.1* %{_mandir}/man1/gnome-shell.1*
%changelog %changelog
* Wed Oct 13 2021 Ray Strode <rstrode@redhat.com> - 40.4-4
- Ensure extensions are reenabled after unlock
Resolves: #2013801
* Mon Sep 27 2021 Ray Strode <rstrode@redhat.com> - 40.4-3 * Mon Sep 27 2021 Ray Strode <rstrode@redhat.com> - 40.4-3
- Allow extensions at the login screen - Allow extensions at the login screen
Related: #2006985 Related: #2006985

View File

@ -1,7 +1,184 @@
From 335b88a5508ae97c8da491e33fb07e823f405844 Mon Sep 17 00:00:00 2001 From e7fe96d918ef75f59448664d7583eb51735be64d Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com>
Date: Tue, 10 Aug 2021 13:25:57 -0400
Subject: [PATCH 1/3] extensionSystem: Get rid of _enabled boolean optimization
At the moment a session mode either allows extensions or it doesn't.
If it allows extensions, then the entire available list of
configured extensions get enabled as soon as the session mode is
entered.
Since enabling or disabling extensions is an all or nothing situation,
the code tracks whether extensions are already enabled when entering
the session mode, and if so, avoids iterating through the extension list
needlessly. It does this using a boolean named _enabled.
In the future, the extensions themselves will be given some say on
whether or not they should be enabled in a given session mode. This
means, the configured extension list may contain extensions that
shouldn't be enabled for a given session mode, and the _enabled boolean
will no longer be appropriated.
This commit drops the _enabled boolean optimization.
---
js/ui/extensionSystem.js | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js
index 6b624fca0..9a8f1c9a2 100644
--- a/js/ui/extensionSystem.js
+++ b/js/ui/extensionSystem.js
@@ -1,56 +1,55 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
/* exported init connect disconnect */
const { GLib, Gio, GObject, Shell, St } = imports.gi;
const ByteArray = imports.byteArray;
const Signals = imports.signals;
const ExtensionDownloader = imports.ui.extensionDownloader;
const ExtensionUtils = imports.misc.extensionUtils;
const FileUtils = imports.misc.fileUtils;
const Main = imports.ui.main;
const MessageTray = imports.ui.messageTray;
const { ExtensionState, ExtensionType } = ExtensionUtils;
const ENABLED_EXTENSIONS_KEY = 'enabled-extensions';
const DISABLED_EXTENSIONS_KEY = 'disabled-extensions';
const DISABLE_USER_EXTENSIONS_KEY = 'disable-user-extensions';
const EXTENSION_DISABLE_VERSION_CHECK_KEY = 'disable-extension-version-validation';
const UPDATE_CHECK_TIMEOUT = 24 * 60 * 60; // 1 day in seconds
var ExtensionManager = class {
constructor() {
this._initialized = false;
- this._enabled = false;
this._updateNotified = false;
this._extensions = new Map();
this._unloadedExtensions = new Map();
this._enabledExtensions = [];
this._extensionOrder = [];
Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
}
init() {
// The following file should exist for a period of time when extensions
// are enabled after start. If it exists, then the systemd unit will
// disable extensions should gnome-shell crash.
// Should the file already exist from a previous login, then this is OK.
let disableFilename = GLib.build_filenamev([GLib.get_user_runtime_dir(), 'gnome-shell-disable-extensions']);
let disableFile = Gio.File.new_for_path(disableFilename);
try {
disableFile.create(Gio.FileCreateFlags.REPLACE_DESTINATION, null);
} catch (e) {
log('Failed to create file %s: %s'.format(disableFilename, e.message));
}
GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 60, () => {
disableFile.delete(null);
return GLib.SOURCE_REMOVE;
});
this._installExtensionUpdates();
this._sessionUpdated();
@@ -563,85 +562,76 @@ var ExtensionManager = class {
this._enabledExtensions = this._getEnabledExtensions();
let perUserDir = Gio.File.new_for_path(global.userdatadir);
FileUtils.collectFromDatadirs('extensions', true, (dir, info) => {
let fileType = info.get_file_type();
if (fileType != Gio.FileType.DIRECTORY)
return;
let uuid = info.get_name();
let existing = this.lookup(uuid);
if (existing) {
log('Extension %s already installed in %s. %s will not be loaded'.format(uuid, existing.path, dir.get_path()));
return;
}
let extension;
let type = dir.has_prefix(perUserDir)
? ExtensionType.PER_USER
: ExtensionType.SYSTEM;
try {
extension = this.createExtensionObject(uuid, dir, type);
} catch (e) {
logError(e, 'Could not load extension %s'.format(uuid));
return;
}
this.loadExtension(extension);
});
}
_enableAllExtensions() {
- if (this._enabled)
- return;
-
if (!this._initialized) {
this._loadExtensions();
this._initialized = true;
} else {
this._enabledExtensions.forEach(uuid => {
this._callExtensionEnable(uuid);
});
}
- this._enabled = true;
}
_disableAllExtensions() {
- if (!this._enabled)
- return;
-
if (this._initialized) {
this._extensionOrder.slice().reverse().forEach(uuid => {
this._callExtensionDisable(uuid);
});
}
-
- this._enabled = false;
}
_sessionUpdated() {
// For now sessionMode.allowExtensions controls extensions from both the
// 'enabled-extensions' preference and the sessionMode.enabledExtensions
// property; it might make sense to make enabledExtensions independent
// from allowExtensions in the future
if (Main.sessionMode.allowExtensions) {
// Take care of added or removed sessionMode extensions
this._onEnabledExtensionsChanged();
this._enableAllExtensions();
} else {
this._disableAllExtensions();
}
}
};
Signals.addSignalMethods(ExtensionManager.prototype);
const ExtensionUpdateSource = GObject.registerClass(
class ExtensionUpdateSource extends MessageTray.Source {
_init() {
let appSys = Shell.AppSystem.get_default();
this._app = appSys.lookup_app('org.gnome.Extensions.desktop');
super._init(this._app.get_name());
}
getIcon() {
return this._app.app_info.get_icon();
}
--
2.31.1
From c96d908167b8bb088454e0e839d1c2d6e3638676 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com> From: Ray Strode <rstrode@redhat.com>
Date: Sat, 28 Aug 2021 13:54:39 -0400 Date: Sat, 28 Aug 2021 13:54:39 -0400
Subject: [PATCH 1/2] extensionSystem: Allow extensions to run on the login Subject: [PATCH 2/3] extensionSystem: Allow extensions to run on the login
screen screen
At the moment it's not realy possible to extend the login screen to do At the moment it's not realy possible to extend the login screen to do
@ -33,10 +210,10 @@ session.
1 file changed, 29 insertions(+), 4 deletions(-) 1 file changed, 29 insertions(+), 4 deletions(-)
diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js
index 6b624fca0..278d31f08 100644 index 9a8f1c9a2..bbf322ee7 100644
--- a/js/ui/extensionSystem.js --- a/js/ui/extensionSystem.js
+++ b/js/ui/extensionSystem.js +++ b/js/ui/extensionSystem.js
@@ -48,120 +48,142 @@ var ExtensionManager = class { @@ -47,120 +47,142 @@ var ExtensionManager = class {
} }
GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 60, () => { GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, 60, () => {
@ -180,7 +357,7 @@ index 6b624fca0..278d31f08 100644
try { try {
extension.stateObj.enable(); extension.stateObj.enable();
@@ -289,60 +311,61 @@ var ExtensionManager = class { @@ -288,60 +310,61 @@ var ExtensionManager = class {
} catch (e) { } catch (e) {
throw new Error('Failed to load metadata.json: %s'.format(e.toString())); throw new Error('Failed to load metadata.json: %s'.format(e.toString()));
} }
@ -242,7 +419,7 @@ index 6b624fca0..278d31f08 100644
if (enabled) { if (enabled) {
if (!this._callExtensionInit(extension.uuid)) if (!this._callExtensionInit(extension.uuid))
return; return;
@@ -373,61 +396,61 @@ var ExtensionManager = class { @@ -372,61 +395,61 @@ var ExtensionManager = class {
// If we did install an importer, it is now cached and it's // If we did install an importer, it is now cached and it's
// impossible to load a different version // impossible to load a different version
if (type === ExtensionType.PER_USER && extension.imports) if (type === ExtensionType.PER_USER && extension.imports)
@ -305,7 +482,7 @@ index 6b624fca0..278d31f08 100644
} catch (e) { } catch (e) {
this.logExtensionError(uuid, e); this.logExtensionError(uuid, e);
return false; return false;
@@ -462,67 +485,69 @@ var ExtensionManager = class { @@ -461,67 +484,69 @@ var ExtensionManager = class {
: ENABLED_EXTENSIONS_KEY; : ENABLED_EXTENSIONS_KEY;
extension.canChange = extension.canChange =
@ -378,12 +555,13 @@ index 6b624fca0..278d31f08 100644
_installExtensionUpdates() { _installExtensionUpdates() {
if (!this.updatesSupported) if (!this.updatesSupported)
-- --
2.32.0 2.31.1
From 8153a4fd6c0526946afaf531a6e6f14e2da1ef1b Mon Sep 17 00:00:00 2001
From 407c537a5cd14c9e9494d954f27eacfa1589aed5 Mon Sep 17 00:00:00 2001
From: Ray Strode <rstrode@redhat.com> From: Ray Strode <rstrode@redhat.com>
Date: Tue, 10 Aug 2021 15:31:00 -0400 Date: Tue, 10 Aug 2021 15:31:00 -0400
Subject: [PATCH 2/2] sessionMode: Allow extensions at the login and unlock Subject: [PATCH 3/3] sessionMode: Allow extensions at the login and unlock
screens screens
Now extensions can specify which session modes they work in, Now extensions can specify which session modes they work in,
@ -480,5 +658,5 @@ index 4d4fb2444..0534fd1d4 100644
'keyring', 'autorunManager', 'automountManager'] 'keyring', 'autorunManager', 'automountManager']
: ['polkitAgent', 'telepathyClient', : ['polkitAgent', 'telepathyClient',
-- --
2.32.0 2.31.1