ExtensionDNR.clearRuleManager is currently being called from the onShutdown lifecycle method defined in the DNR ExtensionAPI subclass, but the onShutdown lifecycle method is only going to be called on extension shutdown if the DNR ExtensionAPI class has been instantiated.
The DNR ExtensionAPI class isn't going to be instantiated unless the extension does either:
- include a
declarative_net_request property in the manifest.json file
- the extension has called a
declarativeNetRequest API method at least once
When an extension has been installed and some DNR rules are being already registered, e.g. through declarativeNetRequest.updateDynamicRules which doesn't need a
declarative_net_request to be part of the manifest, the rules will be persisted on disk and on the next extension startup DNR make be initialized even if the extension will never call any other
declarativeNetRequest API method anymore, and in that case a RuleManager will be created and registered to ExtensionDNR and then never removed after the extension is shutdown.
We should make sure to register an extension shutdown listener to clear the RuleManager as part of initializing DNR for the same extension, so that it is going to be clearer independently from the
declarativeNetRequest ExtensionAPI class being instantiated or not.