diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-03-10 20:26:57 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-10 20:26:57 -0500 |
commit | 63de9273b383cc46a2f063cfb40ef4699b06e612 (patch) | |
tree | cdaefbed8c8c450c20c29a8fb699275947bd5e17 /ext/js/background/backend.js | |
parent | b1f96a7ca7c37d9269b59d14b2cd67cc21db4d13 (diff) |
Fix permissions changes not being supported on some browsers (#1513)
Diffstat (limited to 'ext/js/background/backend.js')
-rw-r--r-- | ext/js/background/backend.js | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index f61e60b6..f3568694 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -180,9 +180,11 @@ class Backend { const onMessage = this._onMessageWrapper.bind(this); chrome.runtime.onMessage.addListener(onMessage); - const onPermissionsChanged = this._onWebExtensionEventWrapper(this._onPermissionsChanged.bind(this)); - chrome.permissions.onAdded.addListener(onPermissionsChanged); - chrome.permissions.onRemoved.addListener(onPermissionsChanged); + if (this._canObservePermissionsChanges()) { + const onPermissionsChanged = this._onWebExtensionEventWrapper(this._onPermissionsChanged.bind(this)); + chrome.permissions.onAdded.addListener(onPermissionsChanged); + chrome.permissions.onRemoved.addListener(onPermissionsChanged); + } chrome.runtime.onInstalled.addListener(this._onInstalled.bind(this)); } @@ -2095,7 +2097,12 @@ class Backend { this._updateBadge(); } + _canObservePermissionsChanges() { + return isObject(chrome.permissions) && isObject(chrome.permissions.onAdded) && isObject(chrome.permissions.onRemoved); + } + _hasRequiredPermissionsForSettings(options) { + if (!this._canObservePermissionsChanges()) { return true; } return this._permissions === null || this._permissionsUtil.hasRequiredPermissionsForOptions(this._permissions, options); } |