aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/settings/settings-controller.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-01-30 15:05:08 -0500
committerGitHub <noreply@github.com>2021-01-30 15:05:08 -0500
commit828c4b11c14a13abe6ce352177ece341471e374f (patch)
treee08bd57aba64b95593dab87349127016df48c50f /ext/bg/js/settings/settings-controller.js
parenta802666d8dde251d996fee66b4d96f69c044edf4 (diff)
Permissions requesting fixes (#1334)
* Fix permissions requests not occurring during user interaction * Update toggle after changing permissions * Update functions * Update clipboard requests
Diffstat (limited to 'ext/bg/js/settings/settings-controller.js')
-rw-r--r--ext/bg/js/settings/settings-controller.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/ext/bg/js/settings/settings-controller.js b/ext/bg/js/settings/settings-controller.js
index 107e8004..e59ab7db 100644
--- a/ext/bg/js/settings/settings-controller.js
+++ b/ext/bg/js/settings/settings-controller.js
@@ -132,6 +132,39 @@ class SettingsController extends EventDispatcher {
return optionsFull;
}
+ hasPermissions(permissions) {
+ return new Promise((resolve, reject) => chrome.permissions.contains({permissions}, (result) => {
+ const e = chrome.runtime.lastError;
+ if (e) {
+ reject(new Error(e.message));
+ } else {
+ resolve(result);
+ }
+ }));
+ }
+
+ setPermissionsGranted(permissions, shouldHave) {
+ return (
+ shouldHave ?
+ new Promise((resolve, reject) => chrome.permissions.request({permissions}, (result) => {
+ const e = chrome.runtime.lastError;
+ if (e) {
+ reject(new Error(e.message));
+ } else {
+ resolve(result);
+ }
+ })) :
+ new Promise((resolve, reject) => chrome.permissions.remove({permissions}, (result) => {
+ const e = chrome.runtime.lastError;
+ if (e) {
+ reject(new Error(e.message));
+ } else {
+ resolve(!result);
+ }
+ }))
+ );
+ }
+
// Private
_setProfileIndex(value) {