From 41c30078212b8082c5d4c8e57197bfb8280d70a1 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 10 Oct 2017 12:42:24 -0400 Subject: [PATCH] expand vault uses a popup instead of a new tab --- .../accountsLoginTwoFactorController.js | 5 ++-- src/popup/app/global/mainController.js | 24 +++++++++++++++++-- src/services/utilsService.js | 4 ++++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/popup/app/accounts/accountsLoginTwoFactorController.js b/src/popup/app/accounts/accountsLoginTwoFactorController.js index 229adf8315..ca497aab72 100644 --- a/src/popup/app/accounts/accountsLoginTwoFactorController.js +++ b/src/popup/app/accounts/accountsLoginTwoFactorController.js @@ -175,9 +175,8 @@ params = providers[constants.twoFactorProvider.email]; $scope.twoFactorEmail = params.Email; - if (chrome.extension.getViews({ type: 'popup' }).length > 0 && - !utilsService.inSidebar($window) && - !utilsService.inTab($window)) { + if (chrome.extension.getViews({ type: 'popup' }).length > 0 && !utilsService.inSidebar($window) && + !utilsService.inTab($window) && !utilsService.inPopout($window)) { SweetAlert.swal({ title: i18nService.twoStepLogin, text: i18nService.popup2faCloseMessage, diff --git a/src/popup/app/global/mainController.js b/src/popup/app/global/mainController.js index 2a2e710b72..b9dff7187d 100644 --- a/src/popup/app/global/mainController.js +++ b/src/popup/app/global/mainController.js @@ -33,8 +33,28 @@ angular } } - href = href.replace('uilocation=popup', 'uilocation=tab').replace('uilocation=sidebar', 'uilocation=tab'); - chrome.tabs.create({ url: href }); + if (chrome.windows.create) { + href = href.replace('uilocation=popup', 'uilocation=popout').replace('uilocation=tab', 'uilocation=popout') + .replace('uilocation=sidebar', 'uilocation=popout'); + + chrome.windows.create({ + url: href, + type: 'popup', + width: $('body').width() + 60, + height: $('body').height() + }); + + if (utilsService.inPopup($window)) { + $window.close(); + } + } + else { + href = href.replace('uilocation=popup', 'uilocation=tab').replace('uilocation=popout', 'uilocation=tab') + .replace('uilocation=sidebar', 'uilocation=tab'); + chrome.tabs.create({ + url: href + }); + } }; chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) { diff --git a/src/services/utilsService.js b/src/services/utilsService.js index 58a862d9d6..e2004a0a5d 100644 --- a/src/services/utilsService.js +++ b/src/services/utilsService.js @@ -236,6 +236,10 @@ function initUtilsService() { return theWindow.location.search && theWindow.location.search.indexOf('uilocation=tab') > -1; }; + UtilsService.prototype.inPopout = function (theWindow) { + return theWindow.location.search && theWindow.location.search.indexOf('uilocation=popout') > -1; + }; + UtilsService.prototype.inPopup = function (theWindow) { return theWindow.location.search && theWindow.location.search.indexOf('uilocation=popup') > -1; };