AdBlock lets advanced users see all the resources requested by a tab, and which ad blocking filters matched which ones. I'm thinking about how to do this using declarativeWebRequest as it currently stands, and came up with:
1. Every RequestMatcher's actions includes a SendMessageToTab whose message specifies the original ad blocking filter that created the RequestMatcher.
2. There's a super-low-priority catch-all RequestMatcher whose SendMessageToTab specifies that the resource was not blocked.
3. Every tab runs an onMessage handler storing the map from resource to filter (or lack of filter).
4. If the user requests to see the map, show-requested-resources.html fetches it using sendMessage() to the current tab, and displays it.
Is there an easier way than that? I don't like having to run an onMessage handler for every requested resource; that's part of what declarativeWebRequest was designed to eliminate.
A couple API changes that could make this less painful:
1. Let the extension request that Chrome start logging all resources and which RequestMatchers they matched, if any, on a specific tab. Then the extension can stop logging and retrieve the log. (The log could truncate after N entries so a broken extension won't eat memory wildly.) AdBlock would then require that the user reload the current tab in order to generate and view the log.
2. Add an asynchronous declarativeWebRequest.whichRuleWouldBeTriggeredBy(request_details), letting the rule engine be queried without attempting to fetch a resource. Then extensions can just log all requested resources, and feed them one at a time to declarativeWebRequest if needed.
Chrome team, do either of those sound plausible? Any better ideas?
Michael