From 6fa5582883237dbf5babdc9cfc6415edbb98f9c2 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Thu, 28 Sep 2017 10:39:31 -0400 Subject: [PATCH] added support for sidebar --- gulpfile.js | 18 ++++++++++++++++++ src/_locales/en/messages.json | 3 +++ src/background.js | 19 +++++++++++++------ .../accountsLoginTwoFactorController.js | 8 +++----- src/popup/app/current/currentController.js | 4 ++++ src/popup/app/current/views/current.html | 7 +++++-- src/popup/app/global/mainController.js | 1 + src/popup/less/components.less | 2 ++ src/services/lockService.js | 11 ++++++++--- src/services/utilsService.js | 15 +++++++++++++++ 10 files changed, 72 insertions(+), 16 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 8f80a783b2..051c71851b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -215,6 +215,12 @@ gulp.task('dist', ['build'], function (cb) { cb); }); +var sidebarActionManifestObj = { + "default_title": "bitwarden", + "default_panel": "popup/index.html?sidebar=true", + "default_icon": "images/icon19.png" +}; + gulp.task('dist-firefox', ['dist'], function (cb) { gulp.src(paths.dist + 'manifest.json') .pipe(jeditor(function (manifest) { @@ -224,12 +230,24 @@ gulp.task('dist-firefox', ['dist'], function (cb) { strict_min_version: '42.0' } }; + + manifest['sidebar_action'] = sidebarActionManifestObj; return manifest; })) .pipe(gulp.dest(paths.dist)); return zipDist('dist-firefox'); }); +gulp.task('dist-opera', ['dist'], function (cb) { + gulp.src(paths.dist + 'manifest.json') + .pipe(jeditor(function (manifest) { + manifest['sidebar_action'] = sidebarActionManifestObj; + return manifest; + })) + .pipe(gulp.dest(paths.dist)); + return zipDist('dist-opera'); +}); + gulp.task('dist-edge', ['dist'], function (cb) { // move dist to temp extension folder new Promise(function (resolve, reject) { diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 4b2159b8d0..a404572c2c 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -777,5 +777,8 @@ }, "cfTypeBoolean": { "message": "Boolean" + }, + "popup2faCloseMessage": { + "message": "Clicking outside the popup window to check your email for your verification code will cause this popup to close. Do you want to open this popup in a new window so that it does not close?" } } diff --git a/src/background.js b/src/background.js index 34ed6b0cc3..4c5719fb1f 100644 --- a/src/background.js +++ b/src/background.js @@ -39,8 +39,8 @@ var bg_isBackground = true, bg_settingsService = new SettingsService(bg_userService); bg_loginService = new LoginService(bg_cryptoService, bg_userService, bg_apiService, bg_settingsService); bg_folderService = new FolderService(bg_cryptoService, bg_userService, bg_apiService, bg_i18nService); - bg_lockService = new LockService(bg_constantsService, bg_cryptoService, bg_folderService, bg_loginService, setIcon, - refreshBadgeAndMenu); + bg_lockService = new LockService(bg_constantsService, bg_cryptoService, bg_folderService, bg_loginService, bg_utilsService, + setIcon, refreshBadgeAndMenu); bg_syncService = new SyncService(bg_loginService, bg_folderService, bg_userService, bg_apiService, bg_settingsService, bg_cryptoService, logout); bg_passwordGenerationService = new PasswordGenerationService(); @@ -371,7 +371,7 @@ var bg_isBackground = true, } function setIcon() { - if (!chrome.browserAction.setIcon) { + if (!chrome.browserAction && !chrome.sidebarAction) { return; } @@ -385,14 +385,21 @@ var bg_isBackground = true, suffix = '_locked'; } - chrome.browserAction.setIcon({ + actionSetIcon(chrome.browserAction, suffix); + actionSetIcon(chrome.sidebarAction, suffix); + }); + }); + + function actionSetIcon(theAction, suffix) { + if (theAction && theAction.setIcon) { + theAction.setIcon({ path: { '19': 'images/icon19' + suffix + '.png', '38': 'images/icon38' + suffix + '.png', } }); - }); - }); + } + } } function refreshBadgeAndMenu() { diff --git a/src/popup/app/accounts/accountsLoginTwoFactorController.js b/src/popup/app/accounts/accountsLoginTwoFactorController.js index 668f0fafde..f74b22ac1b 100644 --- a/src/popup/app/accounts/accountsLoginTwoFactorController.js +++ b/src/popup/app/accounts/accountsLoginTwoFactorController.js @@ -175,12 +175,10 @@ params = providers[constants.twoFactorProvider.email]; $scope.twoFactorEmail = params.Email; - if (chrome.extension.getViews({ type: 'popup' }).length > 0) { + if (chrome.extension.getViews({ type: 'popup' }).length > 0 && !utilsService.inSidebar($window)) { SweetAlert.swal({ - title: 'Two-step Login', - text: 'Clicking outside the popup window to check your email for your verification code will ' + - 'cause this popup to close. ' + - 'Do you want to open this popup in a new window so that it does not close?', + title: i18nService.twoStepLogin, + text: i18nService.popup2faCloseMessage, showCancelButton: true, confirmButtonText: i18nService.yes, cancelButtonText: i18nService.no diff --git a/src/popup/app/current/currentController.js b/src/popup/app/current/currentController.js index 0530cf6ade..fecaef4fef 100644 --- a/src/popup/app/current/currentController.js +++ b/src/popup/app/current/currentController.js @@ -109,6 +109,10 @@ angular }); }; + $scope.refresh = function () { + loadVault(); + }; + $scope.$on('syncCompleted', function (event, successfully) { if ($scope.loaded) { setTimeout(loadVault, 500); diff --git a/src/popup/app/current/views/current.html b/src/popup/app/current/views/current.html index bd36e3d22d..7ceb109557 100644 --- a/src/popup/app/current/views/current.html +++ b/src/popup/app/current/views/current.html @@ -1,7 +1,10 @@