From ac3b3533d568fed836acafaea4527dfb8df1c188 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Wed, 28 Jun 2017 21:55:50 +0200 Subject: [PATCH] polkitAgent: Indicate which application initiated a request Now that the ::initiate signal may contain the PID of the initiating process, we can try to resolve it to an application and use that to indicate where a request originated. This should work for well-behaved applications that only ask for permissions in response to a user action, but unfortunately not when it would be most useful, that is when the dialog is triggered "out of nowhere" by a background service ... https://bugzilla.gnome.org/show_bug.cgi?id=688351 --- data/theme/gnome-shell-sass/_common.scss | 1 + js/ui/components/polkitAgent.js | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/data/theme/gnome-shell-sass/_common.scss b/data/theme/gnome-shell-sass/_common.scss index f1e6ae525..e41e05e94 100644 --- a/data/theme/gnome-shell-sass/_common.scss +++ b/data/theme/gnome-shell-sass/_common.scss @@ -374,6 +374,7 @@ StScrollBar { border: 3px solid $_bubble_borders_color; .message-dialog-main-layout { spacing: 24px; padding: 10px; } + .message-dialog-icon { -st-icon-style: symbolic; } .message-dialog-content { spacing: 16px; } .message-dialog-title { color: darken($osd_fg_color,25%); } } diff --git a/js/ui/components/polkitAgent.js b/js/ui/components/polkitAgent.js index 58743e8a5..9194e7658 100644 --- a/js/ui/components/polkitAgent.js +++ b/js/ui/components/polkitAgent.js @@ -32,7 +32,7 @@ var AuthenticationDialog = new Lang.Class({ Name: 'AuthenticationDialog', Extends: ModalDialog.ModalDialog, - _init(actionId, body, cookie, userNames) { + _init(actionId, body, cookie, app, userNames) { this.parent({ styleClass: 'prompt-dialog' }); this.actionId = actionId; @@ -44,8 +44,11 @@ var AuthenticationDialog = new Lang.Class({ this._group.visible = !Main.sessionMode.isLocked; }); - let icon = new Gio.ThemedIcon({ name: 'dialog-password-symbolic' }); - let title = _("Authentication Required"); + let appInfo = app ? app.app_info : null; + let icon = appInfo ? appInfo.get_icon() + : new Gio.ThemedIcon({ name: 'dialog-password' }); + let title = appInfo ? _("%s Requires Authentication").format(appInfo.get_name()) + : _("Authentication Required"); let content = new Dialog.MessageDialogContent({ icon, title, body }); this.contentLayout.add_actor(content); @@ -362,6 +365,8 @@ var AuthenticationAgent = new Lang.Class({ this._native.connect('initiate', this._onInitiate.bind(this)); this._native.connect('cancel', this._onCancel.bind(this)); this._sessionUpdatedId = 0; + + this._windowTracker = Shell.WindowTracker.get_default(); }, enable() { @@ -392,7 +397,10 @@ var AuthenticationAgent = new Lang.Class({ return; } - this._currentDialog = new AuthenticationDialog(actionId, message, cookie, userNames); + let pid = parseInt(subjectPid); + let app = pid != NaN ? this._windowTracker.get_app_from_pid(pid) : null; + + this._currentDialog = new AuthenticationDialog(actionId, message, cookie, app, userNames); // We actually don't want to open the dialog until we know for // sure that we're going to interact with the user. For