Fixes for context menus in firefox
This commit is contained in:
parent
94bc17bd54
commit
e4007659da
|
@ -31,7 +31,8 @@ chrome.commands.onCommand.addListener(function (command) {
|
||||||
var loadMenuRan = false,
|
var loadMenuRan = false,
|
||||||
loginToAutoFill = null,
|
loginToAutoFill = null,
|
||||||
pageDetailsToAutoFill = [],
|
pageDetailsToAutoFill = [],
|
||||||
autofillTimeout = null;
|
autofillTimeout = null,
|
||||||
|
menuOptionsLoaded = [];
|
||||||
|
|
||||||
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
|
chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
|
||||||
if (msg.command === 'loggedIn' || msg.command === 'unlocked' || msg.command === 'locked') {
|
if (msg.command === 'loggedIn' || msg.command === 'unlocked' || msg.command === 'locked') {
|
||||||
|
@ -156,6 +157,15 @@ function buildContextMenu(callback) {
|
||||||
contexts: ['all'],
|
contexts: ['all'],
|
||||||
title: i18nService.autoFill
|
title: i18nService.autoFill
|
||||||
}, function () {
|
}, function () {
|
||||||
|
if (utilsService.isFirefox()) {
|
||||||
|
// Firefox does not support writing to the clipboard from background
|
||||||
|
buildingContextMenu = false;
|
||||||
|
if (callback) {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
chrome.contextMenus.create({
|
chrome.contextMenus.create({
|
||||||
type: 'normal',
|
type: 'normal',
|
||||||
id: 'copy-username',
|
id: 'copy-username',
|
||||||
|
@ -220,7 +230,7 @@ chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
|
||||||
});
|
});
|
||||||
|
|
||||||
chrome.windows.onFocusChanged.addListener(function (windowId) {
|
chrome.windows.onFocusChanged.addListener(function (windowId) {
|
||||||
if (!windowId || windowId < 0) {
|
if (windowId === null || windowId < 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,10 +267,12 @@ function loadMenuAndUpdateBadge(url, tabId, loadContextMenuOptions) {
|
||||||
|
|
||||||
chrome.browserAction.setBadgeBackgroundColor({ color: '#294e5f' });
|
chrome.browserAction.setBadgeBackgroundColor({ color: '#294e5f' });
|
||||||
|
|
||||||
|
menuOptionsLoaded = [];
|
||||||
loginService.getAllDecryptedForDomain(tabDomain).then(function (logins) {
|
loginService.getAllDecryptedForDomain(tabDomain).then(function (logins) {
|
||||||
sortLogins(logins);
|
sortLogins(logins);
|
||||||
for (var i = 0; i < logins.length; i++) {
|
|
||||||
if (loadContextMenuOptions) {
|
if (loadContextMenuOptions) {
|
||||||
|
for (var i = 0; i < logins.length; i++) {
|
||||||
loadLoginContextMenuOptions(logins[i]);
|
loadLoginContextMenuOptions(logins[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -578,12 +590,11 @@ function loadNoLoginsContextMenuOptions(noLoginsMessage) {
|
||||||
loadContextMenuOptions(noLoginsMessage, 'noop', null);
|
loadContextMenuOptions(noLoginsMessage, 'noop', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
var loadingContextMenuOptions = false;
|
|
||||||
function loadContextMenuOptions(title, idSuffix, login) {
|
function loadContextMenuOptions(title, idSuffix, login) {
|
||||||
if (loadingContextMenuOptions) {
|
if (menuOptionsLoaded.indexOf(idSuffix) > -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
loadingContextMenuOptions = true;
|
menuOptionsLoaded.push(idSuffix);
|
||||||
|
|
||||||
if (!login || (login.password && login.password !== '')) {
|
if (!login || (login.password && login.password !== '')) {
|
||||||
chrome.contextMenus.create({
|
chrome.contextMenus.create({
|
||||||
|
@ -595,6 +606,11 @@ function loadContextMenuOptions(title, idSuffix, login) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (utilsService.isFirefox()) {
|
||||||
|
// Firefox does not support writing to the clipboard from background
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!login || (login.username && login.username !== '')) {
|
if (!login || (login.username && login.username !== '')) {
|
||||||
chrome.contextMenus.create({
|
chrome.contextMenus.create({
|
||||||
type: 'normal',
|
type: 'normal',
|
||||||
|
@ -614,8 +630,6 @@ function loadContextMenuOptions(title, idSuffix, login) {
|
||||||
title: title
|
title: title
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
loadingContextMenuOptions = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Fix callback hell by moving to promises
|
// TODO: Fix callback hell by moving to promises
|
||||||
|
|
|
@ -70,6 +70,7 @@
|
||||||
"contextMenus",
|
"contextMenus",
|
||||||
"storage",
|
"storage",
|
||||||
"unlimitedStorage",
|
"unlimitedStorage",
|
||||||
|
"clipboardWrite",
|
||||||
"http://*/*",
|
"http://*/*",
|
||||||
"https://*/*"
|
"https://*/*"
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue