diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index e32b13431d..14c6ccd334 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -103,6 +103,10 @@ "message": "No matching sites.", "description": "No matching sites." }, + "vaultLocked": { + "message": "Vault is locked.", + "description": "Vault is locked." + }, "autoFillInfo": { "message": "There are no sites available to auto-fill for the current browser tab.", "description": "There are no sites available to auto-fill for the current browser tab." diff --git a/src/background.js b/src/background.js index 99f87b2cd4..a47d40da66 100644 --- a/src/background.js +++ b/src/background.js @@ -27,13 +27,10 @@ chrome.commands.onCommand.addListener(function (command) { }); chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) { - if (msg.command === 'loggedOut') { - setIcon(true); + if (msg.command === 'loggedOut' || msg.command === 'loggedIn' || msg.command === 'unlocked' || msg.command === 'locked') { + setIcon(); refreshBadgeAndMenu(); } - else if (msg.command === 'loggedIn') { - setIcon(false); - } else if (msg.command === 'syncCompleted' && msg.successfully) { setTimeout(refreshBadgeAndMenu, 2000); } @@ -45,21 +42,25 @@ chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) { } }); -userService.isAuthenticated(function (isAuthenticated) { - setIcon(!isAuthenticated); -}); +setIcon(); +function setIcon() { + userService.isAuthenticated(function (isAuthenticated) { + cryptoService.getKey(false, function (key) { + var suffix = ''; + if (!isAuthenticated) { + suffix = '_gray'; + } + else if (!key) { + suffix = '_locked'; + } -function setIcon(grayedOut) { - var suffix = ''; - if (grayedOut) { - suffix = '_gray'; - } - - chrome.browserAction.setIcon({ - path: { - '19': 'images/icon19' + suffix + '.png', - '38': 'images/icon38' + suffix + '.png', - } + chrome.browserAction.setIcon({ + path: { + '19': 'images/icon19' + suffix + '.png', + '38': 'images/icon38' + suffix + '.png', + } + }); + }); }); } @@ -190,14 +191,14 @@ function loadMenuAndUpdateBadge(url, tabId, loadContextMenuOptions) { }); } else { - loadNoSitesContextMenuOptions(); + loadNoSitesContextMenuOptions(i18nService.noMatchingSites); chrome.browserAction.setBadgeText({ text: '', tabId: tabId }); } }, function () { - loadNoSitesContextMenuOptions(); + loadNoSitesContextMenuOptions(i18nService.vaultLocked); chrome.browserAction.setBadgeText({ text: '', tabId: tabId @@ -334,8 +335,8 @@ function loadSiteContextMenuOptions(site) { loadContextMenuOptions(title, site.id, site); } -function loadNoSitesContextMenuOptions() { - loadContextMenuOptions(i18nService.noMatchingSites, 'noop', null); +function loadNoSitesContextMenuOptions(noSitesMessage) { + loadContextMenuOptions(noSitesMessage, 'noop', null); } function loadContextMenuOptions(title, idSuffix, site) { @@ -444,6 +445,7 @@ function checkLock() { if (diffSeconds >= lockOptionSeconds) { // need to lock now cryptoService.clearKey(function () { + setIcon(); folderService.clearCache(); siteService.clearCache(); refreshBadgeAndMenu(); diff --git a/src/images/icon19_locked.png b/src/images/icon19_locked.png new file mode 100644 index 0000000000..11c92080ac Binary files /dev/null and b/src/images/icon19_locked.png differ diff --git a/src/images/icon38_locked.png b/src/images/icon38_locked.png new file mode 100644 index 0000000000..1b4ed7b3a1 Binary files /dev/null and b/src/images/icon38_locked.png differ diff --git a/src/popup/app/lock/lockController.js b/src/popup/app/lock/lockController.js index b321f52526..d21b1ce503 100644 --- a/src/popup/app/lock/lockController.js +++ b/src/popup/app/lock/lockController.js @@ -32,6 +32,7 @@ cryptoService.getKeyHash(true, function (storedKeyHash) { if (storedKeyHash && keyHash && storedKeyHash === keyHash) { cryptoService.setKey(key, function () { + chrome.runtime.sendMessage({ command: 'unlocked' }); $state.go('tabs.current'); }); } diff --git a/src/services/i18nService.js b/src/services/i18nService.js index 39ad962f11..905c87587b 100644 --- a/src/services/i18nService.js +++ b/src/services/i18nService.js @@ -23,6 +23,7 @@ function i18nService() { autoFill: chrome.i18n.getMessage('autoFill'), generatePasswordCopied: chrome.i18n.getMessage('generatePasswordCopied'), noMatchingSites: chrome.i18n.getMessage('noMatchingSites'), + vaultLocked: chrome.i18n.getMessage('vaultLocked'), autoFillInfo: chrome.i18n.getMessage('autoFillInfo'), addSite: chrome.i18n.getMessage('addSite'), passwordHint: chrome.i18n.getMessage('passwordHint'),