diff options
author | siikamiika <siikamiika@users.noreply.github.com> | 2020-01-26 04:16:02 +0200 |
---|---|---|
committer | siikamiika <siikamiika@users.noreply.github.com> | 2020-02-09 21:51:33 +0200 |
commit | 91682dd63334da7acf458a320fbd48bbf7dff766 (patch) | |
tree | 8bde28154a9af98133b8ce2c247d5d1f854381c9 /ext/bg/js | |
parent | 90a5d795708898fba940f77358269354e96355a7 (diff) |
add permission check to formRead
Diffstat (limited to 'ext/bg/js')
-rw-r--r-- | ext/bg/js/settings/main.js | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/ext/bg/js/settings/main.js b/ext/bg/js/settings/main.js index 55472a7b..cf0f08db 100644 --- a/ext/bg/js/settings/main.js +++ b/ext/bg/js/settings/main.js @@ -28,7 +28,22 @@ function getOptionsFullMutable() { async function formRead(options) { options.general.enable = $('#enable').prop('checked'); - options.general.enableClipboardPopups = $('#enable-clipboard-popups').prop('checked'); + const enableClipboardPopups = $('#enable-clipboard-popups').prop('checked'); + if (enableClipboardPopups) { + options.general.enableClipboardPopups = await new Promise((resolve, _reject) => { + chrome.permissions.request( + {permissions: ['clipboardRead']}, + (granted) => { + if (!granted) { + $('#enable-clipboard-popups').prop('checked', false); + } + resolve(granted); + } + ); + }); + } else { + options.general.enableClipboardPopups = false; + } options.general.showGuide = $('#show-usage-guide').prop('checked'); options.general.compactTags = $('#compact-tags').prop('checked'); options.general.compactGlossaries = $('#compact-glossaries').prop('checked'); |