mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-24 12:06:15 +01:00
context menu fixes
This commit is contained in:
parent
0d74e145e2
commit
94bc17bd54
@ -135,7 +135,13 @@ if (chrome.runtime.onInstalled) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var buildingContextMenu = false;
|
||||||
function buildContextMenu(callback) {
|
function buildContextMenu(callback) {
|
||||||
|
if (buildingContextMenu) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
buildingContextMenu = true;
|
||||||
|
|
||||||
chrome.contextMenus.removeAll(function () {
|
chrome.contextMenus.removeAll(function () {
|
||||||
chrome.contextMenus.create({
|
chrome.contextMenus.create({
|
||||||
type: 'normal',
|
type: 'normal',
|
||||||
@ -176,6 +182,7 @@ function buildContextMenu(callback) {
|
|||||||
contexts: ['all'],
|
contexts: ['all'],
|
||||||
title: i18nService.generatePasswordCopied
|
title: i18nService.generatePasswordCopied
|
||||||
}, function () {
|
}, function () {
|
||||||
|
buildingContextMenu = false;
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
@ -212,8 +219,16 @@ chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
|
|||||||
refreshBadgeAndMenu();
|
refreshBadgeAndMenu();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
chrome.windows.onFocusChanged.addListener(function (windowId) {
|
||||||
|
if (!windowId || windowId < 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshBadgeAndMenu();
|
||||||
|
});
|
||||||
|
|
||||||
function refreshBadgeAndMenu() {
|
function refreshBadgeAndMenu() {
|
||||||
chrome.tabs.query({ active: true }, function (tabs) {
|
chrome.tabs.query({ active: true, windowId: chrome.windows.WINDOW_ID_CURRENT }, function (tabs) {
|
||||||
var tab = null;
|
var tab = null;
|
||||||
if (tabs.length > 0) {
|
if (tabs.length > 0) {
|
||||||
tab = tabs[0];
|
tab = tabs[0];
|
||||||
@ -563,7 +578,13 @@ function loadNoLoginsContextMenuOptions(noLoginsMessage) {
|
|||||||
loadContextMenuOptions(noLoginsMessage, 'noop', null);
|
loadContextMenuOptions(noLoginsMessage, 'noop', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var loadingContextMenuOptions = false;
|
||||||
function loadContextMenuOptions(title, idSuffix, login) {
|
function loadContextMenuOptions(title, idSuffix, login) {
|
||||||
|
if (loadingContextMenuOptions) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
loadingContextMenuOptions = true;
|
||||||
|
|
||||||
if (!login || (login.password && login.password !== '')) {
|
if (!login || (login.password && login.password !== '')) {
|
||||||
chrome.contextMenus.create({
|
chrome.contextMenus.create({
|
||||||
type: 'normal',
|
type: 'normal',
|
||||||
@ -593,6 +614,8 @@ function loadContextMenuOptions(title, idSuffix, login) {
|
|||||||
title: title
|
title: title
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadingContextMenuOptions = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Fix callback hell by moving to promises
|
// TODO: Fix callback hell by moving to promises
|
||||||
|
Loading…
Reference in New Issue
Block a user