1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-22 11:13:46 +00:00

added support for sidebar

This commit is contained in:
Kyle Spearrin
2017-09-28 10:39:31 -04:00
parent 915546aa0f
commit 6fa5582883
10 changed files with 72 additions and 16 deletions

View File

@@ -1,9 +1,10 @@
function LockService(constantsService, cryptoService, folderService, loginService, setIcon, refreshBadgeAndMenu) {
function LockService(constantsService, cryptoService, folderService, loginService, utilsService, setIcon, refreshBadgeAndMenu) {
this.lastLockCheck = null;
this.constantsService = constantsService;
this.cryptoService = cryptoService;
this.folderService = folderService;
this.loginService = loginService;
this.utilsService = utilsService;
this.setIcon = setIcon;
this.refreshBadgeAndMenu = refreshBadgeAndMenu;
@@ -22,8 +23,12 @@ function initLockService(self) {
}
self.lastLockCheck = now;
if (chrome.extension.getViews({ type: 'popup' }).length > 0) {
// popup is open, do not lock
var popupOpen = chrome.extension.getViews({ type: 'popup' }).length > 0;
var sidebarViewName = self.utilsService.sidebarViewName();
var sidebarOpen = sidebarViewName && chrome.extension.getViews({ type: sidebarViewName }).length > 0;
if (popupOpen || sidebarOpen) {
// Do not lock
return;
}

View File

@@ -228,6 +228,21 @@ function initUtilsService() {
}
};
UtilsService.prototype.inSidebar = function (theWindow) {
return theWindow.location.search && theWindow.location.search.indexOf('sidebar=true') > -1;
};
UtilsService.prototype.sidebarViewName = function () {
if (this.isFirefox()) {
return 'sidebar';
}
else if (this.isOpera()) {
return 'sidebar_panel';
}
return null;
};
function validIpAddress(ipString) {
var ipRegex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
return ipRegex.test(ipString);