mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 22:33:35 +00:00
added support for sidebar
This commit is contained in:
18
gulpfile.js
18
gulpfile.js
@@ -215,6 +215,12 @@ gulp.task('dist', ['build'], function (cb) {
|
|||||||
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.task('dist-firefox', ['dist'], function (cb) {
|
||||||
gulp.src(paths.dist + 'manifest.json')
|
gulp.src(paths.dist + 'manifest.json')
|
||||||
.pipe(jeditor(function (manifest) {
|
.pipe(jeditor(function (manifest) {
|
||||||
@@ -224,12 +230,24 @@ gulp.task('dist-firefox', ['dist'], function (cb) {
|
|||||||
strict_min_version: '42.0'
|
strict_min_version: '42.0'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
manifest['sidebar_action'] = sidebarActionManifestObj;
|
||||||
return manifest;
|
return manifest;
|
||||||
}))
|
}))
|
||||||
.pipe(gulp.dest(paths.dist));
|
.pipe(gulp.dest(paths.dist));
|
||||||
return zipDist('dist-firefox');
|
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) {
|
gulp.task('dist-edge', ['dist'], function (cb) {
|
||||||
// move dist to temp extension folder
|
// move dist to temp extension folder
|
||||||
new Promise(function (resolve, reject) {
|
new Promise(function (resolve, reject) {
|
||||||
|
|||||||
@@ -777,5 +777,8 @@
|
|||||||
},
|
},
|
||||||
"cfTypeBoolean": {
|
"cfTypeBoolean": {
|
||||||
"message": "Boolean"
|
"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?"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ var bg_isBackground = true,
|
|||||||
bg_settingsService = new SettingsService(bg_userService);
|
bg_settingsService = new SettingsService(bg_userService);
|
||||||
bg_loginService = new LoginService(bg_cryptoService, bg_userService, bg_apiService, bg_settingsService);
|
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_folderService = new FolderService(bg_cryptoService, bg_userService, bg_apiService, bg_i18nService);
|
||||||
bg_lockService = new LockService(bg_constantsService, bg_cryptoService, bg_folderService, bg_loginService, setIcon,
|
bg_lockService = new LockService(bg_constantsService, bg_cryptoService, bg_folderService, bg_loginService, bg_utilsService,
|
||||||
refreshBadgeAndMenu);
|
setIcon, refreshBadgeAndMenu);
|
||||||
bg_syncService = new SyncService(bg_loginService, bg_folderService, bg_userService, bg_apiService, bg_settingsService,
|
bg_syncService = new SyncService(bg_loginService, bg_folderService, bg_userService, bg_apiService, bg_settingsService,
|
||||||
bg_cryptoService, logout);
|
bg_cryptoService, logout);
|
||||||
bg_passwordGenerationService = new PasswordGenerationService();
|
bg_passwordGenerationService = new PasswordGenerationService();
|
||||||
@@ -371,7 +371,7 @@ var bg_isBackground = true,
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setIcon() {
|
function setIcon() {
|
||||||
if (!chrome.browserAction.setIcon) {
|
if (!chrome.browserAction && !chrome.sidebarAction) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,14 +385,21 @@ var bg_isBackground = true,
|
|||||||
suffix = '_locked';
|
suffix = '_locked';
|
||||||
}
|
}
|
||||||
|
|
||||||
chrome.browserAction.setIcon({
|
actionSetIcon(chrome.browserAction, suffix);
|
||||||
|
actionSetIcon(chrome.sidebarAction, suffix);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function actionSetIcon(theAction, suffix) {
|
||||||
|
if (theAction && theAction.setIcon) {
|
||||||
|
theAction.setIcon({
|
||||||
path: {
|
path: {
|
||||||
'19': 'images/icon19' + suffix + '.png',
|
'19': 'images/icon19' + suffix + '.png',
|
||||||
'38': 'images/icon38' + suffix + '.png',
|
'38': 'images/icon38' + suffix + '.png',
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function refreshBadgeAndMenu() {
|
function refreshBadgeAndMenu() {
|
||||||
|
|||||||
@@ -175,12 +175,10 @@
|
|||||||
params = providers[constants.twoFactorProvider.email];
|
params = providers[constants.twoFactorProvider.email];
|
||||||
$scope.twoFactorEmail = params.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({
|
SweetAlert.swal({
|
||||||
title: 'Two-step Login',
|
title: i18nService.twoStepLogin,
|
||||||
text: 'Clicking outside the popup window to check your email for your verification code will ' +
|
text: i18nService.popup2faCloseMessage,
|
||||||
'cause this popup to close. ' +
|
|
||||||
'Do you want to open this popup in a new window so that it does not close?',
|
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
confirmButtonText: i18nService.yes,
|
confirmButtonText: i18nService.yes,
|
||||||
cancelButtonText: i18nService.no
|
cancelButtonText: i18nService.no
|
||||||
|
|||||||
@@ -109,6 +109,10 @@ angular
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.refresh = function () {
|
||||||
|
loadVault();
|
||||||
|
};
|
||||||
|
|
||||||
$scope.$on('syncCompleted', function (event, successfully) {
|
$scope.$on('syncCompleted', function (event, successfully) {
|
||||||
if ($scope.loaded) {
|
if ($scope.loaded) {
|
||||||
setTimeout(loadVault, 500);
|
setTimeout(loadVault, 500);
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
<div class="header header-search">
|
<div class="header header-search">
|
||||||
<div class="left">
|
<div class="left" ng-if="!main.inSidebar">
|
||||||
<a href="" ng-click="main.expandVault()"><i class="fa fa-external-link fa-rotate-270 fa-lg"></i></a>
|
<a href="" ng-click="main.expandVault()"><i class="fa fa-external-link fa-rotate-270 fa-lg"></i></a>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="left" ng-if="main.inSidebar">
|
||||||
|
<a href="" ng-click="refresh()"><i class="fa fa-refresh fa-lg"></i></a>
|
||||||
|
</div>
|
||||||
<div class="search" ng-style="{'visibility': main.disableSearch ? 'hidden' : 'visible'}">
|
<div class="search" ng-style="{'visibility': main.disableSearch ? 'hidden' : 'visible'}">
|
||||||
<input type="search" placeholder="{{i18n.searchVault}}" id="search" ng-model="searchText" ng-change="searchVault()" />
|
<input type="search" placeholder="{{i18n.searchVault}}" id="search" ng-model="searchText" ng-change="searchVault()" />
|
||||||
<i class="fa fa-search"></i>
|
<i class="fa fa-search"></i>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ angular
|
|||||||
self.smBody = !self.xsBody && $window.screen.availHeight <= 800;
|
self.smBody = !self.xsBody && $window.screen.availHeight <= 800;
|
||||||
self.lgBody = !self.xsBody && !self.smBody && utilsService && !utilsService.isFirefox() && !utilsService.isEdge();
|
self.lgBody = !self.xsBody && !self.smBody && utilsService && !utilsService.isFirefox() && !utilsService.isEdge();
|
||||||
self.disableSearch = utilsService.isEdge();
|
self.disableSearch = utilsService.isEdge();
|
||||||
|
self.inSidebar = utilsService.inSidebar($window);
|
||||||
|
|
||||||
$scope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) {
|
$scope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) {
|
||||||
if (toParams.animation) {
|
if (toParams.animation) {
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
display: block;
|
display: block;
|
||||||
padding: 12px 0;
|
padding: 12px 0;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.left {
|
.left {
|
||||||
@@ -167,6 +168,7 @@
|
|||||||
i {
|
i {
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: 2px;
|
margin-bottom: 2px;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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.lastLockCheck = null;
|
||||||
this.constantsService = constantsService;
|
this.constantsService = constantsService;
|
||||||
this.cryptoService = cryptoService;
|
this.cryptoService = cryptoService;
|
||||||
this.folderService = folderService;
|
this.folderService = folderService;
|
||||||
this.loginService = loginService;
|
this.loginService = loginService;
|
||||||
|
this.utilsService = utilsService;
|
||||||
this.setIcon = setIcon;
|
this.setIcon = setIcon;
|
||||||
this.refreshBadgeAndMenu = refreshBadgeAndMenu;
|
this.refreshBadgeAndMenu = refreshBadgeAndMenu;
|
||||||
|
|
||||||
@@ -22,8 +23,12 @@ function initLockService(self) {
|
|||||||
}
|
}
|
||||||
self.lastLockCheck = now;
|
self.lastLockCheck = now;
|
||||||
|
|
||||||
if (chrome.extension.getViews({ type: 'popup' }).length > 0) {
|
var popupOpen = chrome.extension.getViews({ type: 'popup' }).length > 0;
|
||||||
// popup is open, do not lock
|
var sidebarViewName = self.utilsService.sidebarViewName();
|
||||||
|
var sidebarOpen = sidebarViewName && chrome.extension.getViews({ type: sidebarViewName }).length > 0;
|
||||||
|
|
||||||
|
if (popupOpen || sidebarOpen) {
|
||||||
|
// Do not lock
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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) {
|
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]?)$/;
|
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);
|
return ipRegex.test(ipString);
|
||||||
|
|||||||
Reference in New Issue
Block a user