summaryrefslogtreecommitdiff
path: root/ext/bg/js/settings/settings-controller.js
diff options
context:
space:
mode:
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) {