Hi Jeffrey,
I'd be grateful for your opinion on the following:
RulesRegistry needs to distinguish between install/uninstall a
enable/disable
changes for extensions.
For install, it needs to perform AddRules, including AddRulesImpl, and
similarly
for uninstall and RemoveRules.
For enable it only needs to perform AddRulesImpl, and similarly
RemoveRulesImpl
for disable.
In terms of NOTIFICATION_EXTENSION_INSTALLED,
NOTIFICATION_EXTENSION_UNINSTALLED, NOTIFICATION_EXTENSION_LOADED, and
NOTIFICATION_EXTENSION_UNLOADED events (I'll drop the common prefix below),
the
following happens:
on install: INSTALLED, then LOADED
on uninstall: UNLOADED, then UNINSTALLED
on enabled: LOADED
on disabled: UNLOADED
So the most natural seems to be responding with AddRulesImpl to LOADED,
RemoveRulesImple to UNLOADED, AddRules (without calling *Impl) to INSTALLED
and
RemoveRules (without calling *Impl) to UNINSTALLED.
However, there is a problem with reloading extensions.
ExtensionService::ReloadExtension causes this sequence: UNLOADED →
INSTALLED →
LOADED. This misses UNINSTALLED, which would result in duplicating the
rules in
RulesRegistry.
I tried to understand whether this omission is by design or not, but I
could not
convince myself either way.
My favourite option so far would be erasing all rules stored for an
extension in
RulesRegistry as soon as new are being saved due to the INSTALLED
notification.
Obviously if ExtensionService::ReloadExtension should actually emit
UNINSTALLED,
then my preferred solution changes to fixing that first.
I'm also open to any other suggestions, if you have any.
Thanks, and looking forward to hearing from you :)
Vaclav
https://codereview.chromium.org/52743002/