summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Müllner <fmuellner@gnome.org>2021-09-02 16:23:38 +0200
committerMarge Bot <marge-bot@gnome.org>2021-09-03 21:34:58 +0000
commit3b9e672a09dc6cdd997a579be9b310b60dcbb7bc (patch)
tree7c70025f631e9044a217396366fc109d7d2a78cf
parent7298ee23e91b756c7009b4d7687dfd8673856f8b (diff)
downloadgnome-shell-3b9e672a09dc6cdd997a579be9b310b60dcbb7bc.tar.gz
introspect: Make invocation check error-based
If we throw an error when the invocation isn't allowed instead of returning false, we can simply return that error instead of duplicating the error handling. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1970>
-rw-r--r--js/misc/introspect.js26
1 files changed, 14 insertions, 12 deletions
diff --git a/js/misc/introspect.js b/js/misc/introspect.js
index 85f491a69..3cb021cb1 100644
--- a/js/misc/introspect.js
+++ b/js/misc/introspect.js
@@ -137,21 +137,23 @@ var IntrospectService = class {
type == Meta.WindowType.UTILITY;
}
- _isInvocationAllowed(invocation) {
+ _checkInvocation(invocation) {
if (this._isIntrospectEnabled())
- return true;
+ return;
if (this._isSenderAllowed(invocation.get_sender()))
- return true;
+ return;
- return false;
+ throw new GLib.Error(Gio.DBusError,
+ Gio.DBusError.ACCESS_DENIED,
+ 'App introspection not allowed');
}
GetRunningApplicationsAsync(params, invocation) {
- if (!this._isInvocationAllowed(invocation)) {
- invocation.return_error_literal(Gio.DBusError,
- Gio.DBusError.ACCESS_DENIED,
- 'App introspection not allowed');
+ try {
+ this._checkInvocation(invocation);
+ } catch (e) {
+ invocation.return_gerror(e);
return;
}
@@ -163,10 +165,10 @@ var IntrospectService = class {
let apps = this._appSystem.get_running();
let windowsList = {};
- if (!this._isInvocationAllowed(invocation)) {
- invocation.return_error_literal(Gio.DBusError,
- Gio.DBusError.ACCESS_DENIED,
- 'App introspection not allowed');
+ try {
+ this._checkInvocation(invocation);
+ } catch (e) {
+ invocation.return_gerror(e);
return;
}