From 2a7e361300c6ea44bfff8075df8e341f838fd0fe Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 19 Aug 2019 15:57:34 -0400 Subject: [PATCH] cleanup safari specific features --- src/background/commands.background.ts | 2 +- src/background/main.background.ts | 4 ++++ src/browser/browserApi.ts | 4 ++-- src/popup/settings/options.component.ts | 2 +- src/popup/settings/settings.component.ts | 2 +- .../desktop/safari/SafariExtensionViewController.swift | 8 +++++++- src/services/browserPlatformUtils.service.ts | 1 + 7 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/background/commands.background.ts b/src/background/commands.background.ts index 33cac783b4..68d97aa9c8 100644 --- a/src/background/commands.background.ts +++ b/src/background/commands.background.ts @@ -52,7 +52,7 @@ export default class CommandsBackground { } private async generatePasswordToClipboard() { - if (this.isSafari || this.isEdge) { + if (this.isEdge) { // Safari does not support access to clipboard from background return; } diff --git a/src/background/main.background.ts b/src/background/main.background.ts index 7cd18c21f6..db2c982b84 100644 --- a/src/background/main.background.ts +++ b/src/background/main.background.ts @@ -368,6 +368,10 @@ export default class MainBackground { // Chrome APIs cannot open popup // TODO: Do we need to open this popup? + if (!this.isSafari) { + return; + } + await SafariApp.sendMessageToApp('showPopover'); /* if (!this.isSafari || !safari.extension.toolbarItems || !safari.extension.toolbarItems.length) { diff --git a/src/browser/browserApi.ts b/src/browser/browserApi.ts index 5678300774..a502c2e4c8 100644 --- a/src/browser/browserApi.ts +++ b/src/browser/browserApi.ts @@ -230,7 +230,7 @@ export class BrowserApi { } else if (BrowserApi.isWebExtensionsApi || BrowserApi.isChromeApi) { win.close(); } else if (BrowserApi.isSafariApi) { - SafariApp.sendMessageToApp('hideWindow'); + SafariApp.sendMessageToApp('hidePopover'); } } @@ -293,7 +293,7 @@ export class BrowserApi { if (win != null) { return win.location.reload(true); } else if (BrowserApi.isSafariApi) { - SafariApp.sendMessageToApp('reloadWindow'); + SafariApp.sendMessageToApp('reloadExtension'); } else if (!BrowserApi.isSafariApi) { return chrome.runtime.reload(); } diff --git a/src/popup/settings/options.component.ts b/src/popup/settings/options.component.ts index 63988d31fc..4050060617 100644 --- a/src/popup/settings/options.component.ts +++ b/src/popup/settings/options.component.ts @@ -68,7 +68,7 @@ export class OptionsComponent implements OnInit { } async ngOnInit() { - this.showDisableContextMenu = this.showClearClipboard = !this.platformUtilsService.isSafari(); + this.showDisableContextMenu = !this.platformUtilsService.isSafari(); this.enableAutoFillOnPageLoad = await this.storageService.get( ConstantsService.enableAutoFillOnPageLoadKey); diff --git a/src/popup/settings/settings.component.ts b/src/popup/settings/settings.component.ts index 2fb9752105..b022190a99 100644 --- a/src/popup/settings/settings.component.ts +++ b/src/popup/settings/settings.component.ts @@ -94,7 +94,7 @@ export class SettingsComponent implements OnInit { } async saveLockOption(newValue: number) { - if (newValue == null && !this.platformUtilsService.isSafari()) { + if (newValue == null) { const confirmed = await this.platformUtilsService.showDialog( this.i18nService.t('neverLockWarning'), null, this.i18nService.t('yes'), this.i18nService.t('cancel'), 'warning'); diff --git a/src/safari/app/desktop/safari/SafariExtensionViewController.swift b/src/safari/app/desktop/safari/SafariExtensionViewController.swift index fb1ac68db3..a8194a49b7 100644 --- a/src/safari/app/desktop/safari/SafariExtensionViewController.swift +++ b/src/safari/app/desktop/safari/SafariExtensionViewController.swift @@ -135,9 +135,15 @@ class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMe } } } - } else if command == "hideWindow" { + } else if command == "hidePopover" { dismissPopover() replyMessage(message: m!) + } else if command == "showPopover" { + // TODO + replyMessage(message: m!) + } else if command == "reloadExtension" { + // TODO + replyMessage(message: m!) } else if command == "copyToClipboard" { let pasteboard = NSPasteboard.general pasteboard.declareTypes([NSPasteboard.PasteboardType.string], owner: nil) diff --git a/src/services/browserPlatformUtils.service.ts b/src/services/browserPlatformUtils.service.ts index 87f7e6c09f..b358146205 100644 --- a/src/services/browserPlatformUtils.service.ts +++ b/src/services/browserPlatformUtils.service.ts @@ -95,6 +95,7 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService } if (this.isSafari()) { + // TODO return false; }