1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-12 22:33:35 +00:00

Add option to disable content menu integation (#99)

* Add option to disable content menu integation

Fixes issue #98

* pass tab to contextMenuReady
This commit is contained in:
byron jones
2017-03-04 11:33:17 +08:00
committed by Kyle Spearrin
parent 0298c19e13
commit 84821fd67d
5 changed files with 73 additions and 3 deletions

View File

@@ -78,6 +78,8 @@ chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
pageDetailsToAutoFill.push({ frameId: sender.frameId, tabId: msg.tabId, details: msg.details });
autofillTimeout = setTimeout(autofillPage, 300);
}
} else if (msg.command === 'bgUpdateContextMenu') {
refreshBadgeAndMenu();
}
});
@@ -227,13 +229,23 @@ function refreshBadgeAndMenu() {
return;
}
buildContextMenu(function () {
loadMenuAndUpdateBadge(tab.url, tab.id, true);
onUpdatedRan = onReplacedRan = false;
chrome.storage.local.get(constantsService.disableContextMenuItemKey, function (obj) {
if (! obj[constantsService.disableContextMenuItemKey]) {
buildContextMenu(function() { contextMenuReady(tab) });
}
else {
chrome.contextMenus.removeAll();
contextMenuReady(tab);
}
});
});
}
function contextMenuReady(tab) {
loadMenuAndUpdateBadge(tab.url, tab.id, true);
onUpdatedRan = onReplacedRan = false;
}
function loadMenuAndUpdateBadge(url, tabId, loadContextMenuOptions) {
if (!url) {
return;