fix context menu for logins
This commit is contained in:
parent
95c0a5ace2
commit
69c230af94
|
@ -459,20 +459,20 @@ var bg_isBackground = true,
|
||||||
setActionBadgeColor(bg_sidebarAction);
|
setActionBadgeColor(bg_sidebarAction);
|
||||||
|
|
||||||
menuOptionsLoaded = [];
|
menuOptionsLoaded = [];
|
||||||
bg_cipherService.getAllDecryptedForDomain(tabDomain).then(function (logins) {
|
bg_cipherService.getAllDecryptedForDomain(tabDomain).then(function (ciphers) {
|
||||||
logins.sort(bg_cipherService.sortCiphersByLastUsedThenName);
|
ciphers.sort(bg_cipherService.sortCiphersByLastUsedThenName);
|
||||||
|
|
||||||
if (contextMenuEnabled) {
|
if (contextMenuEnabled) {
|
||||||
for (var i = 0; i < logins.length; i++) {
|
for (var i = 0; i < ciphers.length; i++) {
|
||||||
loadLoginContextMenuOptions(logins[i]);
|
loadLoginContextMenuOptions(ciphers[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var theText = '';
|
var theText = '';
|
||||||
if (logins.length > 0 && logins.length < 9) {
|
if (ciphers.length > 0 && ciphers.length < 9) {
|
||||||
theText = logins.length.toString();
|
theText = ciphers.length.toString();
|
||||||
}
|
}
|
||||||
else if (logins.length > 0) {
|
else if (ciphers.length > 0) {
|
||||||
theText = '9+';
|
theText = '9+';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -756,22 +756,28 @@ var bg_isBackground = true,
|
||||||
pageDetailsToAutoFill = [];
|
pageDetailsToAutoFill = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadLoginContextMenuOptions(login) {
|
function loadLoginContextMenuOptions(cipher) {
|
||||||
var title = login.name + (login.username && login.username !== '' ? ' (' + login.username + ')' : '');
|
if (!cipher || cipher.type !== bg_constantsService.cipherType.login) {
|
||||||
loadContextMenuOptions(title, login.id, login);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var title = cipher.name + (cipher.login.username && cipher.login.username !== '' ?
|
||||||
|
' (' + cipher.login.username + ')' : '');
|
||||||
|
loadContextMenuOptions(title, cipher.id, cipher);
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadNoLoginsContextMenuOptions(noLoginsMessage) {
|
function loadNoLoginsContextMenuOptions(noLoginsMessage) {
|
||||||
loadContextMenuOptions(noLoginsMessage, 'noop', null);
|
loadContextMenuOptions(noLoginsMessage, 'noop', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadContextMenuOptions(title, idSuffix, login) {
|
function loadContextMenuOptions(title, idSuffix, cipher) {
|
||||||
if (!chrome.contextMenus || menuOptionsLoaded.indexOf(idSuffix) > -1) {
|
if (!chrome.contextMenus || menuOptionsLoaded.indexOf(idSuffix) > -1 ||
|
||||||
|
(cipher && cipher.type !== bg_constantsService.cipherType.login)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
menuOptionsLoaded.push(idSuffix);
|
menuOptionsLoaded.push(idSuffix);
|
||||||
|
|
||||||
if (!login || (login.password && login.password !== '')) {
|
if (!cipher || (cipher.login.password && cipher.login.password !== '')) {
|
||||||
chrome.contextMenus.create({
|
chrome.contextMenus.create({
|
||||||
type: 'normal',
|
type: 'normal',
|
||||||
id: 'autofill_' + idSuffix,
|
id: 'autofill_' + idSuffix,
|
||||||
|
@ -790,7 +796,7 @@ var bg_isBackground = true,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!login || (login.username && login.username !== '')) {
|
if (!cipher || (cipher.login.username && cipher.login.username !== '')) {
|
||||||
chrome.contextMenus.create({
|
chrome.contextMenus.create({
|
||||||
type: 'normal',
|
type: 'normal',
|
||||||
id: 'copy-username_' + idSuffix,
|
id: 'copy-username_' + idSuffix,
|
||||||
|
@ -804,7 +810,7 @@ var bg_isBackground = true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!login || (login.password && login.password !== '')) {
|
if (!cipher || (cipher.login.password && cipher.login.password !== '')) {
|
||||||
chrome.contextMenus.create({
|
chrome.contextMenus.create({
|
||||||
type: 'normal',
|
type: 'normal',
|
||||||
id: 'copy-password_' + idSuffix,
|
id: 'copy-password_' + idSuffix,
|
||||||
|
|
Loading…
Reference in New Issue