diff --git a/src/browser/browserApi.ts b/src/browser/browserApi.ts index 4a079225e8..83990d6b38 100644 --- a/src/browser/browserApi.ts +++ b/src/browser/browserApi.ts @@ -129,17 +129,24 @@ class BrowserApi { if (BrowserApi.isChromeApi) { return chrome.extension.getViews({ type: 'popup' }).length > 0; } else if (BrowserApi.isSafariApi) { - return true; // TODO + return safari.extension.popovers && safari.extension.popovers.length && + safari.extension.popovers[0].visible; } else { return null; } } - static createNewTab(url: string): void { + static createNewTab(url: string, extensionPage: boolean = false): void { if (BrowserApi.isChromeApi) { chrome.tabs.create({ url: url }); } else if (BrowserApi.isSafariApi) { - return; // TODO + if (extensionPage && url.indexOf('/') === 0) { + url = BrowserApi.getAssetUrl(url); + } + const tab = safari.application.activeBrowserWindow.browserWindow.openTab(); + if (tab) { + tab.url = url; + } } else { return; } @@ -149,7 +156,10 @@ class BrowserApi { if (BrowserApi.isChromeApi) { return chrome.extension.getURL(path); } else if (BrowserApi.isSafariApi) { - return './' + path; // TODO? + if (path.indexOf('/') === 0) { + path = path.substr(1); + } + return safari.extension.baseURI + path; } else { return null; } diff --git a/src/popup/app/accounts/accountsLoginTwoFactorController.js b/src/popup/app/accounts/accountsLoginTwoFactorController.js index b614094f03..49c98d8fd3 100644 --- a/src/popup/app/accounts/accountsLoginTwoFactorController.js +++ b/src/popup/app/accounts/accountsLoginTwoFactorController.js @@ -183,8 +183,9 @@ angular params = providers[constants.twoFactorProvider.email]; $scope.twoFactorEmail = params.Email; - if (BrowserApi.isPopupOpen() && !popupUtilsService.inSidebar($window) && - !popupUtilsService.inTab($window) && !popupUtilsService.inPopout($window)) { + if (!platformUtilsService.isSafari() && BrowserApi.isPopupOpen() && + !popupUtilsService.inSidebar($window) && !popupUtilsService.inTab($window) && + !popupUtilsService.inPopout($window)) { SweetAlert.swal({ title: i18nService.twoStepLogin, text: i18nService.popup2faCloseMessage, @@ -193,7 +194,7 @@ angular cancelButtonText: i18nService.no }, function (confirmed) { if (confirmed) { - BrowserApi.createNewTab('/popup/index.html?uilocation=tab#!/login'); + BrowserApi.createNewTab('/popup/index.html?uilocation=tab#!/login', true); return; } else if (Object.keys(providers).length > 1) { diff --git a/src/popup/app/components/pop-out.component.ts b/src/popup/app/components/pop-out.component.ts index 46ffec4b2e..6a2892a9d7 100644 --- a/src/popup/app/components/pop-out.component.ts +++ b/src/popup/app/components/pop-out.component.ts @@ -1,5 +1,7 @@ import * as template from './pop-out.component.html'; +import { BrowserApi } from '../../../browser/browserApi'; + import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service'; import PopupUtilsService from '../services/popupUtils.service'; @@ -52,7 +54,7 @@ export class PopOutController implements ng.IController { url: href, }); } else if ((typeof safari !== 'undefined')) { - // TODO? + // Safari can't open popup in full page tab :( } } } diff --git a/src/popup/app/current/current.component.html b/src/popup/app/current/current.component.html index cfce2c25d6..350118f253 100644 --- a/src/popup/app/current/current.component.html +++ b/src/popup/app/current/current.component.html @@ -1,5 +1,5 @@