RequestPolicy/tractest — Issue #233: Only check if temporary permissions are set as required [don't try to keep a running count]
Author: jsamuel
Created: 2011-12-22 02:48:16+00:00
State: open
Labels: extension

The extension defines three properties to track the number of temporary permissions:

{{{
_temporarilyAllowedOriginsCount : 0,
_temporarilyAllowedDestinationsCount : 0,
_temporarilyAllowedOriginsToDestinationsCount : 0,
}}}

The counts are adjusted every time a site is temporarily allowed or denied. However, there is only one use of this information:

{{{
#requestpolicyStatusbarPopup[onpopupshowing]
=> onMenuShowing()
=> prepareMenu()
=> areTemporaryPermissionsGranted()
}}}

And this is only used to hide the "Revoke Temporary Permissions" menuitem if no temporary permissions are set...

Instead, the {{{areTemporaryPermissionsGranted()}}} function should do all the work:

{{{
for (var origin in this._temporarilyAllowedOrigins) return true;
for (var destination in this._temporarilyAllowedDestinations) return true;
for (var combinedId in this._temporarilyAllowedOriginsToDestinations) return true;
return false;
}}}

With this change, the counting can be eliminated, making the extension faster, and only considering whether any temporary permissions are set when the time is relevant -- when the menu is being populated.