Fix errors from background when context menu is disabled. Updated language for context menu disabling.

This commit is contained in:
Kyle Spearrin 2017-03-14 23:17:22 -04:00
parent abf4d97e81
commit c6705ebaf8
3 changed files with 21 additions and 15 deletions

View File

@ -648,11 +648,11 @@
"description": "Yes, Save Now" "description": "Yes, Save Now"
}, },
"disableContextMenuItem": { "disableContextMenuItem": {
"message": "Disable Context Menu Integration", "message": "Disable Context Menu Options",
"description": "Disable Context Menu Integration" "description": "Disable Context Menu Options"
}, },
"disableContextMenuItemDesc": { "disableContextMenuItemDesc": {
"message": "bitwarden's context menu item provides quick access to logins for the current tab.", "message": "Context menu options provide quick access to password generation and logins for the website in your current tab.",
"desription": "bitwarden's context menu item provides quick access to logins for the current tab." "desription": "Context menu options provide quick access to password generation and logins for the website in your current tab."
} }
} }

View File

@ -649,10 +649,10 @@
}, },
"disableContextMenuItem": { "disableContextMenuItem": {
"message": "Disabilita Integrazione Menu Contestuale", "message": "Disabilita Integrazione Menu Contestuale",
"description": "Disable Context Menu Integration" "description": "Disable Context Menu Options"
}, },
"disableContextMenuItemDesc": { "disableContextMenuItemDesc": {
"message": "il menu contestuale di bitwarden fornisce l'accesso rapido ai login per la tab corrente.", "message": "il menu contestuale di bitwarden fornisce l'accesso rapido ai login per la tab corrente.",
"desription": "bitwarden's context menu item provides quick access to logins for the current tab." "desription": "Context menu options provide quick access to password generation and logins for the website in your current tab."
} }
} }

View File

@ -230,23 +230,25 @@ function refreshBadgeAndMenu() {
} }
chrome.storage.local.get(constantsService.disableContextMenuItemKey, function (obj) { chrome.storage.local.get(constantsService.disableContextMenuItemKey, function (obj) {
if (! obj[constantsService.disableContextMenuItemKey]) { if (!obj[constantsService.disableContextMenuItemKey]) {
buildContextMenu(function() { contextMenuReady(tab) }); buildContextMenu(function () {
contextMenuReady(tab, true);
});
} }
else { else {
chrome.contextMenus.removeAll(); chrome.contextMenus.removeAll();
contextMenuReady(tab); contextMenuReady(tab, false);
} }
}); });
}); });
} }
function contextMenuReady(tab) { function contextMenuReady(tab, contextMenuEnabled) {
loadMenuAndUpdateBadge(tab.url, tab.id, true); loadMenuAndUpdateBadge(tab.url, tab.id, contextMenuEnabled);
onUpdatedRan = onReplacedRan = false; onUpdatedRan = onReplacedRan = false;
} }
function loadMenuAndUpdateBadge(url, tabId, loadContextMenuOptions) { function loadMenuAndUpdateBadge(url, tabId, contextMenuEnabled) {
if (!url) { if (!url) {
return; return;
} }
@ -262,7 +264,7 @@ function loadMenuAndUpdateBadge(url, tabId, loadContextMenuOptions) {
loginService.getAllDecryptedForDomain(tabDomain).then(function (logins) { loginService.getAllDecryptedForDomain(tabDomain).then(function (logins) {
sortLogins(logins); sortLogins(logins);
if (loadContextMenuOptions) { if (contextMenuEnabled) {
for (var i = 0; i < logins.length; i++) { for (var i = 0; i < logins.length; i++) {
loadLoginContextMenuOptions(logins[i]); loadLoginContextMenuOptions(logins[i]);
} }
@ -281,14 +283,18 @@ function loadMenuAndUpdateBadge(url, tabId, loadContextMenuOptions) {
}); });
} }
else { else {
loadNoLoginsContextMenuOptions(i18nService.noMatchingLogins); if (contextMenuEnabled) {
loadNoLoginsContextMenuOptions(i18nService.noMatchingLogins);
}
chrome.browserAction.setBadgeText({ chrome.browserAction.setBadgeText({
text: '', text: '',
tabId: tabId tabId: tabId
}); });
} }
}, function () { }, function () {
loadNoLoginsContextMenuOptions(i18nService.vaultLocked); if (contextMenuEnabled) {
loadNoLoginsContextMenuOptions(i18nService.vaultLocked);
}
chrome.browserAction.setBadgeText({ chrome.browserAction.setBadgeText({
text: '', text: '',
tabId: tabId tabId: tabId