screenShield: Show detailed notification data if notifications hint it

Allow notifications to set a x-gnome-privacy-scope hint, with values in
['system', 'user']. If all the notifications in a particular source hint
that their privacy scope is ‘system’, don’t hide the notification
details on the lock screen.

This is aimed at fixing the particular case of power notifications: they
contain information which is not private to the user (it relates to the
system: battery state or AC state, which is obvious to anyone who can
see the machine), so hiding the details of a power management
notification when the screen is locked is pointless.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://gitlab.gnome.org/GNOME/gnome-shell/issues/726
This commit is contained in:
Philip Withnall
2018-11-01 20:56:25 +00:00
committed by Florian Müllner
parent 37e0a73c8f
commit e92477a752
3 changed files with 42 additions and 4 deletions

View File

@ -71,6 +71,17 @@ var Urgency = {
CRITICAL: 3
};
// The privacy of the details of a notification. USER is for notifications which
// contain private information to the originating user account (for example,
// details of an e-mail theyve received). SYSTEM is for notifications which
// contain information private to the physical system (for example, battery
// status) and hence the same for every user. This affects whether the content
// of a notification is shown on the lock screen.
var PrivacyScope = {
USER: 0,
SYSTEM: 1,
};
var FocusGrabber = class FocusGrabber {
constructor(actor) {
this._actor = actor;
@ -340,6 +351,7 @@ var Notification = class Notification {
this.resident = false;
// 'transient' is a reserved keyword in JS, so we have to use an alternate variable name
this.isTransient = false;
this.privacyScope = PrivacyScope.USER;
this.forFeedback = false;
this._acknowledged = false;
this.bannerBodyText = null;
@ -436,6 +448,10 @@ var Notification = class Notification {
this.forFeedback = forFeedback;
}
setPrivacyScope(privacyScope) {
this.privacyScope = privacyScope;
}
playSound() {
if (this._soundPlayed)
return;
@ -722,6 +738,11 @@ var Source = class Source {
return new NotificationPolicy();
}
get narrowestPrivacyScope() {
return this.notifications.every(n => n.privacyScope == PrivacyScope.SYSTEM) ? PrivacyScope.SYSTEM
: PrivacyScope.USER;
}
setTitle(newTitle) {
this.title = newTitle;
this.emit('title-changed');