Revert "make clipboardRead optional permission"

This reverts commit a797f18b78.
This commit is contained in:
Kyle Spearrin 2019-03-06 20:28:49 -05:00
parent 9ee5d1af41
commit 16185ffa76
3 changed files with 5 additions and 51 deletions

View File

@ -295,32 +295,4 @@ export class BrowserApi {
return chrome.runtime.reload(); return chrome.runtime.reload();
} }
} }
static hasPermission(permissionName: string): Promise<boolean> {
return new Promise((resolve) => {
if (BrowserApi.isSafariApi) {
resolve(true);
} else {
chrome.permissions.contains({
permissions: [permissionName],
}, (granted: boolean) => {
resolve(granted);
});
}
});
}
static requestPermission(permissionName: string): Promise<boolean> {
return new Promise((resolve) => {
if (BrowserApi.isSafariApi) {
resolve(true);
} else {
chrome.permissions.request({
permissions: [permissionName],
}, (granted: boolean) => {
resolve(granted);
});
}
});
}
} }

View File

@ -71,6 +71,7 @@
"contextMenus", "contextMenus",
"storage", "storage",
"unlimitedStorage", "unlimitedStorage",
"clipboardRead",
"clipboardWrite", "clipboardWrite",
"idle", "idle",
"http://*/*", "http://*/*",
@ -78,9 +79,6 @@
"webRequest", "webRequest",
"webRequestBlocking" "webRequestBlocking"
], ],
"optional_permissions": [
"clipboardRead"
],
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'", "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"commands": { "commands": {
"autofill_login": { "autofill_login": {

View File

@ -16,8 +16,6 @@ import { TotpService } from 'jslib/abstractions/totp.service';
import { ConstantsService } from 'jslib/services/constants.service'; import { ConstantsService } from 'jslib/services/constants.service';
import { BrowserApi } from '../../browser/browserApi';
@Component({ @Component({
selector: 'app-options', selector: 'app-options',
templateUrl: 'options.component.html', templateUrl: 'options.component.html',
@ -37,7 +35,6 @@ export class OptionsComponent implements OnInit {
themeOptions: any[]; themeOptions: any[];
defaultUriMatch = UriMatchType.Domain; defaultUriMatch = UriMatchType.Domain;
uriMatchOptions: any[]; uriMatchOptions: any[];
clearClipboardOriginalValue: number;
clearClipboard: number; clearClipboard: number;
clearClipboardOptions: any[]; clearClipboardOptions: any[];
@ -97,7 +94,6 @@ export class OptionsComponent implements OnInit {
this.defaultUriMatch = defaultUriMatch == null ? UriMatchType.Domain : defaultUriMatch; this.defaultUriMatch = defaultUriMatch == null ? UriMatchType.Domain : defaultUriMatch;
this.clearClipboard = await this.storageService.get<number>(ConstantsService.clearClipboardKey); this.clearClipboard = await this.storageService.get<number>(ConstantsService.clearClipboardKey);
this.clearClipboardOriginalValue = this.clearClipboard;
} }
async updateAddLoginNotification() { async updateAddLoginNotification() {
@ -159,22 +155,10 @@ export class OptionsComponent implements OnInit {
} }
async saveClearClipboard() { async saveClearClipboard() {
if (!this.showClearClipboard) {
return;
}
let hasClipboardPermission = await BrowserApi.hasPermission('clipboardRead');
if (!hasClipboardPermission) {
hasClipboardPermission = await BrowserApi.requestPermission('clipboardRead');
}
if (hasClipboardPermission) {
this.clearClipboardOriginalValue = this.clearClipboard;
await this.storageService.save(ConstantsService.clearClipboardKey, this.clearClipboard); await this.storageService.save(ConstantsService.clearClipboardKey, this.clearClipboard);
this.analytics.eventTrack.next({ this.analytics.eventTrack.next({
action: 'Set Clear Clipboard ' + (this.clearClipboard == null ? 'Disabled' : this.clearClipboard), action: 'Set Clear Clipboard ' + (this.clearClipboard == null ? 'Disabled' : this.clearClipboard),
}); });
} else {
this.clearClipboard = this.clearClipboardOriginalValue;
}
} }
private callAnalytics(name: string, enabled: boolean) { private callAnalytics(name: string, enabled: boolean) {