Blame SOURCES/0004-shellEntry-Support-lockdown-of-Show-Text-menu-in-pas.patch

477568
From ee64cd773bdeef845d02dc84063f926d77090dec Mon Sep 17 00:00:00 2001
477568
From: Ray Strode <rstrode@redhat.com>
477568
Date: Wed, 21 Aug 2019 15:06:46 -0400
477568
Subject: [PATCH 4/4] shellEntry: Support lockdown of "Show Text" menu in
477568
 password entries
477568
477568
Some deployments require being able to prevent users from showing
477568
the password they're currently typing.
477568
477568
This commit adds support for that kind of lockdown.
477568
477568
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/687
477568
---
477568
 js/ui/shellEntry.js | 14 +++++++++++---
477568
 1 file changed, 11 insertions(+), 3 deletions(-)
477568
477568
diff --git a/js/ui/shellEntry.js b/js/ui/shellEntry.js
477568
index 765cede06..c45e4545a 100644
477568
--- a/js/ui/shellEntry.js
477568
+++ b/js/ui/shellEntry.js
477568
@@ -1,81 +1,89 @@
477568
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
477568
 
477568
-const { Clutter, GObject, Pango, Shell, St } = imports.gi;
477568
+const { Clutter, Gio, GObject, Pango, Shell, St } = imports.gi;
477568
 
477568
 const BoxPointer = imports.ui.boxpointer;
477568
 const Main = imports.ui.main;
477568
 const Params = imports.misc.params;
477568
 const PopupMenu = imports.ui.popupMenu;
477568
 const Tweener = imports.ui.tweener;
477568
 
477568
+const LOCKDOWN_SCHEMA = 'org.gnome.desktop.lockdown';
477568
+const DISABLE_SHOW_PASSWORD_KEY = 'disable-show-password';
477568
+
477568
 var EntryMenu = class extends PopupMenu.PopupMenu {
477568
     constructor(entry) {
477568
         super(entry, 0, St.Side.TOP);
477568
 
477568
+        this._lockdownSettings = new Gio.Settings({ schema_id: LOCKDOWN_SCHEMA });
477568
+        this._lockdownSettings.connect('changed::' + DISABLE_SHOW_PASSWORD_KEY, this._resetPasswordItem.bind(this));
477568
+
477568
         this._entry = entry;
477568
         this._clipboard = St.Clipboard.get_default();
477568
 
477568
         // Populate menu
477568
         let item;
477568
         item = new PopupMenu.PopupMenuItem(_("Copy"));
477568
         item.connect('activate', this._onCopyActivated.bind(this));
477568
         this.addMenuItem(item);
477568
         this._copyItem = item;
477568
 
477568
         item = new PopupMenu.PopupMenuItem(_("Paste"));
477568
         item.connect('activate', this._onPasteActivated.bind(this));
477568
         this.addMenuItem(item);
477568
         this._pasteItem = item;
477568
 
477568
         this._passwordItem = null;
477568
 
477568
         Main.uiGroup.add_actor(this.actor);
477568
         this.actor.hide();
477568
     }
477568
 
477568
     _makePasswordItem() {
477568
         let item = new PopupMenu.PopupMenuItem('');
477568
         item.connect('activate', this._onPasswordActivated.bind(this));
477568
         this.addMenuItem(item);
477568
         this._passwordItem = item;
477568
         this._updatePasswordItem();
477568
     }
477568
 
477568
     _resetPasswordItem() {
477568
-        if (!this.isPassword) {
477568
+        let passwordDisabled = this._lockdownSettings.get_boolean(DISABLE_SHOW_PASSWORD_KEY);
477568
+
477568
+        if (!this.isPassword || passwordDisabled) {
477568
             if (this._passwordItem) {
477568
                 this._passwordItem.destroy();
477568
                 this._passwordItem = null;
477568
             }
477568
             this._entry.clutter_text.set_password_char('\u25cf');
477568
-        } else {
477568
+        } else if (this.isPassword && !passwordDisabled) {
477568
             if (!this._passwordItem)
477568
                 this._makePasswordItem();
477568
         }
477568
     }
477568
 
477568
     get isPassword() {
477568
         return this._entry.input_purpose == Clutter.InputContentPurpose.PASSWORD;
477568
     }
477568
 
477568
     set isPassword(v) {
477568
         if (v == this.isPassword)
477568
             return;
477568
 
477568
         if (v)
477568
             this._entry.input_purpose = Clutter.InputContentPurpose.PASSWORD;
477568
         else
477568
             this._entry.input_purpose = Clutter.InputContentPurpose.NORMAL;
477568
 
477568
         this._resetPasswordItem();
477568
     }
477568
 
477568
     open(animate) {
477568
         this._updatePasteItem();
477568
         this._updateCopyItem();
477568
         if (this._passwordItem)
477568
             this._updatePasswordItem();
477568
 
477568
         super.open(animate);
477568
         this._entry.add_style_pseudo_class('focus');
477568
 
477568
-- 
477568
2.27.0
477568