Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix updating of checkbox when user accepts permissions request (#29)
When the user requests the extension to be given access to the site and confirms this in the consequent browser dialog, the context menu item wasn't being immediately changed to checked. We can fix this by ensuring that the updateItem() function which is responsible for updating the checkmark is called with the correct URL for the tab in question, so that it can detect whether the permission is now granted to the site and update the context menu item accordingly. Note that the browser will automatically enable the checkmark simply by virtue of the context menu item having been clicked. So if the user denies access in the dialog (despite previously requesting it to be given via a user-initiated "gesture", which is the only way the chrome.permissions API allows access to be given), then chrome.contextMenus.update() needs to be called to reverse that enabling of the checkmark. However by calling `updateItem()` within the `finally` block with the correct tab URL, we can ensure the checkmark is always correctly set regardless of what happened. Fixes #29.
- Loading branch information