screenShield: Add API to add/remove credential managers

Extensions that provide a credential manager can (un)register themself
so that the screen shield gets activated right after a user is
authenticated.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2399>
This commit is contained in:
Alessandro Bono 2022-08-03 15:43:51 +02:00 committed by Marge Bot
parent b1ac1b47cd
commit f323d85fc3

View File

@ -94,12 +94,8 @@ var ScreenShield = class extends Signals.EventEmitter {
this._activateDialog(); this._activateDialog();
}); });
this._oVirtCredentialsManager = OVirt.getOVirtCredentialsManager(); this._credentialManagers = {};
this._oVirtCredentialsManager.connect('user-authenticated', this.addCredentialManager(OVirt.SERVICE_NAME, OVirt.getOVirtCredentialsManager());
() => {
if (this._isLocked)
this._activateDialog();
});
this._loginManager = LoginManager.getLoginManager(); this._loginManager = LoginManager.getLoginManager();
this._loginManager.connect('prepare-for-sleep', this._loginManager.connect('prepare-for-sleep',
@ -641,6 +637,26 @@ var ScreenShield = class extends Signals.EventEmitter {
// activate without animation in that case. // activate without animation in that case.
} }
addCredentialManager(serviceName, credentialManager) {
if (this._credentialManagers[serviceName])
return;
this._credentialManagers[serviceName] = credentialManager;
credentialManager.connectObject('user-authenticated', () => {
if (this._isLocked)
this._activateDialog();
}, this);
}
removeCredentialManager(serviceName) {
let credentialManager = this._credentialManagers[serviceName];
if (!credentialManager)
return;
credentialManager.disconnectObject(this);
delete this._credentialManagers[serviceName];
}
lock(animate) { lock(animate) {
if (this._lockSettings.get_boolean(DISABLE_LOCK_KEY)) { if (this._lockSettings.get_boolean(DISABLE_LOCK_KEY)) {
log('Screen lock is locked down, not locking'); // lock, lock - who's there? log('Screen lock is locked down, not locking'); // lock, lock - who's there?