mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 07:13:32 +00:00
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:
committed by
Kyle Spearrin
parent
0298c19e13
commit
84821fd67d
@@ -646,5 +646,13 @@
|
|||||||
"notificationAddSave": {
|
"notificationAddSave": {
|
||||||
"message": "Yes, Save Now",
|
"message": "Yes, Save Now",
|
||||||
"description": "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 });
|
pageDetailsToAutoFill.push({ frameId: sender.frameId, tabId: msg.tabId, details: msg.details });
|
||||||
autofillTimeout = setTimeout(autofillPage, 300);
|
autofillTimeout = setTimeout(autofillPage, 300);
|
||||||
}
|
}
|
||||||
|
} else if (msg.command === 'bgUpdateContextMenu') {
|
||||||
|
refreshBadgeAndMenu();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -227,13 +229,23 @@ function refreshBadgeAndMenu() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
buildContextMenu(function () {
|
chrome.storage.local.get(constantsService.disableContextMenuItemKey, function (obj) {
|
||||||
loadMenuAndUpdateBadge(tab.url, tab.id, true);
|
if (! obj[constantsService.disableContextMenuItemKey]) {
|
||||||
onUpdatedRan = onReplacedRan = false;
|
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) {
|
function loadMenuAndUpdateBadge(url, tabId, loadContextMenuOptions) {
|
||||||
if (!url) {
|
if (!url) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
$scope.i18n = i18nService;
|
$scope.i18n = i18nService;
|
||||||
$scope.disableGa = false;
|
$scope.disableGa = false;
|
||||||
$scope.disableAddLoginNotification = false;
|
$scope.disableAddLoginNotification = false;
|
||||||
|
$scope.disableContextMenuItem = false;
|
||||||
|
|
||||||
chrome.storage.local.get(constantsService.disableGaKey, function (obj) {
|
chrome.storage.local.get(constantsService.disableGaKey, function (obj) {
|
||||||
// Default for Firefox is disabled.
|
// Default for Firefox is disabled.
|
||||||
@@ -30,6 +31,17 @@
|
|||||||
$scope.$apply();
|
$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 () {
|
$scope.updateGa = function () {
|
||||||
chrome.storage.local.get(constantsService.disableGaKey, function (obj) {
|
chrome.storage.local.get(constantsService.disableGaKey, function (obj) {
|
||||||
// Default for Firefox is disabled.
|
// 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}}
|
{{i18n.addLoginNotificationDesc}}
|
||||||
</div>
|
</div>
|
||||||
</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>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ function ConstantsService() {
|
|||||||
return {
|
return {
|
||||||
disableGaKey: 'disableGa',
|
disableGaKey: 'disableGa',
|
||||||
disableAddLoginNotificationKey: 'disableAddLoginNotification',
|
disableAddLoginNotificationKey: 'disableAddLoginNotification',
|
||||||
|
disableContextMenuItemKey: 'disableContextMenuItem',
|
||||||
lockOptionKey: 'lockOption',
|
lockOptionKey: 'lockOption',
|
||||||
lastActiveKey: 'lastActive'
|
lastActiveKey: 'lastActive'
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user