make clipboardRead an optional permission

This commit is contained in:
siikamiika 2019-10-27 01:51:18 +03:00
parent 7ee87265cd
commit d3f51690f8
2 changed files with 13 additions and 2 deletions

View File

@ -85,7 +85,16 @@ class DisplaySearch extends Display {
if (this.clipboardMonitorEnable !== null) { if (this.clipboardMonitorEnable !== null) {
this.clipboardMonitorEnable.addEventListener('change', (e) => { this.clipboardMonitorEnable.addEventListener('change', (e) => {
if (e.target.checked) { if (e.target.checked) {
this.startClipboardMonitor(); chrome.permissions.request(
{permissions: ['clipboardRead']},
(granted) => {
if (granted) {
this.startClipboardMonitor();
} else {
e.target.checked = false;
}
}
);
} else { } else {
this.stopClipboardMonitor(); this.stopClipboardMonitor();
} }

View File

@ -41,10 +41,12 @@
"permissions": [ "permissions": [
"<all_urls>", "<all_urls>",
"storage", "storage",
"clipboardRead",
"clipboardWrite", "clipboardWrite",
"unlimitedStorage" "unlimitedStorage"
], ],
"optional_permissions": [
"clipboardRead"
],
"commands": { "commands": {
"toggle": { "toggle": {
"suggested_key": { "suggested_key": {