From c6705ebaf86d5eb64e332b5898f13b10d61e9ed8 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 14 Mar 2017 23:17:22 -0400 Subject: [PATCH] Fix errors from background when context menu is disabled. Updated language for context menu disabling. --- src/_locales/en/messages.json | 8 ++++---- src/_locales/it/messages.json | 4 ++-- src/background.js | 24 +++++++++++++++--------- 3 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 2ff254b198..e185cc33b2 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -648,11 +648,11 @@ "description": "Yes, Save Now" }, "disableContextMenuItem": { - "message": "Disable Context Menu Integration", - "description": "Disable Context Menu Integration" + "message": "Disable Context Menu Options", + "description": "Disable Context Menu Options" }, "disableContextMenuItemDesc": { - "message": "bitwarden's context menu item provides quick access to logins for the current tab.", - "desription": "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": "Context menu options provide quick access to password generation and logins for the website in your current tab." } } diff --git a/src/_locales/it/messages.json b/src/_locales/it/messages.json index 834820da4f..5259bc578f 100644 --- a/src/_locales/it/messages.json +++ b/src/_locales/it/messages.json @@ -649,10 +649,10 @@ }, "disableContextMenuItem": { "message": "Disabilita Integrazione Menu Contestuale", - "description": "Disable Context Menu Integration" + "description": "Disable Context Menu Options" }, "disableContextMenuItemDesc": { "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." } } diff --git a/src/background.js b/src/background.js index 7885f3e4d8..71efb2d8ef 100644 --- a/src/background.js +++ b/src/background.js @@ -230,23 +230,25 @@ function refreshBadgeAndMenu() { } chrome.storage.local.get(constantsService.disableContextMenuItemKey, function (obj) { - if (! obj[constantsService.disableContextMenuItemKey]) { - buildContextMenu(function() { contextMenuReady(tab) }); + if (!obj[constantsService.disableContextMenuItemKey]) { + buildContextMenu(function () { + contextMenuReady(tab, true); + }); } else { chrome.contextMenus.removeAll(); - contextMenuReady(tab); + contextMenuReady(tab, false); } }); }); } -function contextMenuReady(tab) { - loadMenuAndUpdateBadge(tab.url, tab.id, true); +function contextMenuReady(tab, contextMenuEnabled) { + loadMenuAndUpdateBadge(tab.url, tab.id, contextMenuEnabled); onUpdatedRan = onReplacedRan = false; } -function loadMenuAndUpdateBadge(url, tabId, loadContextMenuOptions) { +function loadMenuAndUpdateBadge(url, tabId, contextMenuEnabled) { if (!url) { return; } @@ -262,7 +264,7 @@ function loadMenuAndUpdateBadge(url, tabId, loadContextMenuOptions) { loginService.getAllDecryptedForDomain(tabDomain).then(function (logins) { sortLogins(logins); - if (loadContextMenuOptions) { + if (contextMenuEnabled) { for (var i = 0; i < logins.length; i++) { loadLoginContextMenuOptions(logins[i]); } @@ -281,14 +283,18 @@ function loadMenuAndUpdateBadge(url, tabId, loadContextMenuOptions) { }); } else { - loadNoLoginsContextMenuOptions(i18nService.noMatchingLogins); + if (contextMenuEnabled) { + loadNoLoginsContextMenuOptions(i18nService.noMatchingLogins); + } chrome.browserAction.setBadgeText({ text: '', tabId: tabId }); } }, function () { - loadNoLoginsContextMenuOptions(i18nService.vaultLocked); + if (contextMenuEnabled) { + loadNoLoginsContextMenuOptions(i18nService.vaultLocked); + } chrome.browserAction.setBadgeText({ text: '', tabId: tabId