From 61dc7454d3fe8a80da1e17ec23df6ec76cce5bb4 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 11 Jan 2018 23:39:16 -0500 Subject: [PATCH] safari fixes --- src/background/main.background.ts | 20 +++++++++++--------- src/browser/browserApi.ts | 14 ++++++-------- src/services/i18n.service.ts | 11 ++++++----- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/background/main.background.ts b/src/background/main.background.ts index f0e2325d5a..8906f8b5fc 100644 --- a/src/background/main.background.ts +++ b/src/background/main.background.ts @@ -142,15 +142,17 @@ export default class MainBackground { opr.sidebarAction : (window as any).chrome.sidebarAction; // Background - this.commandsBackground = new CommandsBackground(this, this.passwordGenerationService); - this.contextMenusBackground = new ContextMenusBackground(this, this.cipherService, - this.passwordGenerationService); - this.idleBackground = new IdleBackground(this, this.lockService, this.storageService); - this.runtimeBackground = new RuntimeBackground(this, this.autofillService, this.cipherService, - this.platformUtilsService); - this.tabsBackground = new TabsBackground(this); - this.webRequestBackground = new WebRequestBackground(this.platformUtilsService, this.cipherService); - this.windowsBackground = new WindowsBackground(this); + if (!this.isSafari) { + this.commandsBackground = new CommandsBackground(this, this.passwordGenerationService); + this.contextMenusBackground = new ContextMenusBackground(this, this.cipherService, + this.passwordGenerationService); + this.idleBackground = new IdleBackground(this, this.lockService, this.storageService); + this.runtimeBackground = new RuntimeBackground(this, this.autofillService, this.cipherService, + this.platformUtilsService); + this.tabsBackground = new TabsBackground(this); + this.webRequestBackground = new WebRequestBackground(this.platformUtilsService, this.cipherService); + this.windowsBackground = new WindowsBackground(this); + } } async bootstrap() { diff --git a/src/browser/browserApi.ts b/src/browser/browserApi.ts index 616e724d4f..08e350076b 100644 --- a/src/browser/browserApi.ts +++ b/src/browser/browserApi.ts @@ -54,14 +54,12 @@ export default class BrowserApi { } static getBackgroundPage(): any { - function getBackgroundPage(): any { - if (BrowserApi.isChromeApi) { - return chrome.extension.getBackgroundPage(); - } else if (BrowserApi.isSafariApi) { - return safari.extension.globalPage.contentWindow; - } else { - return null; - } + if (BrowserApi.isChromeApi) { + return chrome.extension.getBackgroundPage(); + } else if (BrowserApi.isSafariApi) { + return safari.extension.globalPage.contentWindow; + } else { + return null; } } } diff --git a/src/services/i18n.service.ts b/src/services/i18n.service.ts index 30217f81a5..583c6eeb95 100644 --- a/src/services/i18n.service.ts +++ b/src/services/i18n.service.ts @@ -11,10 +11,10 @@ export default function i18nService(platformUtilsService: PlatformUtilsService) 'zh-CN', 'zh-TW', ]; - async function loadMessages(locale: string, messagesObj: any, + async function loadMessages(localesDir: string, locale: string, messagesObj: any, messageCallback: (prop: string, message: string) => string): Promise { const formattedLocale = locale.replace('-', '_'); - const file = await fetch('../_locales/' + formattedLocale + '/messages.json'); + const file = await fetch(localesDir + formattedLocale + '/messages.json'); const locales = await file.json(); for (const prop in locales) { if (locales.hasOwnProperty(prop)) { @@ -24,7 +24,7 @@ export default function i18nService(platformUtilsService: PlatformUtilsService) } if (platformUtilsService.isEdge()) { - loadMessages('en', localeMessages, (prop: string, message: string) => chrome.i18n.getMessage(prop)); + loadMessages('../_locales/', 'en', localeMessages, (prop: string, message: string) => chrome.i18n.getMessage(prop)); return localeMessages; } @@ -38,9 +38,10 @@ export default function i18nService(platformUtilsService: PlatformUtilsService) } } - loadMessages(lang, localeMessages, (prop: string, message: string) => message); + const dir = './_locales/'; + loadMessages(dir, lang, localeMessages, (prop: string, message: string) => message); if (lang !== supportedLocales[0]) { - loadMessages(supportedLocales[0], defaultMessages, (prop: string, message: string) => message); + loadMessages(dir, supportedLocales[0], defaultMessages, (prop: string, message: string) => message); } }