Add option to disable content menu integation (#99)
* Add option to disable content menu integation Fixes issue #98 * pass tab to contextMenuReady
This commit is contained in:
parent
0298c19e13
commit
84821fd67d
|
@ -646,5 +646,13 @@
|
|||
"notificationAddSave": {
|
||||
"message": "Yes, Save Now",
|
||||
"description": "Yes, Save Now"
|
||||
},
|
||||
"disableContextMenuItem": {
|
||||
"message": "Disable Context Menu Integration",
|
||||
"description": "Disable Context Menu Integration"
|
||||
},
|
||||
"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."
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,6 +78,8 @@ chrome.runtime.onMessage.addListener(function (msg, sender, sendResponse) {
|
|||
pageDetailsToAutoFill.push({ frameId: sender.frameId, tabId: msg.tabId, details: msg.details });
|
||||
autofillTimeout = setTimeout(autofillPage, 300);
|
||||
}
|
||||
} else if (msg.command === 'bgUpdateContextMenu') {
|
||||
refreshBadgeAndMenu();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -227,13 +229,23 @@ function refreshBadgeAndMenu() {
|
|||
return;
|
||||
}
|
||||
|
||||
buildContextMenu(function () {
|
||||
loadMenuAndUpdateBadge(tab.url, tab.id, true);
|
||||
onUpdatedRan = onReplacedRan = false;
|
||||
chrome.storage.local.get(constantsService.disableContextMenuItemKey, function (obj) {
|
||||
if (! obj[constantsService.disableContextMenuItemKey]) {
|
||||
buildContextMenu(function() { contextMenuReady(tab) });
|
||||
}
|
||||
else {
|
||||
chrome.contextMenus.removeAll();
|
||||
contextMenuReady(tab);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function contextMenuReady(tab) {
|
||||
loadMenuAndUpdateBadge(tab.url, tab.id, true);
|
||||
onUpdatedRan = onReplacedRan = false;
|
||||
}
|
||||
|
||||
function loadMenuAndUpdateBadge(url, tabId, loadContextMenuOptions) {
|
||||
if (!url) {
|
||||
return;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
$scope.i18n = i18nService;
|
||||
$scope.disableGa = false;
|
||||
$scope.disableAddLoginNotification = false;
|
||||
$scope.disableContextMenuItem = false;
|
||||
|
||||
chrome.storage.local.get(constantsService.disableGaKey, function (obj) {
|
||||
// Default for Firefox is disabled.
|
||||
|
@ -30,6 +31,17 @@
|
|||
$scope.$apply();
|
||||
});
|
||||
|
||||
chrome.storage.local.get(constantsService.disableContextMenuItemKey, function (obj) {
|
||||
if (obj && obj[constantsService.disableContextMenuItemKey]) {
|
||||
$scope.disableContextMenuItem = true;
|
||||
}
|
||||
else {
|
||||
$scope.disableContextMenuItem = false;
|
||||
}
|
||||
|
||||
$scope.$apply();
|
||||
});
|
||||
|
||||
$scope.updateGa = function () {
|
||||
chrome.storage.local.get(constantsService.disableGaKey, function (obj) {
|
||||
// Default for Firefox is disabled.
|
||||
|
@ -75,4 +87,29 @@
|
|||
});
|
||||
});
|
||||
};
|
||||
|
||||
$scope.updateDisableContextMenuItem = function () {
|
||||
chrome.storage.local.get(constantsService.disableContextMenuItemKey, function (obj) {
|
||||
if (obj[constantsService.disableContextMenuItemKey]) {
|
||||
// enable
|
||||
obj[constantsService.disableContextMenuItemKey] = false;
|
||||
}
|
||||
else {
|
||||
// disable
|
||||
$analytics.eventTrack('Disabled Context Menu Item');
|
||||
obj[constantsService.disableContextMenuItemKey] = true;
|
||||
}
|
||||
|
||||
chrome.storage.local.set(obj, function () {
|
||||
$scope.disableContextMenuItem = obj[constantsService.disableContextMenuItemKey];
|
||||
$scope.$apply();
|
||||
if (!obj[constantsService.disableContextMenuItemKey]) {
|
||||
$analytics.eventTrack('Enabled Context Menu Item');
|
||||
}
|
||||
chrome.runtime.sendMessage({
|
||||
command: 'bgUpdateContextMenu'
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
@ -29,5 +29,17 @@
|
|||
{{i18n.addLoginNotificationDesc}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-section">
|
||||
<div class="list-section-items">
|
||||
<div class="list-section-item list-section-item-checkbox">
|
||||
<label for="context-menu">{{i18n.disableContextMenuItem}}</label>
|
||||
<input id="context-menu" type="checkbox" ng-model="disableContextMenuItem"
|
||||
ng-change="updateDisableContextMenuItem()">
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-section-footer">
|
||||
{{i18n.disableContextMenuItemDesc}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -2,6 +2,7 @@ function ConstantsService() {
|
|||
return {
|
||||
disableGaKey: 'disableGa',
|
||||
disableAddLoginNotificationKey: 'disableAddLoginNotification',
|
||||
disableContextMenuItemKey: 'disableContextMenuItem',
|
||||
lockOptionKey: 'lockOption',
|
||||
lastActiveKey: 'lastActive'
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue