remove ols safari api dependencies

This commit is contained in:
Kyle Spearrin 2019-08-13 15:47:03 -04:00
parent d585c21c38
commit 80d0bd68f1
4 changed files with 14 additions and 10 deletions

View File

@ -9,7 +9,6 @@ import { PasswordGenerationService } from 'jslib/abstractions/passwordGeneration
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
export default class CommandsBackground {
private commands: any;
private isSafari: boolean;
private isEdge: boolean;
private isVivaldi: boolean;
@ -20,22 +19,17 @@ export default class CommandsBackground {
this.isSafari = this.platformUtilsService.isSafari();
this.isEdge = this.platformUtilsService.isEdge();
this.isVivaldi = this.platformUtilsService.isVivaldi();
this.commands = this.isSafari ? safari.application : chrome.commands;
}
async init() {
if (!this.commands && !this.isEdge) {
return;
}
if (this.isSafari || this.isEdge || this.isVivaldi) {
BrowserApi.messageListener(async (msg: any, sender: any, sendResponse: any) => {
if (msg.command === 'keyboardShortcutTriggered' && msg.shortcut) {
await this.processCommand(msg.shortcut, sender);
}
});
} else {
this.commands.onCommand.addListener(async (command: any) => {
} else if (chrome && chrome.commands && !this.isEdge) {
chrome.commands.onCommand.addListener(async (command: any) => {
await this.processCommand(command);
});
}

View File

@ -367,6 +367,10 @@ export default class MainBackground {
async openPopup() {
// Chrome APIs cannot open popup
// TODO: Do we need to open this popup?
/*
if (!this.isSafari || !safari.extension.toolbarItems || !safari.extension.toolbarItems.length) {
return;
}
@ -378,6 +382,7 @@ export default class MainBackground {
if (activeToolBars && activeToolBars.length) {
activeToolBars[0].showPopover();
}
*/
}
async reseedStorage() {

View File

@ -39,7 +39,7 @@ export default class RuntimeBackground {
private analytics: Analytics, private notificationsService: NotificationsService,
private systemService: SystemService, private lockService: LockService) {
this.isSafari = this.platformUtilsService.isSafari();
this.runtime = this.isSafari ? safari.application : chrome.runtime;
this.runtime = this.isSafari ? {} : chrome.runtime;
// onInstalled listener must be wired up before anything else, so we do it in the ctor
if (!this.isSafari) {
@ -56,6 +56,8 @@ export default class RuntimeBackground {
if (this.isSafari) {
// Reload the popup when it's opened
// TODO
/*
this.runtime.addEventListener('popover', (event: any) => {
const win: Window = event.target.contentWindow;
let href = win.location.href;
@ -69,6 +71,7 @@ export default class RuntimeBackground {
win.location.href = href;
}
}, true);
*/
}
await this.checkOnInstalled();

View File

@ -8,7 +8,7 @@ export default class TabsBackground {
constructor(private main: MainBackground, private platformUtilsService: PlatformUtilsService) {
this.isSafari = this.platformUtilsService.isSafari();
this.tabs = this.isSafari ? safari.application : chrome.tabs;
this.tabs = this.isSafari ? null : chrome.tabs;
}
async init() {
@ -17,6 +17,7 @@ export default class TabsBackground {
}
if (this.isSafari) {
/*
this.tabs.addEventListener('activate', async (ev: any) => {
await this.main.refreshBadgeAndMenu();
}, true);
@ -25,6 +26,7 @@ export default class TabsBackground {
await this.main.checkNotificationQueue();
await this.main.refreshBadgeAndMenu();
}, true);
*/
return;
}