mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-25 12:15:18 +01:00
update icon when vault is locked/unlocked
This commit is contained in:
parent
124ac06419
commit
e4c5ab88fb
@ -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."
|
||||
|
@ -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();
|
||||
|
BIN
src/images/icon19_locked.png
Normal file
BIN
src/images/icon19_locked.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 584 B |
BIN
src/images/icon38_locked.png
Normal file
BIN
src/images/icon38_locked.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 996 B |
@ -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');
|
||||
});
|
||||
}
|
||||
|
@ -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'),
|
||||
|
Loading…
Reference in New Issue
Block a user