1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-13 06:43:35 +00:00

Adjust autofill to handle sites with no username/password

This commit is contained in:
Kyle Spearrin
2016-10-13 23:42:08 -04:00
parent 6b3416a367
commit 9e2b64d0c4
4 changed files with 40 additions and 30 deletions

View File

@@ -336,39 +336,45 @@ function buildContextMenuOptions(url) {
}
function loadSiteContextMenuOptions(site) {
var title = site.name + ' (' + site.username + ')';
loadContextMenuOptions(title, site.id);
var title = site.name + (site.username && site.username !== '' ? ' (' + site.username + ')' : '');
loadContextMenuOptions(title, site.id, site);
}
function loadNoSitesContextMenuOptions() {
var title = 'No matching sites.';
loadContextMenuOptions(title, 'noop');
loadContextMenuOptions(title, 'noop', null);
}
function loadContextMenuOptions(title, idSuffix) {
chrome.contextMenus.create({
type: 'normal',
id: 'autofill_' + idSuffix,
parentId: 'autofill',
contexts: ['all'],
title: title
});
function loadContextMenuOptions(title, idSuffix, site) {
if (site.password && site.password !== '') {
chrome.contextMenus.create({
type: 'normal',
id: 'autofill_' + idSuffix,
parentId: 'autofill',
contexts: ['all'],
title: title
});
}
chrome.contextMenus.create({
type: 'normal',
id: 'copy-username_' + idSuffix,
parentId: 'copy-username',
contexts: ['all'],
title: title
});
if (site.username && site.username !== '') {
chrome.contextMenus.create({
type: 'normal',
id: 'copy-username_' + idSuffix,
parentId: 'copy-username',
contexts: ['all'],
title: title
});
}
chrome.contextMenus.create({
type: 'normal',
id: 'copy-password_' + idSuffix,
parentId: 'copy-password',
contexts: ['all'],
title: title
});
if (site.password && site.password !== '') {
chrome.contextMenus.create({
type: 'normal',
id: 'copy-password_' + idSuffix,
parentId: 'copy-password',
contexts: ['all'],
title: title
});
}
}
function copyToClipboard(text) {